int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = dst_addr;

    size_t want, did;



    while (nbytes) {

	want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;

	did = fread(buf, 1, want, f);



	cpu_physical_memory_write_rom(dst_addr, buf, did);

	dst_addr += did;

	nbytes -= did;

	if (did != want)

	    break;

    }

    return dst_addr - dst_begin;

}

int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = dst_addr;

    size_t want, did;



    while (nbytes) {

	want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;

	did = fread(buf, 1, want, f);



	cpu_physical_memory_write_rom(dst_addr, buf, did);

	dst_addr += did;

	nbytes -= did;

	if (did != want)

	    break;

    }

    return dst_addr - dst_begin;

}

int FUNC_0(target_phys_addr_t VAR_0, size_t VAR_1, FILE *VAR_2)

{

    uint8_t buf[4096];

    target_phys_addr_t dst_begin = VAR_0;

    size_t want, did;



    while (VAR_1) {

	want = VAR_1 > sizeof(buf) ? sizeof(buf) : VAR_1;

	did = fread(buf, 1, want, VAR_2);



	cpu_physical_memory_write_rom(VAR_0, buf, did);

	VAR_0 += did;

	VAR_1 -= did;

	if (did != want)

	    break;

    }

    return VAR_0 - dst_begin;

}

int FUNC_0(target_phys_addr_t VAR_0, size_t VAR_1, FILE *VAR_2)
{ uint8_t buf[4096]; target_phys_addr_t dst_begin = VAR_0; size_t want, did; while (VAR_1) { want = VAR_1 > sizeof(buf) ? sizeof(buf) : VAR_1; did = fread(buf, 1, want, VAR_2); cpu_physical_memory_write_rom(VAR_0, buf, did); VAR_0 += did; VAR_1 -= did; if (did != want)
break; } return VAR_0 - dst_begin; }