LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/millimat[P]Soft-Heap/epsilon-timing.c
// Function: main
int main(int argc, char *argv[]) {
  int n = 10000;
  int tries = 10;

  srand(time(NULL));

  time_insert_extract(tries, n);
  time_meld(tries, n);

  return 0;
}

// Assembly:
pushq %rax
xorl %edi, %edi
callq 0x10a0
movl %eax, %edi
callq 0x1090
movl $0xa, %edi
movl $0x2710, %esi           # imm = 0x2710
callq 0x11ec
movl $0xa, %edi
movl $0x2710, %esi           # imm = 0x2710
callq 0x1471
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/main.c
// Function: err_multi_action
static void err_multi_action(enum actions new)
{
	fprintf(stderr,
		"ERROR: Invalid options !\n"
		"\tCan't execute \"%s\" and \"%s\" at the same time.\n",
		action2str(action), action2str(new));
}

// Assembly:
movq 0xbbc4(%rip), %rax      # 0xdff8
movl 0xbf95(%rip), %r8d      # 0xe3d0
decl %r8d
leaq 0x6333(%rip), %rcx      # 0x8778
leaq 0xb954(%rip), %rsi      # 0xdda0
movq %rcx, %rdx
cmpl $0x6, %r8d
ja 0x245c
movl %r8d, %edx
movq (%rsi,%rdx,8), %rdx
movq (%rax), %rax
decl %edi
cmpl $0x6, %edi
ja 0x246c
movl %edi, %ecx
movq (%rsi,%rcx,8), %rcx
leaq 0x7414(%rip), %rsi      # 0x9887
movq %rax, %rdi
xorl %eax, %eax
jmp 0x2170
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_warn_stretching
static void stm32_warn_stretching(const char *f)
{
	fprintf(stderr, "Attention !!!\n");
	fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f);
	fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n");
	fprintf(stderr, "\tas required by bootloader.\n");
	fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movq 0xb5a7(%rip), %r15      # 0xdff8
movq (%r15), %rcx
leaq 0x75bf(%rip), %rdi      # 0xa01a
pushq $0xe
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rdi
leaq 0x75b6(%rip), %rsi      # 0xa029
movq %r14, %rdx
xorl %eax, %eax
callq 0x2170
movq (%r15), %rcx
leaq 0x75ce(%rip), %rdi      # 0xa055
pushq $0x2d
popq %rsi
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rcx
leaq 0x75e7(%rip), %rdi      # 0xa083
pushq $0x1c
popq %rsi
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rcx
leaq 0x75ef(%rip), %rdi      # 0xa0a0
pushq $0x2c
popq %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/i2c.c
// Function: i2c_open
static port_err_t i2c_open(struct port_interface *port,
			   struct port_options *ops)
{
	struct i2c_priv *h;
	int fd, addr, ret;
	unsigned long funcs;

	/* 1. check device name match */
	if (strncmp(ops->device, "/dev/i2c-", strlen("/dev/i2c-")))
		return PORT_ERR_NODEV;

	/* 2. check options */
	addr = ops->bus_addr;
	if (addr < 0x03 || addr > 0x77) {
		fprintf(stderr, "I2C address out of range [0x03-0x77]\n");
		return PORT_ERR_UNKNOWN;
	}

	/* 3. open it */
	h = calloc(sizeof(*h), 1);
	if (h == NULL) {
		fprintf(stderr, "End of memory\n");
		return PORT_ERR_UNKNOWN;
	}
	fd = open(ops->device, O_RDWR);
	if (fd < 0) {
		fprintf(stderr, "Unable to open special file \"%s\"\n",
			ops->device);
		free(h);
		return PORT_ERR_UNKNOWN;
	}

	/* 3.5. Check capabilities */
	ret = ioctl(fd, I2C_FUNCS, &funcs);
	if (ret < 0) {
		fprintf(stderr, "I2C ioctl(funcs) error %d\n", errno);
		close(fd);
		free(h);
		return PORT_ERR_UNKNOWN;
	}
	if ((funcs & I2C_FUNC_I2C) == 0) {
		fprintf(stderr, "Error: controller is not I2C, only SMBUS.\n");
		close(fd);
		free(h);
		return PORT_ERR_UNKNOWN;
	}

	/* 4. set options */
	ret = ioctl(fd, I2C_SLAVE, addr);
	if (ret < 0) {
		fprintf(stderr, "I2C ioctl(slave) error %d\n", errno);
		close(fd);
		free(h);
		return PORT_ERR_UNKNOWN;
	}

