LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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 0xb673(%rip), %r15      # 0xdff8
movq (%r15), %rcx
leaq 0x774f(%rip), %rdi      # 0xa0de
pushq $0xe
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rdi
leaq 0x7746(%rip), %rsi      # 0xa0ed
movq %r14, %rdx
xorl %eax, %eax
callq 0x2170
movq (%r15), %rcx
leaq 0x775e(%rip), %rdi      # 0xa119
pushq $0x2d
popq %rsi
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rcx
leaq 0x7777(%rip), %rdi      # 0xa147
pushq $0x1c
popq %rsi
movq %rbx, %rdx
callq 0x22b0
movq (%r15), %rcx
leaq 0x777f(%rip), %rdi      # 0xa164
pushq $0x2c
popq %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O3/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 0x536f(%rip), %rsi      # 0x83a6
movl $0x9, %edx
movq %rbp, %rdi
callq 0x2050
movl $0x1, %r13d
testl %eax, %eax
jne 0x310f
movl 0x18(%r12), %r15d
leal -0x78(%r15), %eax
cmpl $-0x76, %eax
jbe 0x30cc
movl $0x8, %edi
movl $0x1, %esi
callq 0x2150
testq %rax, %rax
je 0x30d3
movq %rax, %r14
movq %rbp, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x2230
testl %eax, %eax
js 0x30da
movl %eax, %ebp
movq %rsp, %rdx
movl $0x705, %esi            # imm = 0x705
movl %eax, %edi
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x30e7
testb $0x1, (%rsp)
je 0x30f3
xorl %r13d, %r13d
movl $0x703, %esi            # imm = 0x703
movl %ebp, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x30ff
movl %ebp, (%r14)
movl %r15d, 0x4(%r14)
movq %r14, 0x50(%rbx)
jmp 0x310f
callq 0x23ef
jmp 0x3109
callq 0x23d3
jmp 0x3109
movq %r12, %rdi
movq %r14, %rsi
callq 0x23a8
jmp 0x3109
movl %ebp, %edi
movq %r14, %rsi
callq 0x2369
jmp 0x3109
movl %ebp, %edi
movq %r14, %rsi
callq 0x232f
jmp 0x3109
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_O3/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 0x314d
movq %rdi, %rbx
movl (%r14), %edi
callq 0x2120
movq %r14, %rdi
callq 0x2030
movq $0x0, 0x50(%rbx)
xorl %eax, %eax
jmp 0x3152
movl $0x3, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x317d
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_O3/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 0x3228
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x3a, %esi
callq 0x20d0
testq %rax, %rax
je 0x3228
movq %rax, %r14
cmpb $0x0, 0x1(%rax)
je 0x3228
incq %r14
movq %r14, %rdi
callq 0x20b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3235
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x38a9
movl %eax, %r14d
movq %r15, %rdi
callq 0x20b0
movl %r14d, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2090
testl %eax, %eax
js 0x38c6
movl %r14d, %edi
callq 0x2120
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xa748(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4d06(%rip), %rsi      # 0x85c0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2170
jmp 0x389c
movq 0xa72b(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4d00(%rip), %rsi      # 0x85d7
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2170
movl %r14d, %edi
callq 0x2120
jmp 0x389c
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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 0xaab9(%rip), %rax      # 0xe3b0
movq 0x20(%rax), %rdx
xorl %eax, %eax
movl %edi, %ecx
subl 0x18(%rdx), %ecx
jb 0x3931
cmpl %edi, 0x1c(%rdx)
jb 0x3931
movq 0x28(%rdx), %rdx
movl (%rdx), %esi
xorl %eax, %eax
cmpl %esi, %ecx
jb 0x392b
xorl %eax, %eax
cmpl $0x0, 0x4(%rdx)
je 0x3921
addq $0x4, %rdx
subl %esi, %ecx
incl %eax
movl (%rdx), %esi
cmpl %esi, %ecx
jae 0x3917
cmpl $0x1, %ecx
sbbl $-0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xa6bc(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4dfe(%rip), %rsi      # 0x8744
xorl %eax, %eax
callq 0x2170
movq 0xaa64(%rip), %rdi      # 0xe3b8
testq %rdi, %rdi
setne %cl
movq 0xaa5f(%rip), %rax      # 0xe3c0
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3971
callq *0x18(%rax)
movq 0xaa38(%rip), %rdi      # 0xe3b0
testq %rdi, %rdi
je 0x3982
callq 0x5bbc
movq 0xaa3f(%rip), %rdi      # 0xe3c8
testq %rdi, %rdi
je 0x3991
callq *0x18(%rdi)
movl $0x1, %edi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
leaq 0x94b2(%rip), %rax      # 0xe2c0
movq %rax, 0x95fb(%rip)      # 0xe410
movq 0x94a4(%rip), %rdi      # 0xe2c0
testq %rdi, %rdi
je 0x4e73
movq %rsi, %r14
movq %rbx, %rsi
callq *0x10(%rdi)
cmpl $0x1, %eax
jne 0x4e4c
movq 0x95da(%rip), %rax      # 0xe410
leaq 0x8(%rax), %rcx
movq %rcx, 0x95cf(%rip)      # 0xe410
movq 0x8(%rax), %rdi
testq %rdi, %rdi
jne 0x4e24
jmp 0x4e73
testl %eax, %eax
je 0x4e57
callq 0x2915
jmp 0x4e2f
movq 0x95b2(%rip), %rax      # 0xe410
movq (%rax), %rax
testq %rax, %rax
je 0x4e73
movq %rax, (%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x293a
movl $0x3, %eax
jmp 0x4e6b
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x4eca
cmpl $0x8c9ff, %edi          # imm = 0x8C9FF
jg 0x4f08
cmpl $0x3e7ff, %edi          # imm = 0x3E7FF
jle 0x4f96
cmpl $0x3e800, %edi          # imm = 0x3E800
je 0x4fe6
cmpl $0x70800, %edi          # imm = 0x70800
je 0x4fd4
cmpl $0x7a120, %edi          # imm = 0x7A120
jne 0x4ffe
movl $0xd, %eax
retq
cmpl $0x257f, %edi           # imm = 0x257F
jle 0x4f3e
cmpl $0x95ff, %edi           # imm = 0x95FF
jle 0x4f80
cmpl $0x9600, %edi           # imm = 0x9600
je 0x4fce
cmpl $0xe100, %edi           # imm = 0xE100
je 0x4fc8
cmpl $0x1c200, %edi          # imm = 0x1C200
jne 0x4ffe
movl $0x8, %eax
retq
cmpl $0xf423f, %edi          # imm = 0xF423F
jle 0x4fac
cmpl $0xf4240, %edi          # imm = 0xF4240
je 0x4fec
cmpl $0x16e360, %edi         # imm = 0x16E360
je 0x4fda
cmpl $0x1e8480, %edi         # imm = 0x1E8480
jne 0x4ffe
movl $0x12, %eax
retq
cmpl $0x95f, %edi            # imm = 0x95F
jg 0x4f66
xorl %eax, %eax
cmpl $0x4b0, %edi            # imm = 0x4B0
je 0x5003
cmpl $0x708, %edi            # imm = 0x708
jne 0x4ffe
movl $0x1, %eax
retq
cmpl $0x960, %edi            # imm = 0x960
je 0x4fc2
cmpl $0x12c0, %edi           # imm = 0x12C0
jne 0x4ffe
movl $0x3, %eax
retq
cmpl $0x2580, %edi           # imm = 0x2580
je 0x4fe0
cmpl $0x4b00, %edi           # imm = 0x4B00
jne 0x4ffe
movl $0x5, %eax
retq
cmpl $0x1f400, %edi          # imm = 0x1F400
je 0x4ff2
cmpl $0x38400, %edi          # imm = 0x38400
jne 0x4ffe
movl $0xa, %eax
retq
cmpl $0x8ca00, %edi          # imm = 0x8CA00
je 0x4ff8
cmpl $0xe1000, %edi          # imm = 0xE1000
jne 0x4ffe
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_O3/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 0x5430
callq 0x55b9
movq $0x0, 0x50(%rbx)
xorl %eax, %eax
jmp 0x5435
movl $0x3, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x544e
movl (%rax), %edi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x20c0
jmp 0x5453
movl $0x3, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x549f
movq %rdx, %r14
testq %rdx, %rdx
je 0x5496
movq %rsi, %r15
movl (%r12), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2140
testq %rax, %rax
je 0x549a
js 0x549f
addq %rax, %r15
subq %rax, %r14
jne 0x5478
xorl %ebx, %ebx
jmp 0x549f
movl $0x2, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x54ec
movq %rdx, %r14
testq %rdx, %rdx
je 0x54ea
movq %rsi, %r15
movl (%r12), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2090
testq %rax, %rax
jle 0x54ec
addq %rax, %r15
subq %rax, %r14
jne 0x54ce
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x5595
movl %edx, %ebp
cmpl $0x1, %esi
je 0x553f
cmpl $0x3, %esi
je 0x552c
cmpl $0x2, %esi
jne 0x5595
movl $0x2, %r15d
jmp 0x5545
testl %ebp, %ebp
je 0x5593
movl (%r14), %edi
movl $0x1, %esi
callq 0x2160
jmp 0x5587
movl $0x4, %r15d
movl (%r14), %edi
leaq 0x4(%rsp), %rdx
movl $0x5415, %esi           # imm = 0x5415
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
jne 0x5595
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 0x5595
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x7373
movb $0x1, %r13b
testl %eax, %eax
je 0x5c12
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 0x5c64
leal 0x2(%r12), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
testl %eax, %eax
je 0x5c93
movq 0x8(%r15), %rdi
callq 0x73fc
testl %eax, %eax
jne 0x5bff
movzbl %bpl, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
jne 0x5bff
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
testl %eax, %eax
jne 0x5bff
movzbl (%r14), %edx
jmp 0x5ca4
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
testl %eax, %eax
jne 0x5bff
movzbl (%r14), %edx
incq %r14
incq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
testl %eax, %eax
setne %r13b
jmp 0x5bff
movzbl (%r14), %edx
cmpl %r12d, %edx
jne 0x5ca4
xorl %r13d, %r13d
jmp 0x5bff
movq 0x834d(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x43dc(%rip), %rsi      # 0xa091
xorl %eax, %eax
callq 0x2170
movq 0x8(%r15), %rdi
callq 0x73fc
testl %eax, %eax
jne 0x5bff
movzbl (%r14), %r12d
movzbl %bpl, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
jne 0x5bff
addq $0x2, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
jmp 0x5c85
// File: /workspace/github_c_makefile_star2_O3/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 0x5dc4
movl %ecx, %r14d
cmpl $0x101, %ecx            # imm = 0x101
jae 0x5dd7
movq %rdi, %r12
movq 0x18(%rdi), %rax
movb 0x3(%rax), %al
cmpb $-0x1, %al
je 0x5de3
movq %rdx, %rbx
movl %esi, %r13d
movq 0x8(%r12), %r15
movzbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x7373
movl $0x1, %ebp
testl %eax, %eax
jne 0x5dc6
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 0x5dc6
movq 0x8(%r12), %rdi
xorl %esi, %esi
callq 0x6230
testl %eax, %eax
jne 0x5dc6
leal -0x1(%r14), %eax
movzbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
jne 0x5dc6
movl %r14d, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq *0x28(%r15)
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x5dc6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2b69
movl $0x1, %ebp
jmp 0x5dc6
callq 0x2b4d
movl $0x3, %ebp
jmp 0x5dc6
// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
xorl %r12d, %r12d
testb $0x8, 0x8(%rdi)
cmovneq %rsi, %r12
testq %r12, %r12
je 0x6259
leaq 0x18(%rsp), %rdi
callq 0x21b0
leaq 0xf(%rsp), %r14
leaq 0x10(%rsp), %r15
testq %r12, %r12
sete %bpl
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rbx)
cmpl $0x2, %eax
setne %cl
orb %bpl, %cl
jne 0x629c
movq %r15, %rdi
callq 0x21b0
movq 0x18(%rsp), %rax
addq %r12, %rax
cmpq %rax, 0x10(%rsp)
jl 0x6263
jmp 0x62ca
testl %eax, %eax
jne 0x62ca
movzbl 0xf(%rsp), %edx
cmpl $0x76, %edx
je 0x6263
cmpl $0x1f, %edx
je 0x62b8
cmpl $0x79, %edx
jne 0x62d1
xorl %eax, %eax
jmp 0x62bd
movl $0x2, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x2bd9
jmp 0x62e9
movq 0x7d20(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x3ddc(%rip), %rsi      # 0xa0be
xorl %eax, %eax
callq 0x2170
movl $0x1, %eax
jmp 0x62bd
// File: /workspace/github_c_makefile_star2_O3/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 0x6357
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
je 0x6321
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x6230
testl %eax, %eax
je 0x6319
cmpl $0x2, %eax
je 0x6363
testb $0x10, 0x8(%r14)
je 0x6314
movq 0x18(%rbx), %rax
cmpb $0x74, 0x8(%rax)
je 0x6314
leaq 0x39f3(%rip), %rdi      # 0x9d43
callq 0x2976
jmp 0x6314
callq 0x2c17
movl $0x3, %eax
jmp 0x6319
callq 0x2bfb
jmp 0x6314
// File: /workspace/github_c_makefile_star2_O3/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 0x63d1
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
je 0x639b
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x6230
testl %eax, %eax
je 0x6393
cmpl $0x2, %eax
je 0x63dd
testb $0x10, 0x8(%r14)
je 0x638e
movq 0x18(%rbx), %rax
cmpb $0x64, 0x7(%rax)
je 0x638e
leaq 0x39e6(%rip), %rdi      # 0x9db0
callq 0x2976
jmp 0x638e
callq 0x2c4f
movl $0x3, %eax
jmp 0x6393
callq 0x2c33
jmp 0x638e
// File: /workspace/github_c_makefile_star2_O3/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 0x644b
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
je 0x6415
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x8(%rbx), %rdi
movl $0x23, %esi
callq 0x6230
testl %eax, %eax
je 0x640d
cmpl $0x2, %eax
je 0x6457
testb $0x10, 0x8(%r14)
je 0x6408
movq 0x18(%rbx), %rax
cmpb $-0x6d, 0xa(%rax)
je 0x6408
leaq 0x39df(%rip), %rdi      # 0x9e23
callq 0x2976
jmp 0x6408
callq 0x2c87
movl $0x3, %eax
jmp 0x640d
callq 0x2c6b
jmp 0x6408
// File: /workspace/github_c_makefile_star2_O3/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 0x64c5
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x7373
testl %eax, %eax
je 0x648f
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x6230
testl %eax, %eax
je 0x6487
cmpl $0x2, %eax
je 0x64d1
testb $0x10, 0x8(%r14)
je 0x6482
movq 0x18(%rbx), %rax
cmpb $-0x7d, 0x9(%rax)
je 0x6482
leaq 0x39d8(%rip), %rdi      # 0x9e96
callq 0x2976
jmp 0x6482
callq 0x2cbf
movl $0x3, %eax
jmp 0x6487
callq 0x2ca3
jmp 0x6482
// File: /workspace/github_c_makefile_star2_O3/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 0x6f1a
movl %esi, %r15d
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movzbl %al, %esi
xorl %edx, %edx
callq 0x7373
movl $0x1, %ebp
testl %eax, %eax
jne 0x6f24
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 0x6f24
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x6230
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x6f24
callq 0x2e31
movl $0x3, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x6f4c
testb $0x4, %al
jne 0x6f5a
leaq 0x33c6(%rip), %rdx      # 0xa310
jmp 0x6f53
leaq 0x336d(%rip), %rdx      # 0xa2c0
movl $0x10, %ecx
jmp 0x6f68
leaq 0x336f(%rip), %rdx      # 0xa2d0
movl $0x38, %ecx
jmp 0x6f68
// File: /workspace/github_c_makefile_star2_O3/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 0x74a0
movl %eax, %r12d
leal 0x9(%rbx), %edi
callq 0x74a0
movq %rbx, 0x10(%rsp)
testb $0x3, %bl
jne 0x7063
movl %eax, 0x8(%rsp)
leal 0x8(%r13), %ebx
movl %ebx, %edi
callq 0x21c0
testq %rax, %rax
je 0x704f
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 0x5def
testl %eax, %eax
jne 0x7045
addl %r13d, %ebp
movl %r13d, %eax
addq %rax, %r12
subl %r13d, %ebx
jne 0x6ff1
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 0x6e99
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 0x2e4d
jmp 0x704f
// File: /workspace/github_c_makefile_star2_O3/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 0x7274
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movq 0x18(%rdi), %rax
cmpb $-0x1, 0xb(%rax)
je 0x7283
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 0x706a
callq 0x2ebd
movl $0x1, %eax
jmp 0x7341
movq %rcx, 0x8(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %ebp, %ebp
je 0x7332
movl %ebp, %eax
cvtsi2ss %rax, %xmm0
movss 0x1387(%rip), %xmm1     # 0x862c
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 0x5cf6
testl %eax, %eax
jne 0x7353
movl %r13d, %edi
leaq 0x10(%rsp), %rsi
movl %ebx, %edx
callq 0x71eb
addl %ebx, %r12d
movl %r12d, %ecx
subl %r14d, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
movl %eax, %r13d
movq 0x6cf7(%rip), %rax      # 0xdff8
movq (%rax), %rdi
mulss 0x4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2c86(%rip), %rsi      # 0x9f9b
movl %r12d, %edx
movb $0x1, %al
callq 0x2170
movq 0x6cd2(%rip), %rax      # 0xdff8
movq (%rax), %rdi
callq 0x21d0
subl %ebx, %ebp
jne 0x72b2
movl %r13d, %edi
movq 0x8(%rsp), %rsi
callq 0x2ed9
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6c9e(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x15e5(%rip), %rsi      # 0x8949
movl %r12d, %edx
xorl %eax, %eax
callq 0x2170
jmp 0x7279
// File: /workspace/github_c_makefile_star2_O3/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 0x73d4
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x6230
testl %eax, %eax
jne 0x73bc
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x2, %eax
jne 0x73db
movq 0x6c30(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x2c67(%rip), %rsi      # 0xa039
jmp 0x73ec
callq 0x2f06
jmp 0x73f5
movq 0x6c16(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x2c75(%rip), %rsi      # 0xa061
movl %ebx, %edx
xorl %eax, %eax
callq 0x2170
movl $0x1, %eax
jmp 0x73b2
// File: /workspace/github_c_makefile_star2_O3/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 %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 0x7450
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x22d0
jmp 0x7469
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq *0x28(%rbx)
testl %eax, %eax
jne 0x7469
cmpb $0x1f, 0x5(%rsp)
je 0x7488
movq %r14, %rdi
callq 0x21b0
movq 0x10(%rsp), %rax
addq $0x23, %rax
cmpq %rax, 0x8(%rsp)
jl 0x7432
movl $0x1, %eax
jmp 0x748a
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x74c0
leaq 0x2e6f(%rip), %rdi      # 0xa320
movl $0x7, %esi
movl $0x1, %edx
jmp 0x22b0
leaq 0x2e61(%rip), %rdi      # 0xa328
movl $0x3, %esi
movl $0x1, %edx
jmp 0x22b0
nop
// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movb (%rsi), %al
testb %bl, %bl
je 0x7538
cmpb $0x2d, %al
jne 0x7505
cmpb $0x0, 0x1(%r15)
je 0x7569
movq %r15, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x2230
movl %eax, (%r14)
movq $0x0, 0x38(%r14)
movb %bl, 0x4(%r14)
xorl %ecx, %ecx
cmpl $-0x1, %eax
sete %cl
movl %ecx, %eax
popq %rbx
popq %r14
popq %r15
retq
cmpb $0x2d, %al
jne 0x7543
cmpb $0x0, 0x1(%r15)
je 0x7570
leaq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x2190
movl $0x2, %ecx
testl %eax, %eax
jne 0x7530
movq %r15, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2230
movl %eax, (%r14)
jmp 0x7524
movl $0x1, %eax
jmp 0x7519
movl $0x0, (%r14)
xorl %eax, %eax
jmp 0x7524
// File: /workspace/github_c_makefile_star2_O3/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 0x758a
callq 0x2120
movq %rbx, %rdi
callq 0x2030
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/parsers/binary.c
// Function: binary_read
parser_err_t binary_read(void *storage, void *data, unsigned int *len) {
	binary_t *st = storage;
	unsigned int left = *len;
	unsigned char *d = data;

	if (st->write) return PARSER_ERR_WRONLY;

	ssize_t r;
	while(left > 0) {
		r = read(st->fd, d, left);
		/* If there is no data to read at all, return OK, but with zero read */
		if (r == 0 && left == *len) {
			*len = 0;
			return PARSER_ERR_OK;
		}
		if (r <= 0) return PARSER_ERR_SYSTEM;
		left -= r;
		d += r;
	}

	*len = *len - left;
	return PARSER_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0x3, %ebx
cmpb $0x0, 0x4(%rdi)
je 0x75b8
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r14
movl (%rdx), %ebp
xorl %ebx, %ebx
testl %ebp, %ebp
je 0x75ad
movq %rsi, %r15
movq %rdi, %r12
movl (%r12), %edi
movl %ebp, %edx
movq %r15, %rsi
callq 0x2140
testq %rax, %rax
je 0x75e7
jle 0x75fc
addq %rax, %r15
subl %eax, %ebp
jne 0x75c9
jmp 0x75ad
movl $0x1, %ebx
cmpl (%r14), %ebp
jne 0x75ad
movl $0x0, (%r14)
xorl %ebx, %ebx
jmp 0x75ad
movl $0x1, %ebx
jmp 0x75ad
// File: /workspace/github_c_makefile_star2_O3/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/parsers/binary.c
// Function: binary_write
parser_err_t binary_write(void *storage, void *data, unsigned int len) {
	binary_t *st = storage;
	unsigned char *d = data;

	if (!st->write) return PARSER_ERR_RDONLY;

	ssize_t r;
	while(len > 0) {
		r = write(st->fd, d, len);
		if (r < 1) return PARSER_ERR_SYSTEM;
		st->stat.st_size += r;

		len  -= r;
		d += r;
	}

	return PARSER_ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpb $0x0, 0x4(%rdi)
je 0x763d
movl %edx, %ebp
xorl %ebx, %ebx
testl %edx, %edx
je 0x7649
movq %rsi, %r14
movq %rdi, %r15
movl (%r15), %edi
movl %ebp, %edx
movq %r14, %rsi
callq 0x2090
testq %rax, %rax
jle 0x7644
addq %rax, 0x38(%r15)
addq %rax, %r14
subl %eax, %ebp
jne 0x761e
jmp 0x7649
movl $0x4, %ebx
jmp 0x7649
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/stm32flash/parsers/hex.c
// Function: hex_close
parser_err_t hex_close(void *storage) {
	hex_t *st = storage;
	if (st) free(st->data);
	free(st);
	return PARSER_ERR_OK;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
je 0x7a0c
movq 0x10(%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
xorl %eax, %eax
popq %rbx
retq