	h->fd = fd;
	h->addr = addr;
	port->private = h;
	return PORT_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
movq (%rsi), %rbp
leaq 0x52cf(%rip), %rsi      # 0x83a6
movl $0x9, %edx
movq %rbp, %rdi
callq 0x2050
movl $0x1, %r13d
testl %eax, %eax
jne 0x31af
movl 0x18(%r12), %r15d
leal -0x78(%r15), %eax
cmpl $-0x76, %eax
jbe 0x316c
movl $0x8, %edi
movl $0x1, %esi
callq 0x2150
testq %rax, %rax
je 0x3173
movq %rax, %r14
movq %rbp, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x2230
testl %eax, %eax
js 0x317a
movl %eax, %ebp
movq %rsp, %rdx
movl $0x705, %esi            # imm = 0x705
movl %eax, %edi
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x3187
testb $0x1, (%rsp)
je 0x3193
xorl %r13d, %r13d
movl $0x703, %esi            # imm = 0x703
movl %ebp, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x319f
movl %ebp, (%r14)
movl %r15d, 0x4(%r14)
movq %r14, 0x50(%rbx)
jmp 0x31af
callq 0x23ef
jmp 0x31a9
callq 0x23d3
jmp 0x31a9
movq %r12, %rdi
movq %r14, %rsi
callq 0x23a8
jmp 0x31a9
movl %ebp, %edi
movq %r14, %rsi
callq 0x2369
jmp 0x31a9
movl %ebp, %edi
movq %r14, %rsi
callq 0x232f
jmp 0x31a9
movl %ebp, %edi
movq %r14, %rsi
callq 0x22f0
movl $0x3, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/i2c.c
// Function: i2c_close
static port_err_t i2c_close(struct port_interface *port)
{
	struct i2c_priv *h;

	h = (struct i2c_priv *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;
	close(h->fd);
	free(h);
	port->private = NULL;
	return PORT_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x50(%rdi), %r14
testq %r14, %r14
je 0x31ed
movq %rdi, %rbx
movl (%r14), %edi
callq 0x2120
movq %r14, %rdi
callq 0x2030
movq $0x0, 0x50(%rbx)
xorl %eax, %eax
jmp 0x31f2
movl $0x3, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/i2c.c
// Function: i2c_read
static port_err_t i2c_read(struct port_interface *port, void *buf,
			   size_t nbyte)
{
	struct i2c_priv *h;
	int ret;

	h = (struct i2c_priv *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;
	ret = read(h->fd, buf, nbyte);
	if (ret != (int)nbyte)
		return PORT_ERR_UNKNOWN;
	return PORT_ERR_OK;
}

// Assembly:
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0x321d
pushq %rbx
movq %rdx, %rbx
movl (%rax), %edi
callq 0x2140
xorl %ecx, %ecx
cmpl %ebx, %eax
setne %cl
leal (%rcx,%rcx,2), %eax
popq %rbx
retq
movl $0x3, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/i2c.c
// Function: i2c_write
static port_err_t i2c_write(struct port_interface *port, void *buf,
			    size_t nbyte)
{
	struct i2c_priv *h;
	int ret;

	h = (struct i2c_priv *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;
	ret = write(h->fd, buf, nbyte);
	if (ret != (int)nbyte)
		return PORT_ERR_UNKNOWN;
	return PORT_ERR_OK;
}

// Assembly:
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0x3243
pushq %rbx
movq %rdx, %rbx
movl (%rax), %edi
callq 0x2090
xorl %ecx, %ecx
cmpl %ebx, %eax
setne %cl
leal (%rcx,%rcx,2), %eax
popq %rbx
retq
movl $0x3, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/init.c
// Function: gpio_bl_exit
int gpio_bl_exit(struct port_interface *port, const char *seq)
{
	char *s;

	if (seq == NULL)
		return 1;

	s = strchr(seq, ':');
	if (s == NULL || s[1] == '\0')
		return 1;

	return gpio_sequence(port, s + 1, strlen(s + 1));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x32c8
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x3a, %esi
callq 0x20d0
testq %rax, %rax
je 0x32c8
movq %rax, %r14
cmpb $0x0, 0x1(%rax)
je 0x32c8
incq %r14
movq %r14, %rdi
callq 0x20b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x32d5
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/init.c
// Function: write_to
static int write_to(const char *filename, const char *value)
{
	int fd, ret;

	fd = open(filename, O_WRONLY);
	if (fd < 0) {
		fprintf(stderr, "Cannot open file \"%s\"\n", filename);
		return 0;
	}
	ret = write(fd, value, strlen(value));
	if (ret < 0) {
		fprintf(stderr, "Error writing in file \"%s\"\n", filename);
		close(fd);
		return 0;
	}
	close(fd);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
xorl %ebp, %ebp
movl $0x1, %esi
xorl %eax, %eax
callq 0x2230
testl %eax, %eax
js 0x3a0c
movl %eax, %r14d
movq %r15, %rdi
callq 0x20b0
movl %r14d, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2090
testl %eax, %eax
js 0x3a29
movl %r14d, %edi
callq 0x2120
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xa5e5(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4baf(%rip), %rsi      # 0x85cc
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2170
jmp 0x39ff
movq 0xa5c8(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4ba9(%rip), %rsi      # 0x85e3
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2170
movl %r14d, %edi
callq 0x2120
jmp 0x39ff
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/main.c
// Function: flash_addr_to_page_ceil
int flash_addr_to_page_ceil(uint32_t addr)
{
	int page;
	uint32_t *psize;

	if (!(addr >= stm->dev->fl_start && addr <= stm->dev->fl_end))
		return 0;

	page = 0;
	addr -= stm->dev->fl_start;
	psize = stm->dev->fl_ps;

	while (addr >= psize[0]) {
		addr -= psize[0];
		page++;
		if (psize[1])
			psize++;
	}

	return addr ? page + 1 : page;
}

// Assembly:
movq 0xa959(%rip), %rax      # 0xe3b0
movq 0x20(%rax), %rdx
xorl %eax, %eax
movl %edi, %ecx
subl 0x18(%rdx), %ecx
jb 0x3a91
cmpl %edi, 0x1c(%rdx)
jb 0x3a91
movq 0x28(%rdx), %rdx
movl (%rdx), %esi
xorl %eax, %eax
cmpl %esi, %ecx
jb 0x3a8b
xorl %eax, %eax
cmpl $0x0, 0x4(%rdx)
je 0x3a81
addq $0x4, %rdx
subl %esi, %ecx
incl %eax
movl (%rdx), %esi
cmpl %esi, %ecx
jae 0x3a77
cmpl $0x1, %ecx
sbbl $-0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/main.c
// Function: sighandler
void sighandler(int s){
	fprintf(stderr, "\nCaught signal %d\n",s);
	if (p_st &&  parser ) parser->close(p_st);
	if (stm  ) stm32_close  (stm);
	if (port) port->close(port);
	exit(1);
}

// Assembly:
pushq %rax
movl %edi, %edx
movq 0xa55c(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4c8a(%rip), %rsi      # 0x8730
xorl %eax, %eax
callq 0x2170
movq 0xa904(%rip), %rdi      # 0xe3b8
testq %rdi, %rdi
setne %cl
movq 0xa8ff(%rip), %rax      # 0xe3c0
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3ad1
callq *0x18(%rax)
movq 0xa8d8(%rip), %rdi      # 0xe3b0
testq %rdi, %rdi
je 0x3ae2
callq 0x5c4d
movq 0xa8df(%rip), %rdi      # 0xe3c8
testq %rdi, %rdi
je 0x3af1
callq *0x18(%rdi)
movl $0x1, %edi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/port.c
// Function: port_open
port_err_t port_open(struct port_options *ops, struct port_interface **outport)
{
	int ret;
	static struct port_interface **port;

	for (port = ports; *port; port++) {
		ret = (*port)->open(*port, ops);
		if (ret == PORT_ERR_NODEV)
			continue;
		if (ret == PORT_ERR_OK)
			break;
		fprintf(stderr, "Error probing interface \"%s\"\n",
			(*port)->name);
	}
	if (*port == NULL) {
		fprintf(stderr, "Cannot handle device \"%s\"\n",
			ops->device);
		return PORT_ERR_UNKNOWN;
	}

	*outport = *port;
	return PORT_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x93c7(%rip), %rax      # 0xe2c0
movq %rax, 0x9510(%rip)      # 0xe410
movq 0x93b9(%rip), %rdi      # 0xe2c0
testq %rdi, %rdi
je 0x4f3a
movq %rbx, %rsi
callq *0x10(%rdi)
cmpl $0x1, %eax
jne 0x4f2f
movq 0x94f2(%rip), %rax      # 0xe410
leaq 0x8(%rax), %rcx
movq %rcx, 0x94e7(%rip)      # 0xe410
movq 0x8(%rax), %rdi
jmp 0x4f07
testl %eax, %eax
je 0x4f3a
callq 0x29e1
jmp 0x4f17
movq 0x94cf(%rip), %rax      # 0xe410
movq (%rax), %rax
testq %rax, %rax
je 0x4f56
movq %rax, (%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x2a06
movl $0x3, %eax
jmp 0x4f4e
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/serial_common.c
// Function: serial_get_baud
serial_baud_t serial_get_baud(const unsigned int baud) {
	switch(baud) {
		case   1200: return SERIAL_BAUD_1200  ;
		case   1800: return SERIAL_BAUD_1800  ;
		case   2400: return SERIAL_BAUD_2400  ;
		case   4800: return SERIAL_BAUD_4800  ;
		case   9600: return SERIAL_BAUD_9600  ;
		case  19200: return SERIAL_BAUD_19200 ;
		case  38400: return SERIAL_BAUD_38400 ;
		case  57600: return SERIAL_BAUD_57600 ;
		case 115200: return SERIAL_BAUD_115200;
		case 128000: return SERIAL_BAUD_128000;
		case 230400: return SERIAL_BAUD_230400;
		case 256000: return SERIAL_BAUD_256000;
		case 460800: return SERIAL_BAUD_460800;
		case 500000: return SERIAL_BAUD_500000;
		case 576000: return SERIAL_BAUD_576000;
		case 921600: return SERIAL_BAUD_921600;
		case 1000000: return SERIAL_BAUD_1000000;
		case 1500000: return SERIAL_BAUD_1500000;
		case 2000000: return SERIAL_BAUD_2000000;

		default:
			return SERIAL_BAUD_INVALID;
	}
}

// Assembly:
cmpl $0x1f3ff, %edi          # imm = 0x1F3FF
jle 0x4fae
cmpl $0x8c9ff, %edi          # imm = 0x8C9FF
jg 0x4fec
cmpl $0x3e7ff, %edi          # imm = 0x3E7FF
jle 0x507a
cmpl $0x3e800, %edi          # imm = 0x3E800
je 0x50ca
cmpl $0x70800, %edi          # imm = 0x70800
je 0x50b8
cmpl $0x7a120, %edi          # imm = 0x7A120
jne 0x50e2
movl $0xd, %eax
retq
cmpl $0x257f, %edi           # imm = 0x257F
jle 0x5022
cmpl $0x95ff, %edi           # imm = 0x95FF
jle 0x5064
cmpl $0x9600, %edi           # imm = 0x9600
je 0x50b2
cmpl $0xe100, %edi           # imm = 0xE100
je 0x50ac
cmpl $0x1c200, %edi          # imm = 0x1C200
jne 0x50e2
movl $0x8, %eax
retq
cmpl $0xf423f, %edi          # imm = 0xF423F
jle 0x5090
cmpl $0xf4240, %edi          # imm = 0xF4240
je 0x50d0
cmpl $0x16e360, %edi         # imm = 0x16E360
je 0x50be
cmpl $0x1e8480, %edi         # imm = 0x1E8480
jne 0x50e2
movl $0x12, %eax
retq
cmpl $0x95f, %edi            # imm = 0x95F
jg 0x504a
xorl %eax, %eax
cmpl $0x4b0, %edi            # imm = 0x4B0
je 0x50e7
cmpl $0x708, %edi            # imm = 0x708
jne 0x50e2
movl $0x1, %eax
retq
cmpl $0x960, %edi            # imm = 0x960
je 0x50a6
cmpl $0x12c0, %edi           # imm = 0x12C0
jne 0x50e2
movl $0x3, %eax
retq
cmpl $0x2580, %edi           # imm = 0x2580
je 0x50c4
cmpl $0x4b00, %edi           # imm = 0x4B00
jne 0x50e2
movl $0x5, %eax
retq
cmpl $0x1f400, %edi          # imm = 0x1F400
je 0x50d6
cmpl $0x38400, %edi          # imm = 0x38400
jne 0x50e2
movl $0xa, %eax
retq
cmpl $0x8ca00, %edi          # imm = 0x8CA00
je 0x50dc
cmpl $0xe1000, %edi          # imm = 0xE1000
jne 0x50e2
movl $0xf, %eax
retq
movl $0x2, %eax
retq
movl $0x7, %eax
retq
movl $0x6, %eax
retq
movl $0xc, %eax
retq
movl $0x11, %eax
retq
movl $0x4, %eax
retq
movl $0xb, %eax
retq
movl $0x10, %eax
retq
movl $0x9, %eax
retq
movl $0xe, %eax
retq
movl $0x13, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_posix_close
static port_err_t serial_posix_close(struct port_interface *port)
{
	serial_t *h;

	h = (serial_t *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;

	serial_close(h);
	port->private = NULL;
	return PORT_ERR_OK;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x50(%rdi), %rdi
testq %rdi, %rdi
je 0x54f7
callq 0x5680
movq $0x0, 0x50(%rbx)
xorl %eax, %eax
jmp 0x54fc
movl $0x3, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_posix_flush
static port_err_t serial_posix_flush(struct port_interface *port)
{
	serial_t *h;
	h = (serial_t *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;

	serial_flush(h);

	return PORT_ERR_OK;
}

// Assembly:
pushq %rbx
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0x5515
movl (%rax), %edi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x20c0
jmp 0x551a
movl $0x3, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_posix_read
static port_err_t serial_posix_read(struct port_interface *port, void *buf,
				     size_t nbyte)
{
	serial_t *h;
	ssize_t r;
	uint8_t *pos = (uint8_t *)buf;

	h = (serial_t *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;

	while (nbyte) {
		r = read(h->fd, pos, nbyte);
		if (r == 0)
			return PORT_ERR_TIMEDOUT;
		if (r < 0)
			return PORT_ERR_UNKNOWN;

		nbyte -= r;
		pos += r;
	}
	return PORT_ERR_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x50(%rdi), %r12
movl $0x3, %ebx
testq %r12, %r12
je 0x5566
movq %rdx, %r14
testq %rdx, %rdx
je 0x555d
movq %rsi, %r15
movl (%r12), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2140
testq %rax, %rax
je 0x5561
js 0x5566
addq %rax, %r15
subq %rax, %r14
jne 0x553f
xorl %ebx, %ebx
jmp 0x5566
movl $0x2, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_posix_write
static port_err_t serial_posix_write(struct port_interface *port, void *buf,
				      size_t nbyte)
{
	serial_t *h;
	ssize_t r;
	const uint8_t *pos = (const uint8_t *)buf;

	h = (serial_t *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;

	while (nbyte) {
		r = write(h->fd, pos, nbyte);
		if (r < 1)
			return PORT_ERR_UNKNOWN;

		nbyte -= r;
		pos += r;
	}
	return PORT_ERR_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x50(%rdi), %r12
movl $0x3, %ebx
testq %r12, %r12
je 0x55b3
movq %rdx, %r14
testq %rdx, %rdx
je 0x55b1
movq %rsi, %r15
movl (%r12), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2090
testq %rax, %rax
jle 0x55b3
addq %rax, %r15
subq %rax, %r14
jne 0x5595
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_posix_gpio
static port_err_t serial_posix_gpio(struct port_interface *port,
				    serial_gpio_t n, int level)
{
	serial_t *h;
	int bit, lines;

	h = (serial_t *)port->private;
	if (h == NULL)
		return PORT_ERR_UNKNOWN;

	switch (n) {
	case GPIO_RTS:
		bit = TIOCM_RTS;
		break;

	case GPIO_DTR:
		bit = TIOCM_DTR;
		break;

	case GPIO_BRK:
		if (level == 0)
			return PORT_ERR_OK;
		if (tcsendbreak(h->fd, 1))
			return PORT_ERR_UNKNOWN;
		return PORT_ERR_OK;

	default:
		return PORT_ERR_UNKNOWN;
	}

	/* handle RTS/DTR */
	if (ioctl(h->fd, TIOCMGET, &lines))
		return PORT_ERR_UNKNOWN;
	lines = level ? lines | bit : lines & ~bit;
	if (ioctl(h->fd, TIOCMSET, &lines))
		return PORT_ERR_UNKNOWN;

	return PORT_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x50(%rdi), %r14
movl $0x3, %ebx
testq %r14, %r14
je 0x565c
movl %edx, %ebp
cmpl $0x1, %esi
je 0x5606
cmpl $0x3, %esi
je 0x55f3
cmpl $0x2, %esi
jne 0x565c
movl $0x2, %r15d
jmp 0x560c
testl %ebp, %ebp
je 0x565a
movl (%r14), %edi
movl $0x1, %esi
callq 0x2160
jmp 0x564e
movl $0x4, %r15d
movl (%r14), %edi
leaq 0x4(%rsp), %rdx
movl $0x5415, %esi           # imm = 0x5415
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
jne 0x565c
leaq 0x4(%rsp), %rdx
movl (%rdx), %eax
movl %eax, %ecx
orl %r15d, %ecx
notl %r15d
andl %eax, %r15d
testl %ebp, %ebp
cmovnel %ecx, %r15d
movl %r15d, (%rdx)
movl (%r14), %edi
movl $0x5418, %esi           # imm = 0x5418
xorl %eax, %eax
callq 0x2110
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leal (%rcx,%rcx,2), %ebx
jmp 0x565c
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/./serial_posix.c
// Function: serial_close
static void serial_close(serial_t *h)
{
	serial_flush(h);
	tcsetattr(h->fd, TCSANOW, &h->oldtio);
	lockf(h->fd, F_ULOCK, 0);
	close(h->fd);
	free(h);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
xorl %esi, %esi
callq 0x20c0
movl (%rbx), %edi
leaq 0x4(%rbx), %rdx
xorl %esi, %esi
callq 0x2220
movl (%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20f0
movl (%rbx), %edi
callq 0x2120
movq %rbx, %rdi
popq %rbx
jmp 0x2030
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_guess_len_cmd
static stm32_err_t stm32_guess_len_cmd(const stm32_t *stm, uint8_t cmd,
				       uint8_t *data, unsigned int len)
{
	struct port_interface *port = stm->port;
	port_err_t p_err;

	if (stm32_send_command(stm, cmd) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;
	if (port->flags & PORT_BYTE) {
		/* interface is UART-like */
		p_err = port->read(port, data, 1);
		if (p_err != PORT_ERR_OK)
			return STM32_ERR_UNKNOWN;
		len = data[0];
		p_err = port->read(port, data + 1, len + 1);
		if (p_err != PORT_ERR_OK)
			return STM32_ERR_UNKNOWN;
		return STM32_ERR_OK;
	}

	p_err = port->read(port, data, len + 2);
	if (p_err == PORT_ERR_OK && len == data[0])
		return STM32_ERR_OK;
	if (p_err != PORT_ERR_OK) {
		/* restart with only one byte */
		if (stm32_resync(stm) != STM32_ERR_OK)
			return STM32_ERR_UNKNOWN;
		if (stm32_send_command(stm, cmd) != STM32_ERR_OK)
			return STM32_ERR_UNKNOWN;
		p_err = port->read(port, data, 1);
		if (p_err != PORT_ERR_OK)
			return STM32_ERR_UNKNOWN;
	}

	fprintf(stderr, "Re sync (len = %d)\n", data[0]);
	if (stm32_resync(stm) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	len = data[0];
	if (stm32_send_command(stm, cmd) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;
	p_err = port->read(port, data, len + 2);
	if (p_err != PORT_ERR_OK)
		return STM32_ERR_UNKNOWN;
	return STM32_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r12d
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movq 0x8(%rdi), %rbx
xorl %edx, %edx
callq 0x6b78
movb $0x1, %r13b
testl %eax, %eax
je 0x5ca3
movzbl %r13b, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, 0x8(%rbx)
movq 0x28(%rbx), %rax
jne 0x5cf0
leal 0x2(%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
testl %eax, %eax
je 0x5d1f
movq %r15, %rdi
callq 0x6c00
testl %eax, %eax
jne 0x5c90
movzbl %bpl, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
jne 0x5c90
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
testl %eax, %eax
jne 0x5c90
jmp 0x5d30
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
testl %eax, %eax
jne 0x5c90
movzbl (%r14), %edx
incq %r14
incq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
testl %eax, %eax
setne %r13b
jmp 0x5c90
movzbl (%r14), %eax
cmpl %r12d, %eax
jne 0x5d30
xorl %r13d, %r13d
jmp 0x5c90
movq 0x82c1(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movzbl (%r14), %edx
leaq 0x4288(%rip), %rsi      # 0x9fcd
xorl %eax, %eax
callq 0x2170
movq %r15, %rdi
callq 0x6c00
testl %eax, %eax
jne 0x5c90
movzbl (%r14), %r12d
movzbl %bpl, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
jne 0x5c90
addq $0x2, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
jmp 0x5d11
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_read_memory
stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address,
			      uint8_t data[], unsigned int len)
{
	struct port_interface *port = stm->port;
	uint8_t buf[5];

	if (!len)
		return STM32_ERR_OK;

	if (len > 256) {
		fprintf(stderr, "Error: READ length limit at 256 bytes\n");
		return STM32_ERR_UNKNOWN;
	}

	if (stm->cmd->rm == STM32_CMD_ERR) {
		fprintf(stderr, "Error: READ command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->rm) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	buf[0] = address >> 24;
	buf[1] = (address >> 16) & 0xFF;
	buf[2] = (address >> 8) & 0xFF;
	buf[3] = address & 0xFF;
	buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3];
	if (port->write(port, buf, 5) != PORT_ERR_OK)
		return STM32_ERR_UNKNOWN;
	if (stm32_get_ack(stm) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	if (stm32_send_command(stm, len - 1) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	if (port->read(port, data, len) != PORT_ERR_OK)
		return STM32_ERR_UNKNOWN;

	return STM32_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %ecx, %ecx
je 0x5e51
movl %ecx, %r14d
cmpl $0x101, %ecx            # imm = 0x101
jae 0x5e64
movq %rdi, %r12
movq 0x18(%rdi), %rax
movb 0x3(%rax), %al
cmpb $-0x1, %al
je 0x5e70
movq %rdx, %rbx
movl %esi, %r13d
movq 0x8(%r12), %r15
movzbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x6b78
movl $0x1, %ebp
testl %eax, %eax
jne 0x5e53
movl %r13d, %eax
shrl $0x18, %eax
leaq 0x3(%rsp), %rsi
movb %al, (%rsi)
movl %r13d, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rsi)
movl %r13d, %edx
shrl $0x8, %edx
movb %dl, 0x2(%rsi)
movb %r13b, 0x3(%rsi)
xorb %r13b, %cl
xorb %dl, %al
xorb %cl, %al
movb %al, 0x4(%rsi)
movl $0x5, %edx
movq %r15, %rdi
callq *0x30(%r15)
testl %eax, %eax
jne 0x5e53
movq %r12, %rdi
xorl %esi, %esi
callq 0x602b
testl %eax, %eax
jne 0x5e53
leal -0x1(%r14), %eax
movzbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
jne 0x5e53
movl %r14d, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq *0x28(%r15)
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x5e53
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2c61
movl $0x1, %ebp
jmp 0x5e53
callq 0x2c45
movl $0x3, %ebp
jmp 0x5e53
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_get_ack_timeout
static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout)
{
	struct port_interface *port = stm->port;
	uint8_t byte;
	port_err_t p_err;
	time_t t0, t1;

	if (!(port->flags & PORT_RETRY))
		timeout = 0;

	if (timeout)
		time(&t0);

	do {
		p_err = port->read(port, &byte, 1);
		if (p_err == PORT_ERR_TIMEDOUT && timeout) {
			time(&t1);
			if (t1 < t0 + timeout)
				continue;
		}

		if (p_err != PORT_ERR_OK) {
			fprintf(stderr, "Failed to read ACK byte\n");
			return STM32_ERR_UNKNOWN;
		}

		if (byte == STM32_ACK)
			return STM32_ERR_OK;
		if (byte == STM32_NACK)
			return STM32_ERR_NACK;
		if (byte != STM32_BUSY) {
			fprintf(stderr, "Got byte 0x%02x instead of ACK\n",
				byte);
			return STM32_ERR_UNKNOWN;
		}
	} while (1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x8(%rdi), %rbx
xorl %r12d, %r12d
testb $0x8, 0x8(%rbx)
cmovneq %rsi, %r12
testq %r12, %r12
je 0x6057
leaq 0x10(%rsp), %rdi
callq 0x21b0
leaq 0x7(%rsp), %r14
leaq 0x8(%rsp), %r15
testq %r12, %r12
sete %r13b
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
movl %eax, %ebp
cmpl $0x2, %eax
setne %al
orb %r13b, %al
jne 0x609a
movq %r15, %rdi
callq 0x21b0
movq 0x10(%rsp), %rax
addq %r12, %rax
cmpq %rax, 0x8(%rsp)
jl 0x6061
testl %ebp, %ebp
jne 0x60ca
movzbl 0x7(%rsp), %edx
cmpl $0x76, %edx
je 0x6061
cmpl $0x1f, %edx
je 0x60b6
cmpl $0x79, %edx
jne 0x60d1
xorl %eax, %eax
jmp 0x60bb
movl $0x2, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2cd1
jmp 0x60e9
movq 0x7f20(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x3f18(%rip), %rsi      # 0x9ffa
xorl %eax, %eax
callq 0x2170
movl $0x1, %eax
jmp 0x60bb
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_wunprot_memory
stm32_err_t stm32_wunprot_memory(const stm32_t *stm)
{
	struct port_interface *port = stm->port;
	stm32_err_t s_err;

	if (stm->cmd->uw == STM32_CMD_ERR) {
		fprintf(stderr, "Error: WRITE UNPROTECT command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->uw) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	s_err = stm32_get_ack_timeout(stm, STM32_WUNPROT_TIMEOUT);
	if (s_err == STM32_ERR_NACK) {
		fprintf(stderr, "Error: Failed to WRITE UNPROTECT\n");
		return STM32_ERR_UNKNOWN;
	}
	if (s_err != STM32_ERR_OK) {
		if ((port->flags & PORT_STRETCH_W)
		    && stm->cmd->uw != STM32_CMD_UW_NS)
			stm32_warn_stretching("WRITE UNPROTECT");
		return STM32_ERR_UNKNOWN;
	}
	return STM32_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rax
movb 0x8(%rax), %al
cmpb $-0x1, %al
je 0x6156
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
je 0x6121
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, %esi
movq %rbx, %rdi
callq 0x602b
testl %eax, %eax
je 0x6119
cmpl $0x2, %eax
je 0x6162
testb $0x10, 0x8(%r14)
je 0x6114
movq 0x18(%rbx), %rax
cmpb $0x74, 0x8(%rax)
je 0x6114
leaq 0x3b30(%rip), %rdi      # 0x9c7f
callq 0x2a42
jmp 0x6114
callq 0x2d0f
movl $0x3, %eax
jmp 0x6119
callq 0x2cf3
jmp 0x6114
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_wprot_memory
stm32_err_t stm32_wprot_memory(const stm32_t *stm)
{
	struct port_interface *port = stm->port;
	stm32_err_t s_err;

	if (stm->cmd->wp == STM32_CMD_ERR) {
		fprintf(stderr, "Error: WRITE PROTECT command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->wp) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	s_err = stm32_get_ack_timeout(stm, STM32_WPROT_TIMEOUT);
	if (s_err == STM32_ERR_NACK) {
		fprintf(stderr, "Error: Failed to WRITE PROTECT\n");
		return STM32_ERR_UNKNOWN;
	}
	if (s_err != STM32_ERR_OK) {
		if ((port->flags & PORT_STRETCH_W)
		    && stm->cmd->wp != STM32_CMD_WP_NS)
			stm32_warn_stretching("WRITE PROTECT");
		return STM32_ERR_UNKNOWN;
	}
	return STM32_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rax
movb 0x7(%rax), %al
cmpb $-0x1, %al
je 0x61cf
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
je 0x619a
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, %esi
movq %rbx, %rdi
callq 0x602b
testl %eax, %eax
je 0x6192
cmpl $0x2, %eax
je 0x61db
testb $0x10, 0x8(%r14)
je 0x618d
movq 0x18(%rbx), %rax
cmpb $0x64, 0x7(%rax)
je 0x618d
leaq 0x3b24(%rip), %rdi      # 0x9cec
callq 0x2a42
jmp 0x618d
callq 0x2d47
movl $0x3, %eax
jmp 0x6192
callq 0x2d2b
jmp 0x618d
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_runprot_memory
stm32_err_t stm32_runprot_memory(const stm32_t *stm)
{
	struct port_interface *port = stm->port;
	stm32_err_t s_err;

	if (stm->cmd->ur == STM32_CMD_ERR) {
		fprintf(stderr, "Error: READOUT UNPROTECT command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->ur) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT);
	if (s_err == STM32_ERR_NACK) {
		fprintf(stderr, "Error: Failed to READOUT UNPROTECT\n");
		return STM32_ERR_UNKNOWN;
	}
	if (s_err != STM32_ERR_OK) {
		if ((port->flags & PORT_STRETCH_W)
		    && stm->cmd->ur != STM32_CMD_UR_NS)
			stm32_warn_stretching("READOUT UNPROTECT");
		return STM32_ERR_UNKNOWN;
	}
	return STM32_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rax
movb 0xa(%rax), %al
cmpb $-0x1, %al
je 0x6248
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
je 0x6213
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x23, %esi
movq %rbx, %rdi
callq 0x602b
testl %eax, %eax
je 0x620b
cmpl $0x2, %eax
je 0x6254
testb $0x10, 0x8(%r14)
je 0x6206
movq 0x18(%rbx), %rax
cmpb $-0x6d, 0xa(%rax)
je 0x6206
leaq 0x3b1e(%rip), %rdi      # 0x9d5f
callq 0x2a42
jmp 0x6206
callq 0x2d7f
movl $0x3, %eax
jmp 0x620b
callq 0x2d63
jmp 0x6206
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_readprot_memory
stm32_err_t stm32_readprot_memory(const stm32_t *stm)
{
	struct port_interface *port = stm->port;
	stm32_err_t s_err;

	if (stm->cmd->rp == STM32_CMD_ERR) {
		fprintf(stderr, "Error: READOUT PROTECT command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->rp) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	s_err = stm32_get_ack_timeout(stm, STM32_RPROT_TIMEOUT);
	if (s_err == STM32_ERR_NACK) {
		fprintf(stderr, "Error: Failed to READOUT PROTECT\n");
		return STM32_ERR_UNKNOWN;
	}
	if (s_err != STM32_ERR_OK) {
		if ((port->flags & PORT_STRETCH_W)
		    && stm->cmd->rp != STM32_CMD_RP_NS)
			stm32_warn_stretching("READOUT PROTECT");
		return STM32_ERR_UNKNOWN;
	}
	return STM32_ERR_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rax
movb 0x9(%rax), %al
cmpb $-0x1, %al
je 0x62c1
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x6b78
testl %eax, %eax
je 0x628c
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, %esi
movq %rbx, %rdi
callq 0x602b
testl %eax, %eax
je 0x6284
cmpl $0x2, %eax
je 0x62cd
testb $0x10, 0x8(%r14)
je 0x627f
movq 0x18(%rbx), %rax
cmpb $-0x7d, 0x9(%rax)
je 0x627f
leaq 0x3b18(%rip), %rdi      # 0x9dd2
callq 0x2a42
jmp 0x627f
callq 0x2db7
movl $0x3, %eax
jmp 0x6284
callq 0x2d9b
jmp 0x627f
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_go
stm32_err_t stm32_go(const stm32_t *stm, uint32_t address)
{
	struct port_interface *port = stm->port;
	uint8_t buf[5];

	if (stm->cmd->go == STM32_CMD_ERR) {
		fprintf(stderr, "Error: GO command not implemented in bootloader.\n");
		return STM32_ERR_NO_CMD;
	}

	if (stm32_send_command(stm, stm->cmd->go) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;

	buf[0] = address >> 24;
	buf[1] = (address >> 16) & 0xFF;
	buf[2] = (address >> 8) & 0xFF;
	buf[3] = address & 0xFF;
	buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3];
	if (port->write(port, buf, 5) != PORT_ERR_OK)
		return STM32_ERR_UNKNOWN;

	if (stm32_get_ack(stm) != STM32_ERR_OK)
		return STM32_ERR_UNKNOWN;
	return STM32_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x18(%rdi), %rax
movb 0x4(%rax), %al
cmpb $-0x1, %al
je 0x6722
movl %esi, %r15d
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x6b78
movl $0x1, %ebp
testl %eax, %eax
jne 0x672c
movl %r15d, %eax
shrl $0x18, %eax
leaq 0x3(%rsp), %rsi
movb %al, (%rsi)
movl %r15d, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rsi)
movl %r15d, %edx
shrl $0x8, %edx
movb %dl, 0x2(%rsi)
movb %r15b, 0x3(%rsi)
xorb %r15b, %cl
xorb %dl, %al
xorb %cl, %al
movb %al, 0x4(%rsi)
movl $0x5, %edx
movq %r14, %rdi
callq *0x30(%r14)
testl %eax, %eax
jne 0x672c
movq %rbx, %rdi
xorl %esi, %esi
callq 0x602b
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x672c
callq 0x2ed5
movl $0x3, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_reset_device
stm32_err_t stm32_reset_device(const stm32_t *stm)
{
	uint32_t target_address = stm->dev->ram_start;

	if (stm->dev->flags & F_OBLL) {
		/* set the OBL_LAUNCH bit to reset device (see RM0360, 2.5) */
		return stm32_run_raw_code(stm, target_address, stm_obl_launch_code, stm_obl_launch_code_length);
	} else if (stm->dev->flags & F_PEMPTY) {
		/* clear the PEMPTY bit to reset the device (see RM0394) */
		return stm32_run_raw_code(stm, target_address, stm_pempty_launch_code, stm_pempty_launch_code_length);
	} else {
		return stm32_run_raw_code(stm, target_address, stm_reset_code, stm_reset_code_length);
	}
}

// Assembly:
movq 0x20(%rdi), %rax
movl 0x10(%rax), %esi
movl 0x40(%rax), %eax
testb $0x2, %al
jne 0x6754
testb $0x4, %al
jne 0x6762
leaq 0x3afe(%rip), %rdx      # 0xa250
jmp 0x675b
leaq 0x3aa5(%rip), %rdx      # 0xa200
movl $0x10, %ecx
jmp 0x6770
leaq 0x3aa7(%rip), %rdx      # 0xa210
movl $0x38, %ecx
jmp 0x6770
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_run_raw_code
static stm32_err_t stm32_run_raw_code(const stm32_t *stm,
				      uint32_t target_address,
				      const uint8_t *code, uint32_t code_size)
{
	uint32_t stack_le = le_u32(0x20002000);
	uint32_t code_address_le = le_u32(target_address + 8 + 1); // thumb mode address (!)
	uint32_t length = code_size + 8;
	uint8_t *mem, *pos;
	uint32_t address, w;

	/* Must be 32-bit aligned */
	if (target_address & 0x3) {
		fprintf(stderr, "Error: code address must be 4 byte aligned\n");
		return STM32_ERR_UNKNOWN;
	}

	mem = malloc(length);
	if (!mem)
		return STM32_ERR_UNKNOWN;

	memcpy(mem, &stack_le, sizeof(uint32_t));
	memcpy(mem + 4, &code_address_le, sizeof(uint32_t));
	memcpy(mem + 8, code, code_size);

	pos = mem;
	address = target_address;
	while (length > 0) {
		w = length > 256 ? 256 : length;
		if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) {
			free(mem);
			return STM32_ERR_UNKNOWN;
		}

		address += w;
		pos += w;
		length -= w;
	}

	free(mem);
	return stm32_go(stm, target_address);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r13d
movq %rdx, %rbp
movl %esi, %ebx
movq %rdi, %r14
movl $0x20002000, %edi       # imm = 0x20002000
callq 0x6ca4
movl %eax, %r12d
leal 0x9(%rbx), %edi
callq 0x6ca4
movq %rbx, 0x10(%rsp)
testb $0x3, %bl
jne 0x686b
movl %eax, 0x8(%rsp)
leal 0x8(%r13), %ebx
movl %ebx, %edi
callq 0x21c0
testq %rax, %rax
je 0x6857
movq %rax, %r15
movl %r12d, (%rax)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%r15)
movq %r15, %rdi
addq $0x8, %rdi
movl %r13d, %edx
movq %rbp, %rsi
callq 0x21a0
movq %r15, %r12
movl $0x100, %r15d           # imm = 0x100
movq 0x10(%rsp), %rax
movl %eax, %ebp
movq %r12, 0x8(%rsp)
cmpl %r15d, %ebx
movl $0x100, %r13d           # imm = 0x100
cmovbl %ebx, %r13d
movq %r14, %rdi
movl %ebp, %esi
movq %r12, %rdx
movl %r13d, %ecx
callq 0x5e7c
testl %eax, %eax
jne 0x684d
addl %r13d, %ebp
movl %r13d, %eax
addq %rax, %r12
subl %r13d, %ebx
jne 0x67f9
movq 0x8(%rsp), %rdi
callq 0x2030
movq %r14, %rdi
movq 0x10(%rsp), %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x66a2
movq 0x8(%rsp), %rdi
callq 0x2030
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2ef1
jmp 0x6857
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_crc_wrapper
stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address,
			      uint32_t length, uint32_t *crc)
{
	uint8_t buf[256];
	uint32_t start, total_len, len, current_crc;

	if ((address & 0x3) || (length & 0x3)) {
		fprintf(stderr, "Start and end addresses must be 4 byte aligned\n");
		return STM32_ERR_UNKNOWN;
	}

	if (stm->cmd->crc != STM32_CMD_ERR)
		return stm32_crc_memory(stm, address, length, crc);

	start = address;
	total_len = length;
	current_crc = CRC_INIT_VALUE;
	while (length) {
		len = length > 256 ? 256 : length;
		if (stm32_read_memory(stm, address, buf, len) != STM32_ERR_OK) {
			fprintf(stderr,
				"Failed to read memory at address 0x%08x, target write-protected?\n",
				address);
			return STM32_ERR_UNKNOWN;
		}
		current_crc = stm32_sw_crc(current_crc, buf, len);
		length -= len;
		address += len;

		fprintf(stderr,
			"\rCRC address 0x%08x (%.2f%%) ",
			address,
			(100.0f / (float)total_len) * (float)(address - start)
		);
		fflush(stderr);
	}
	fprintf(stderr, "Done.\n");
	*crc = current_crc;
	return STM32_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %edx, %eax
orl %esi, %eax
testb $0x3, %al
jne 0x6a79
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movq 0x18(%rdi), %rax
cmpb $-0x1, 0xb(%rax)
je 0x6a88
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6872
callq 0x2f61
movl $0x1, %eax
jmp 0x6b46
movq %rcx, 0x8(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %ebp, %ebp
je 0x6b37
movl %ebp, %eax
cvtsi2ss %rax, %xmm0
movss 0x1b8e(%rip), %xmm1     # 0x8638
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
movl %r14d, %r12d
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %ebp
movl $0x100, %ebx            # imm = 0x100
cmovbl %ebp, %ebx
movq %r15, %rdi
movl %r12d, %esi
leaq 0x10(%rsp), %rdx
movl %ebx, %ecx
callq 0x5d85
testl %eax, %eax
jne 0x6b58
movl %r13d, %edi
leaq 0x10(%rsp), %rsi
movl %ebx, %edx
callq 0x69f0
addl %ebx, %r12d
movl %r12d, %ecx
subl %r14d, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
movl %eax, %r13d
movq 0x74f2(%rip), %rax      # 0xdff8
movq (%rax), %rdi
mulss 0x4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x33bd(%rip), %rsi      # 0x9ed7
movl %r12d, %edx
movb $0x1, %al
callq 0x2170
movq 0x74cd(%rip), %rax      # 0xdff8
movq (%rax), %rdi
callq 0x21d0
subl %ebx, %ebp
jne 0x6ab7
movl %r13d, %edi
movq 0x8(%rsp), %rsi
callq 0x2f7d
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7499(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x1dcc(%rip), %rsi      # 0x8935
movl %r12d, %edx
xorl %eax, %eax
callq 0x2170
jmp 0x6a7e
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_send_command_timeout
static stm32_err_t stm32_send_command_timeout(const stm32_t *stm,
					      const uint8_t cmd,
					      time_t timeout)
{
	struct port_interface *port = stm->port;
	stm32_err_t s_err;
	port_err_t p_err;
	uint8_t buf[2];

	buf[0] = cmd;
	buf[1] = cmd ^ 0xFF;
	p_err = port->write(port, buf, 2);
	if (p_err != PORT_ERR_OK) {
		fprintf(stderr, "Failed to send command\n");
		return STM32_ERR_UNKNOWN;
	}
	s_err = stm32_get_ack_timeout(stm, timeout);
	if (s_err == STM32_ERR_OK)
		return STM32_ERR_OK;
	if (s_err == STM32_ERR_NACK)
		fprintf(stderr, "Got NACK from device on command 0x%02x\n", cmd);
	else
		fprintf(stderr, "Unexpected reply from device on command 0x%02x\n", cmd);
	return STM32_ERR_UNKNOWN;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movl %esi, %ebx
movq %rdi, %r15
movq 0x8(%rdi), %rdi
leaq 0xe(%rsp), %rsi
movb %bl, (%rsi)
movl %ebx, %eax
notb %al
movb %al, 0x1(%rsi)
movl $0x2, %edx
callq *0x30(%rdi)
testl %eax, %eax
jne 0x6bd8
movq %r15, %rdi
movq %r14, %rsi
callq 0x602b
testl %eax, %eax
jne 0x6bc0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x2, %eax
jne 0x6bdf
movq 0x742c(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x339f(%rip), %rsi      # 0x9f75
jmp 0x6bf0
callq 0x2faa
jmp 0x6bf9
movq 0x7412(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x33ad(%rip), %rsi      # 0x9f9d
movl %ebx, %edx
xorl %eax, %eax
callq 0x2170
movl $0x1, %eax
jmp 0x6bb6
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/stm32.c
// Function: stm32_resync
static stm32_err_t stm32_resync(const stm32_t *stm)
{
	struct port_interface *port = stm->port;
	port_err_t p_err;
	uint8_t buf[2], ack;
	time_t t0, t1;

	time(&t0);
	t1 = t0;

	buf[0] = STM32_CMD_ERR;
	buf[1] = STM32_CMD_ERR ^ 0xFF;
	while (t1 < t0 + STM32_RESYNC_TIMEOUT) {
		p_err = port->write(port, buf, 2);
		if (p_err != PORT_ERR_OK) {
			usleep(500000);
			time(&t1);
			continue;
		}
		p_err = port->read(port, &ack, 1);
		if (p_err != PORT_ERR_OK) {
			time(&t1);
			continue;
		}
		if (ack == STM32_NACK)
			return STM32_ERR_OK;
		time(&t1);
	}
	return STM32_ERR_UNKNOWN;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x8(%rdi), %rbx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x21b0
movq (%r14), %rax
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
leaq 0x6(%rsp), %r15
movw $0xff, (%r15)
leaq 0x5(%rsp), %r12
movl $0x2, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq *0x30(%rbx)
testl %eax, %eax
je 0x6c55
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x22d0
jmp 0x6c6e
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq *0x28(%rbx)
testl %eax, %eax
jne 0x6c6e
cmpb $0x1f, 0x5(%rsp)
je 0x6c8d
movq %r14, %rdi
callq 0x21b0
movq 0x10(%rsp), %rax
addq $0x23, %rax
cmpq %rax, 0x8(%rsp)
jl 0x6c37
movl $0x1, %eax
jmp 0x6c8f
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/utils.c
// Function: printStatus
void printStatus(FILE *fd, int condition){
	if(condition)
		fprintf(fd, "Error!\n");
	else
		fprintf(fd, "OK\n");
}

// Assembly:
movq %rdi, %rcx
testl %esi, %esi
je 0x6cc4
leaq 0x35ab(%rip), %rdi      # 0xa260
movl $0x7, %esi
movl $0x1, %edx
jmp 0x22b0
leaq 0x359d(%rip), %rdi      # 0xa268
movl $0x3, %esi
movl $0x1, %edx
jmp 0x22b0
nop
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/parsers/binary.c
// Function: binary_open
parser_err_t binary_open(void *storage, const char *filename, const char write) {
	binary_t *st = storage;
	if (write) {
		if (filename[0] == '-' && filename[1] == '\0')
			st->fd = 1;
		else
			st->fd = open(
				filename,
#ifndef __WIN32__
				O_WRONLY | O_CREAT | O_TRUNC,
#else
				O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
#endif
#ifndef __WIN32__
				S_IRUSR  | S_IWUSR | S_IRGRP | S_IROTH
#else
				0
#endif
			);
		st->stat.st_size = 0;
	} else {
		if (filename[0] == '-' && filename[1] == '\0') {
			st->fd = 0;
		} else {
			if (stat(filename, &st->stat) != 0)
				return PARSER_ERR_INVALID_FILE;
			st->fd = open(filename,
#ifndef __WIN32__
				O_RDONLY
#else
				O_RDONLY | O_BINARY
#endif
			);
		}
	}

	st->write = write;
	return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movb (%rsi), %al
testb %bpl, %bpl
je 0x6d38
cmpb $0x2d, %al
jne 0x6d09
cmpb $0x0, 0x1(%r14)
je 0x6d6a
movq %r14, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x2230
movl %eax, (%rbx)
movq $0x0, 0x38(%rbx)
movb %bpl, 0x4(%rbx)
xorl %eax, %eax
cmpl $-0x1, (%rbx)
sete %al
popq %rbx
popq %r14
popq %rbp
retq
cmpb $0x2d, %al
jne 0x6d43
cmpb $0x0, 0x1(%r14)
je 0x6d71
leaq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2190
movl %eax, %ecx
movl $0x2, %eax
testl %ecx, %ecx
jne 0x6d33
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2230
movl %eax, (%rbx)
jmp 0x6d27
movl $0x1, %eax
jmp 0x6d1d
movl $0x0, (%rbx)
jmp 0x6d27
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/parsers/binary.c
// Function: binary_close
parser_err_t binary_close(void *storage) {
	binary_t *st = storage;

	if (st->fd) close(st->fd);
	free(st);
	return PARSER_ERR_OK;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
testl %edi, %edi
je 0x6d88
callq 0x2120
movq %rbx, %rdi
callq 0x2030
xorl %eax, %eax
popq %rbx
retq