LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/ufat_mkfs.c
// Function: write_fsinfo
static int write_fsinfo(struct ufat_device *dev, const struct fs_layout *fl)
{
	const unsigned int log2_bps =
		fl->log2_sector_size - dev->log2_block_size;
	const unsigned int block_size = 1 << dev->log2_block_size;
	uint8_t buf[block_size];

	memset(buf, 0, sizeof(buf));
	w32(buf + 0x000, 0x41615252); /* FSI_LeadSig */
	w32(buf + 0x1e4, 0x61417272); /* FSI_StrucSig */
	w32(buf + 0x1e8, fl->clusters - 3); /* FSI_Free_Count */
	w32(buf + 0x1ec, 2); /* FSI_Nxt_Free */
	w32(buf + 0x1fc, 0xaa550000); /* FSI_TrailSig */

	/* Write FSInfo and its backup */
	const ufat_block_t fsinfo_block = FSINFO_SECTOR >> log2_bps;
	const ufat_block_t fsinfo_backup_block =
		(FSINFO_SECTOR + BACKUP_SECTOR) >> log2_bps;
	if (dev->write(dev, fsinfo_block, 1, buf) < 0 ||
	    dev->write(dev, fsinfo_backup_block, 1, buf) < 0)
		return -UFAT_ERR_IO;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, -0x2c(%rbp)
movq %rdi, %r14
movl (%rdi), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movl %esi, %r15d
subl %ecx, %r15d
leaq 0xf(%rdx), %r12
andq $-0x10, %r12
movq %rsp, %r13
movq %r13, %rbx
subq %r12, %rbx
movq %rbx, %rsp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1110
movl $0x41615252, (%rbx)     # imm = 0x41615252
movl $0x61417272, 0x1e4(%rbx) # imm = 0x61417272
negq %r12
movl -0x2c(%rbp), %ecx
addl $-0x3, %ecx
movb %cl, 0x1e8(%r13,%r12)
movb %ch, 0x1e9(%rbx)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x1ea(%rbx)
shrl $0x18, %ecx
movb %cl, 0x1eb(%rbx)
movl $0x2, 0x1ec(%rbx)
movl $0xaa550000, 0x1fc(%rbx) # imm = 0xAA550000
movl $0x1, %esi
movl %r15d, %ecx
shrl %cl, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%r14)
testl %eax, %eax
js 0x4a84
movl $0x7, %esi
movl %r15d, %ecx
shrl %cl, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%r14)
sarl $0x1f, %eax
jmp 0x4a89
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/ufat_mkfs.c
// Function: erase_blocks
static int erase_blocks(struct ufat_device *dev, ufat_block_t start,
			ufat_block_t count)
{
	const unsigned int block_size = 1 << dev->log2_block_size;
	uint8_t buf[block_size];

	memset(buf, 0, sizeof(buf));
	for (ufat_block_t i = 0; i < count; i++)
		if (dev->write(dev, start + i, 1, buf) < 0)
			return -UFAT_ERR_IO;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb (%rdi), %cl
movl $0x1, %eax
shlq %cl, %rax
movq %rdx, %r14
movq %rsi, %r13
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
movq %rsp, %r12
subq %rcx, %r12
movq %r12, %rsp
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x1110
movq %r14, -0x30(%rbp)
testq %r14, %r14
je 0x4d7f
movl $0x1, %r15d
movl $0x1, %edx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq *0x10(%rbx)
testl %eax, %eax
js 0x4d79
movq %r13, %r14
movq %r15, %r13
cmpq %r15, -0x30(%rbp)
je 0x4d6d
leaq (%r14,%r13), %rsi
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rcx
callq *0x10(%rbx)
leaq 0x1(%r13), %r15
testl %eax, %eax
jns 0x4d4a
xorl %r15d, %r15d
cmpq -0x30(%rbp), %r13
sbbl %r15d, %r15d
jmp 0x4d7f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: open_output
static FILE *open_output(const char *fname)
{
	FILE *out;

	if (!fname)
		return stdout;

	out = fopen(fname, "wb");
	if (!out) {
		fprintf(stderr, "Failed to open %s for writing: %s\n",
			fname, strerror(errno));
		return NULL;
	}

	return out;
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x531b
movq %rdi, %rbx
leaq 0x2b02(%rip), %rsi      # 0x7e07
callq 0x11a0
testq %rax, %rax
jne 0x5325
movq %rbx, %rdi
callq 0x13cc
xorl %eax, %eax
jmp 0x5325
movq 0x5c9e(%rip), %rax      # 0xafc0
movq (%rax), %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: cmd_read
static int cmd_read(struct ufat *uf, const struct options *opt)
{
	FILE *out;
	struct ufat_dirent ent;
	struct ufat_file file;
	int err;

	if (!opt->argc) {
		fprintf(stderr, "You must specify a file path\n");
		return -1;
	}

	if (require_file(uf, opt->argv[0], &ent) < 0)
		return -1;

	err = ufat_open_file(uf, &file, &ent);
	if (err < 0) {
		fprintf(stderr, "ufat_open_file: %s\n", ufat_strerror(err));
		return -1;
	}

	out = open_output(opt->out_file);
	if (!out)
		return -1;

	for (;;) {
		char buf[16384];
		int req_size = sizeof(buf);
		int len;

		if (opt->flags & OPTION_RANDOMIZE)
			req_size = random() % sizeof(buf) + 1;

		len = ufat_file_read(&file, buf, req_size);
		if (len < 0) {
			fprintf(stderr, "ufat_file_read: %s\n",
				ufat_strerror(len));
			close_output(opt->out_file, out);
			return -1;
		}

		if (!len)
			break;

		if (fwrite(buf, 1, len, out) != (size_t)len) {
			perror("fwrite");
			close_output(opt->out_file, out);
			return -1;
		}
	}

	return close_output(opt->out_file, out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4078, %rsp           # imm = 0x4078
cmpl $0x0, 0x40(%rsi)
je 0x5975
movq %rsi, %r14
movq %rdi, %r15
movq 0x38(%rsi), %rax
movq (%rax), %rsi
leaq 0x28(%rsp), %rdx
callq 0x61cb
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x5961
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
movq %r15, %rdi
callq 0x2e8c
testl %eax, %eax
js 0x5981
movq 0x20(%r14), %rdi
callq 0x52f5
testq %rax, %rax
je 0x5961
movq %rax, %r15
movq %rsp, %r12
leaq 0x70(%rsp), %r13
movl $0x4000, %edx           # imm = 0x4000
testb $0x2, (%r14)
je 0x591a
callq 0x1180
movq %rax, %rdx
andl $0x3fff, %edx           # imm = 0x3FFF
incl %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2f57
testl %eax, %eax
js 0x598a
je 0x5953
movl %eax, %ebp
movl $0x1, %esi
movq %r13, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x11e0
cmpq %rbp, %rax
je 0x58ff
leaq 0x24b4(%rip), %rdi      # 0x7e00
callq 0x11b0
jmp 0x5991
movq 0x20(%r14), %rdi
movq %r15, %rsi
callq 0x5327
movl %eax, %ebx
movl %ebx, %eax
addq $0x4078, %rsp           # imm = 0x4078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x14f6
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x5961
movl %eax, %edi
callq 0x14d0
jmp 0x5961
movl %eax, %edi
callq 0x14aa
movq 0x20(%r14), %rdi
movq %r15, %rsi
callq 0x5327
jmp 0x5961
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: cmd_rm
static int cmd_rm(struct ufat *uf, const struct options *opt)
{
	struct ufat_dirent ent;
	int err;

	if (!opt->argc) {
		fprintf(stderr, "You must specify a file path\n");
		return -1;
	}

	if (require_file(uf, opt->argv[0], &ent) < 0)
		return -1;

	err = ufat_dir_delete(uf, &ent);
	if (err < 0) {
		fprintf(stderr, "ufat_dir_delete: %s\n", ufat_strerror(err));
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbx
subq $0x50, %rsp
cmpl $0x0, 0x40(%rsi)
je 0x5c95
movq %rdi, %rbx
movq 0x38(%rsi), %rax
movq (%rax), %rsi
leaq 0x8(%rsp), %rdx
callq 0x61cb
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x5c8f
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x26f9
movl %eax, %edi
xorl %eax, %eax
testl %edi, %edi
js 0x5c9c
addq $0x50, %rsp
popq %rbx
retq
callq 0x15ce
jmp 0x5ca1
callq 0x15a8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5c8f
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: cmd_mkdir
static int cmd_mkdir(struct ufat *uf, const struct options *opt)
{
	const char *basename;
	struct ufat_directory dir;
	struct ufat_dirent ent;
	struct tm *local;
	time_t now = time(NULL);
	int err;

	if (!opt->argc) {
		fprintf(stderr, "You must specify a file path\n");
		return -1;
	}

	err = find_path(uf, &dir, opt->argv[0], &ent, &basename);
	if (err < 0)
		return -1;

	if (!err) {
		fprintf(stderr, "Path already exists: %s\n",
			opt->argv[0]);
		return -1;
	}

	local = localtime(&now);
	ent.attributes = 0;
	ent.create_date = UFAT_DATE(local->tm_year + 1900, local->tm_mon + 1,
				    local->tm_mday);
	ent.create_time = UFAT_TIME(local->tm_hour, local->tm_min,
				    local->tm_sec);
	ent.modify_date = ent.create_date;
	ent.modify_time = ent.create_time;
	ent.access_date = ent.create_date;

	err = ufat_dir_create(&dir, &ent, basename);
	if (err < 0) {
		fprintf(stderr, "ufat_dir_create: %s\n", ufat_strerror(err));
		return -1;
	}

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %edi, %edi
callq 0x1170
movq %rax, (%rsp)
cmpl $0x0, 0x40(%rbx)
je 0x5d6e
movq 0x38(%rbx), %rax
addq $0x38, %rbx
movq (%rax), %rdx
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r14, %rdi
callq 0x6222
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x5d66
je 0x5d75
movq %rsp, %rdi
callq 0x1050
leaq 0x30(%rsp), %rsi
movl $0x0, 0x2c(%rsi)
movl 0x10(%rax), %edx
movl 0x14(%rax), %ecx
shll $0x9, %ecx
addl $0x6000, %ecx           # imm = 0x6000
shll $0x5, %edx
orl 0xc(%rax), %ecx
addl $0x20, %edx
orl %edx, %ecx
movw %cx, 0x30(%rsi)
movl 0x8(%rax), %edx
shll $0xb, %edx
movl (%rax), %edi
movl 0x4(%rax), %eax
shll $0x5, %eax
orl %edx, %eax
shrl %edi
orl %eax, %edi
movw %di, 0x32(%rsi)
movw %cx, 0x34(%rsi)
movw %di, 0x36(%rsi)
movw %cx, 0x38(%rsi)
movq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rdi
callq 0x2822
movl %eax, %edi
xorl %eax, %eax
testl %edi, %edi
js 0x5d7f
addq $0x78, %rsp
popq %rbx
popq %r14
retq
callq 0x1637
jmp 0x5d84
movq %rbx, %rdi
callq 0x1610
jmp 0x5d84
callq 0x15ea
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5d66
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: cmd_rename
static int cmd_rename(struct ufat *uf, const struct options *opt)
{
	struct ufat_directory dir;
	struct ufat_dirent ent;
	int err;
	const char *src_path;
	const char *dst_name;

	if (opt->argc < 2) {
		fprintf(stderr, "You must specified a source path and "
			"a new name.\n");
		return -1;
	}

	src_path = opt->argv[0];
	dst_name = opt->argv[1];

	err = find_path(uf, &dir, src_path, &ent, NULL);
	if (err < 0)
		return -1;

	if (err) {
		fprintf(stderr, "No such file or directory: %s\n",
			ufat_strerror(err));
		return -1;
	}

	err = ufat_move(&ent, &dir, dst_name);
	if (err < 0) {
		fprintf(stderr, "ufat_move: %s\n", ufat_strerror(err));
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbx
subq $0x70, %rsp
cmpl $0x1, 0x40(%rsi)
jle 0x61b1
movq 0x38(%rsi), %rax
movq (%rax), %rdx
movq 0x8(%rax), %rbx
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rcx
xorl %r8d, %r8d
callq 0x6222
movl %eax, %edi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %edi
js 0x61ab
jne 0x61b8
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x2dea
movl %eax, %edi
xorl %eax, %eax
testl %edi, %edi
js 0x61bf
addq $0x70, %rsp
popq %rbx
retq
callq 0x17bc
jmp 0x61c4
callq 0x1770
jmp 0x61c4
callq 0x1796
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x61ab
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: require_file
static int require_file(struct ufat *uf, const char *path,
			struct ufat_dirent *ent)
{
	struct ufat_directory dir;
	int err = find_path(uf, &dir, path, ent, NULL);

	if (err < 0)
		return err;

	if (err) {
		fprintf(stderr, "No such file or directory: %s\n", path);
		return -1;
	}

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rcx
movq %rsi, %rbx
xorl %r14d, %r14d
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x6222
testl %eax, %eax
js 0x6214
je 0x6217
movq 0x4e00(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x1710(%rip), %rsi      # 0x7912
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x6217
movl %eax, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: find_path
static int find_path(struct ufat *uf,
		     struct ufat_directory *dir, const char *path,
		     struct ufat_dirent *inf, const char **path_out)
{
	int err;

	ufat_open_root(uf, dir);
	err = ufat_dir_find_path(dir, path, inf, path_out);

	if (err < 0)
		fprintf(stderr, "ufat_dir_find_path: %s\n",
			ufat_strerror(err));

	return err;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
callq 0x24e0
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2c3f
movl %eax, %ebx
testl %eax, %eax
js 0x6260
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl %ebx, %edi
callq 0x17d8
jmp 0x6252
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: parse_date
static int parse_date(const char *text, ufat_date_t *d)
{
	int bits[3] = {0};
	int b = 0;
	int i;

	if (!strcasecmp(text, "now")) {
		time_t now = time(NULL);
		struct tm *local = localtime(&now);

		*d = UFAT_DATE(local->tm_year + 1900,
			       local->tm_mon + 1,
			       local->tm_mday);
		return 0;
	}

	for (i = 0; text[i]; i++) {
		const int c = text[i];

		if (c == '-') {
			b++;
			if (b >= 3)
				goto bad_format;
		} else if (isdigit(c)) {
			bits[b] = bits[b] * 10 + c - '0';
		} else {
			goto bad_format;
		}
	}

	if (b < 2)
		goto bad_format;

	*d = UFAT_DATE(bits[0], bits[1], bits[2]);
	return 0;

 bad_format:
	fprintf(stderr, "Date must be of the form YYYY-MM-DD: %s\n", text);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x199e(%rip), %rsi      # 0x7c8a
callq 0x1040
testl %eax, %eax
je 0x6372
movb (%r14), %al
testb %al, %al
je 0x63a8
leaq 0x1(%r14), %r15
xorl %ebp, %ebp
cmpb $0x2d, %al
jne 0x6317
cmpl $0x1, %ebp
jg 0x63a8
incl %ebp
jmp 0x6342
movsbl %al, %r12d
callq 0x1200
movq (%rax), %rax
movslq %r12d, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x63a8
movslq %ebp, %rax
movl 0x8(%rsp,%rax,4), %ecx
leal (%rcx,%rcx,4), %ecx
leal (%r12,%rcx,2), %ecx
addl $-0x30, %ecx
movl %ecx, 0x8(%rsp,%rax,4)
movb (%r15), %al
incq %r15
testb %al, %al
jne 0x6306
cmpl $0x2, %ebp
jl 0x63a8
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
shll $0x9, %eax
addl $0x8800, %eax           # imm = 0x8800
shll $0x5, %ecx
orl %eax, %ecx
orl 0x10(%rsp), %ecx
movw %cx, (%rbx)
xorl %r14d, %r14d
jmp 0x63c9
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1170
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
callq 0x1050
movl 0x10(%rax), %ecx
movl 0x14(%rax), %edx
shll $0x9, %edx
addl $0x6000, %edx           # imm = 0x6000
shll $0x5, %ecx
addl $0x20, %ecx
orl 0xc(%rax), %edx
orl %ecx, %edx
movw %dx, (%rbx)
jmp 0x63c9
movq 0x4c49(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x18d5(%rip), %rsi      # 0x7c8e
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: parse_time
static int parse_time(const char *text, ufat_time_t *t)
{
	int bits[3] = {0};
	int b = 0;
	int i;

	if (!strcasecmp(text, "now")) {
		time_t now = time(NULL);
		struct tm *local = localtime(&now);

		*t = UFAT_TIME(local->tm_hour,
			       local->tm_min,
			       local->tm_sec);
		return 0;
	}

	for (i = 0; text[i]; i++) {
		const int c = text[i];

		if (c == ':') {
			b++;
			if (b >= 3)
				goto bad_format;
		} else if (isdigit(c)) {
			bits[b] = bits[b] * 10 + c - '0';
		} else {
			goto bad_format;
		}
	}

	if (b < 2)
		goto bad_format;

	*t = UFAT_TIME(bits[0], bits[1], bits[2]);
	return 0;

 bad_format:
	fprintf(stderr, "Time must be of the form HH:MM:SS: %s\n",
		text);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x1887(%rip), %rsi      # 0x7c8a
callq 0x1040
testl %eax, %eax
je 0x6488
movb (%r14), %al
testb %al, %al
je 0x64b8
leaq 0x1(%r14), %r15
xorl %ebp, %ebp
cmpb $0x3a, %al
jne 0x642e
cmpl $0x1, %ebp
jg 0x64b8
incl %ebp
jmp 0x6459
movsbl %al, %r12d
callq 0x1200
movq (%rax), %rax
movslq %r12d, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x64b8
movslq %ebp, %rax
movl 0x8(%rsp,%rax,4), %ecx
leal (%rcx,%rcx,4), %ecx
leal (%r12,%rcx,2), %ecx
addl $-0x30, %ecx
movl %ecx, 0x8(%rsp,%rax,4)
movb (%r15), %al
incq %r15
testb %al, %al
jne 0x641d
cmpl $0x2, %ebp
jl 0x64b8
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
shll $0xb, %eax
shll $0x5, %ecx
orl %eax, %ecx
movl 0x10(%rsp), %eax
shrl %eax
orl %ecx, %eax
movw %ax, (%rbx)
xorl %r14d, %r14d
jmp 0x64d9
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1170
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
callq 0x1050
movl 0x8(%rax), %ecx
shll $0xb, %ecx
movl (%rax), %edx
movl 0x4(%rax), %eax
shll $0x5, %eax
orl %ecx, %eax
shrl %edx
orl %eax, %edx
movw %dx, (%rbx)
jmp 0x64d9
movq 0x4b39(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x17ee(%rip), %rsi      # 0x7cb7
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: file_device_read
static int file_device_read(const struct ufat_device *dev, ufat_block_t start,
			    ufat_block_t count, void *buffer)
{
	struct file_device *f = (struct file_device *)dev;

	if (fseek(f->f, start << f->base.log2_block_size, SEEK_SET) < 0) {
		perror("file_device_read: fseek");
		return -1;
	}

	if (fread(buffer, 1 << f->base.log2_block_size,
		  count, f->f) != count) {
		if (feof(f->f)) {
			memset(buffer, 0xcc,
			       (1 << f->base.log2_block_size) * count);
		} else {
			perror("file_device_read: fread");
			return -1;
		}
	}

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %r12
movq 0x18(%rdi), %rdi
movb (%r12), %cl
shlq %cl, %rsi
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1190
testl %eax, %eax
js 0x6570
movb (%r12), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rsi
movq 0x18(%r12), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x10b0
cmpq %r15, %rax
je 0x6562
movq 0x18(%r12), %rdi
callq 0x1150
testl %eax, %eax
je 0x6579
movb (%r12), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rdx
imulq %r15, %rdx
movq %r14, %rdi
movl $0xcc, %esi
callq 0x1110
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1808(%rip), %rdi      # 0x7d7f
jmp 0x6580
leaq 0x1817(%rip), %rdi      # 0x7d97
callq 0x11b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x6562
// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: file_device_write
static int file_device_write(const struct ufat_device *dev, ufat_block_t start,
			     ufat_block_t count, const void *buffer)
{
	struct file_device *f = (struct file_device *)dev;

	if (f->is_read_only) {
		fprintf(stderr, "file_device_write: read-only device\n");
		return -1;
	}

	if (fseek(f->f, start << f->base.log2_block_size, SEEK_SET) < 0) {
		perror("file_device_write: fseek");
		return -1;
	}

	if (fwrite(buffer, 1 << f->base.log2_block_size,
		   count, f->f) != count) {
		perror("file_device_write: fwrite");
		return -1;
	}

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x0, 0x20(%rdi)
jne 0x65ec
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %r12
movq 0x18(%rdi), %rdi
movb (%r12), %cl
shlq %cl, %rsi
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1190
testl %eax, %eax
js 0x65f3
movb (%r12), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rsi
movq 0x18(%r12), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x11e0
cmpq %r14, %rax
jne 0x65fc
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x17fd
jmp 0x6608
leaq 0x17da(%rip), %rdi      # 0x7dd4
jmp 0x6603
leaq 0x17ea(%rip), %rdi      # 0x7ded
callq 0x11b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x65de
// File: /workspace/github_c_makefile_star2_O3/arq5x[P]grabix/bgzf.c
// Function: bgzf_write
ssize_t bgzf_write(BGZF *fp, const void *data, size_t length)
{
	const uint8_t *input = (const uint8_t*)data;
	int block_length = BGZF_BLOCK_SIZE, bytes_written = 0;
	assert(fp->is_write);
#ifdef BGZF_MT
	if (fp->mt) return mt_write(fp, data, length);
#endif
	while (bytes_written < length) {
		uint8_t* buffer = (uint8_t*)fp->uncompressed_block;
		int copy_length = block_length - fp->block_offset < length - bytes_written? block_length - fp->block_offset : length - bytes_written;
		memcpy(buffer + fp->block_offset, input, copy_length);
		fp->block_offset += copy_length;
		input += copy_length;
		bytes_written += copy_length;
		if (fp->block_offset == block_length && bgzf_flush(fp)) break;
	}
	return bytes_written;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testb $0x3, 0x2(%rdi)
je 0x49c1
movq %rdx, %r14
xorl %ebx, %ebx
testq %rdx, %rdx
je 0x49b4
movq %rsi, %r15
movq %rdi, %r12
xorl %eax, %eax
movslq 0xc(%r12), %rdi
movl $0xff00, %ecx           # imm = 0xFF00
subq %rdi, %rcx
movq %r14, %rdx
subq %rax, %rdx
cmpq %rcx, %rdx
cmoval %ecx, %edx
addq 0x18(%r12), %rdi
movslq %edx, %r13
movq %r15, %rsi
movq %r13, %rdx
callq 0x21a0
addl %r13d, %ebx
movl 0xc(%r12), %eax
addl %r13d, %eax
movl %eax, 0xc(%r12)
addq %r13, %r15
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x49a9
movq %r12, %rdi
callq 0x47a1
testl %eax, %eax
jne 0x49b1
movslq %ebx, %rax
cmpq %r14, %rax
jb 0x4957
movslq %ebx, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xbe2(%rip), %rdi       # 0x55aa
leaq 0xb46(%rip), %rsi       # 0x5515
leaq 0xbe1(%rip), %rcx       # 0x55b7
movl $0x239, %edx            # imm = 0x239
callq 0x2130
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: tun_tcp_close
static void tun_tcp_close(tun_data_t *data) {
  ELOG(__FUNCTION__);

  tcp_arg(data->tpcb, NULL);
  tcp_err(data->tpcb, NULL);
  tcp_recv(data->tpcb, NULL);
  tcp_sent(data->tpcb, NULL);

  tcp_close(data->tpcb);
  close(data->fd);
  tun_tcp_free(data);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x19777(%rip), %rax     # 0x1bff0
movq (%rax), %rdi
leaq 0x117e7(%rip), %rsi     # 0x1406a
leaq 0x12412(%rip), %rdx     # 0x14c9c
leaq 0x1193b(%rip), %r8      # 0x141cc
movl $0xac, %ecx
xorl %eax, %eax
callq 0x2170
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x84d4
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x8560
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x84de
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x851f
movq 0x8(%rbx), %rdi
callq 0x6e77
movl 0x4(%rbx), %edi
callq 0x2120
movq %rbx, %rdi
popq %rbx
jmp 0x2da9
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: tun_tcp_error
static void tun_tcp_error(void *arg, err_t err) {
  ELOG(__FUNCTION__);
  printf("err %d\n", err);

  close(((tun_data_t *)arg)->fd);
  tun_tcp_free((tun_data_t *)arg);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x196fd(%rip), %rax     # 0x1bff0
movq (%rax), %rdi
leaq 0x1176d(%rip), %rsi     # 0x1406a
leaq 0x12398(%rip), %rdx     # 0x14c9c
leaq 0x11891(%rip), %r8      # 0x1419c
movl $0x86, %ecx
xorl %eax, %eax
callq 0x2170
leaq 0x1188c(%rip), %rdi     # 0x141aa
movl %ebx, %esi
xorl %eax, %eax
callq 0x20d0
movl 0x4(%r14), %edi
callq 0x2120
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2da9
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: tun_tcp_recv
static err_t tun_tcp_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
                          err_t err) {
  ELOG(__FUNCTION__);

  ASSERT(err == ERR_OK);

  tun_data_t *data;
  int n;

  data = (tun_data_t *)arg;

  /* closed, peer will send no data */
  if (!p) {
    ELOG("client closed");

    if (data->server_status == TUN_CLOSE) {
      tun_tcp_close(data);
      return ERR_OK;
    } else {
      data->client_status = TUN_CLOSE;
    }
  }
  /* save pbuf to data->client_buf */
  else {
    if ((p->tot_len + data->client_buf_len) > TUN_TCP_SIZE) {
      ELOG("out of TUN_TCP_SIZE");
      tun_tcp_close(data);
      return ERR_OK;
    }

    n = pbuf_copy_partial(p, data->client_buf + data->client_buf_len,
                          p->tot_len, 0);
    if (n != p->tot_len) {
      ELOG("pbuf_copy_partial()");
      tun_tcp_close(data);
      return ERR_OK;
    }
    data->client_buf_len += n;
    pbuf_free(p);
  }

  /* can't do anything if server is TUN_CONNECTING */
  if (data->server_status == TUN_CONNECTED ||
      data->server_status == TUN_CLOSE) {
    lwip_to_epoll(data);
  }

  return ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rdi, %rbx
movq 0x1969b(%rip), %r15     # 0x1bff0
movq (%r15), %rdi
leaq 0x1170b(%rip), %rsi     # 0x1406a
leaq 0x12336(%rip), %rdx     # 0x14c9c
leaq 0x117ec(%rip), %r8      # 0x14159
pushq $0x55
popq %rcx
xorl %eax, %eax
callq 0x2170
testb %bpl, %bpl
jne 0x2a5e
testq %r14, %r14
je 0x29d6
movzwl 0x10(%r14), %eax
movslq 0x28(%rbx), %rsi
leal (%rsi,%rax), %ecx
cmpl $0x10000, %ecx          # imm = 0x10000
jge 0x2a09
addq 0x18(%rbx), %rsi
movzwl %ax, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x56cf
cmpw 0x10(%r14), %ax
jne 0x2a2f
movzwl %ax, %eax
addl %eax, 0x28(%rbx)
movq %r14, %rdi
callq 0x4fdf
movl 0x14(%rbx), %eax
decl %eax
cmpl $0x1, %eax
jbe 0x2a25
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdi
leaq 0x1168a(%rip), %rsi     # 0x1406a
leaq 0x122b5(%rip), %rdx     # 0x14c9c
leaq 0x11778(%rip), %r8      # 0x14166
pushq $0x60
popq %rcx
xorl %eax, %eax
callq 0x2170
movl 0x14(%rbx), %eax
cmpl $0x2, %eax
je 0x2a51
movl $0x2, 0x10(%rbx)
jmp 0x29c2
movq (%r15), %rdi
leaq 0x11657(%rip), %rsi     # 0x1406a
leaq 0x12282(%rip), %rdx     # 0x14c9c
leaq 0x11753(%rip), %r8      # 0x14174
pushq $0x6c
jmp 0x2a49
movq %rbx, %rdi
callq 0x2c7f
jmp 0x29c9
movq (%r15), %rdi
leaq 0x11631(%rip), %rsi     # 0x1406a
leaq 0x1225c(%rip), %rdx     # 0x14c9c
leaq 0x11741(%rip), %r8      # 0x14188
pushq $0x74
popq %rcx
xorl %eax, %eax
callq 0x2170
movq %rbx, %rdi
callq 0x286e
jmp 0x29c9
movq (%r15), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2220
leaq 0x11590(%rip), %rsi     # 0x14004
leaq 0x12221(%rip), %rdx     # 0x14c9c
pushq $0x57
popq %rcx
movq %rbx, %rdi
movq %rax, %r8
xorl %eax, %eax
callq 0x2170
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: handle_epoll_tcp
void handle_epoll_tcp(uint32_t events, tun_data_t *data) {
  ELOG(__FUNCTION__);

  if (data->server_status == TUN_CONNECTING) {
    data->server_status = TUN_CONNECTED;
  }
  if (events & EPOLLIN) {
    epoll_to_lwip(data);
  } else {
    lwip_to_epoll(data);
  }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movq 0x19516(%rip), %rax     # 0x1bff0
movq (%rax), %rdi
leaq 0x11586(%rip), %rsi     # 0x1406a
leaq 0x121b1(%rip), %rdx     # 0x14c9c
leaq 0x11656(%rip), %r8      # 0x14148
movl $0x97, %ecx
xorl %eax, %eax
callq 0x2170
cmpl $0x0, 0x14(%rbx)
jne 0x2b0b
movl $0x1, 0x14(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
testb $0x1, %bpl
jne 0x2b1f
popq %rbx
popq %rbp
jmp 0x2c7f
popq %rbx
popq %rbp
jmp 0x2b23
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: epoll_to_lwip
static void epoll_to_lwip(tun_data_t *data) {
  ELOG(__FUNCTION__);

  int nread, send_len;
  extern int errno;
  err_t err;

  nread = read(data->fd, data->server_buf + data->server_buf_len,
               TUN_TCP_SIZE - data->server_buf_len);
  if (nread == -1 && errno != EAGAIN) {
    ELOG("read()");
    tun_tcp_close(data);
    return;
  } else if (nread == 0) {
    if (data->client_status == TUN_CLOSE) {
      tun_tcp_close(data);
      return;
    } else {
      data->server_status = TUN_CLOSE;
    }
  } else if (nread > 0) {
    data->server_buf_len += nread;

    send_len = (data->server_buf_len < tcp_sndbuf(data->tpcb))
                   ? data->server_buf_len
                   : tcp_sndbuf(data->tpcb);

    err =
        tcp_write(data->tpcb, data->server_buf, send_len, TCP_WRITE_FLAG_COPY);
    if (err == ERR_OK) {
      data->server_buf_len -= send_len;
      tcp_output(data->tpcb);
    } else if (err != ERR_MEM) {
      ELOG("tcp_write()");
      tun_tcp_close(data);
      return;
    }
  }

  /* TUN_CLOSE and no buf left, should shutdown write side */
  if (data->server_buf_len == 0 && data->server_status == TUN_CLOSE) {
    ELOG("shutdown server write");

    tcp_shutdown(data->tpcb, 0, 1);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x194be(%rip), %r15     # 0x1bff0
movq (%r15), %rdi
leaq 0x1152e(%rip), %rsi     # 0x1406a
leaq 0x12159(%rip), %rdx     # 0x14c9c
leaq 0x116ba(%rip), %r8      # 0x14204
movl $0xd7, %ecx
xorl %eax, %eax
callq 0x2170
movl 0x4(%rbx), %edi
movslq 0x2c(%rbx), %rax
movq 0x20(%rbx), %rsi
addq %rax, %rsi
movl $0xffff, %edx           # imm = 0xFFFF
subq %rax, %rdx
callq 0x2140
movq %rax, %r14
testl %r14d, %r14d
je 0x2bab
cmpl $-0x1, %r14d
jne 0x2bbe
callq 0x2060
cmpl $0xb, (%rax)
je 0x2c05
movq (%r15), %rdi
leaq 0x114d7(%rip), %rsi     # 0x1406a
leaq 0x12102(%rip), %rdx     # 0x14c9c
leaq 0x11671(%rip), %r8      # 0x14212
movl $0xe0, %ecx
jmp 0x2c6b
cmpl $0x2, 0x10(%rbx)
je 0x2c72
movl $0x2, 0x14(%rbx)
jmp 0x2c05
testl %r14d, %r14d
jle 0x2c05
addl 0x2c(%rbx), %r14d
movl %r14d, 0x2c(%rbx)
movq 0x8(%rbx), %rdi
movq 0x20(%rbx), %rsi
movzwl 0x9c(%rdi), %eax
cmpl %eax, %r14d
cmovgel %eax, %r14d
movzwl %r14w, %edx
pushq $0x1
popq %rcx
callq 0xaa98
cmpb $-0x1, %al
je 0x2c05
movzbl %al, %eax
testl %eax, %eax
jne 0x2c4e
subl %r14d, 0x2c(%rbx)
movq 0x8(%rbx), %rdi
callq 0xbd02
cmpl $0x0, 0x2c(%rbx)
jne 0x2c11
cmpl $0x2, 0x14(%rbx)
je 0x2c17
popq %rbx
popq %r14
popq %r15
retq
movq (%r15), %rdi
leaq 0x11449(%rip), %rsi     # 0x1406a
leaq 0x12074(%rip), %rdx     # 0x14c9c
leaq 0x115f6(%rip), %r8      # 0x14225
movl $0xff, %ecx
xorl %eax, %eax
callq 0x2170
movq 0x8(%rbx), %rdi
pushq $0x1
popq %rdx
xorl %esi, %esi
popq %rbx
popq %r14
popq %r15
jmp 0x70bf
movq (%r15), %rdi
leaq 0x11412(%rip), %rsi     # 0x1406a
leaq 0x1203d(%rip), %rdx     # 0x14c9c
leaq 0x115b3(%rip), %r8      # 0x14219
movl $0xf7, %ecx
xorl %eax, %eax
callq 0x2170
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x286e
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: lwip_to_epoll
static void lwip_to_epoll(tun_data_t *data) {
  ELOG(__FUNCTION__);

  int nwrite;
  extern int errno;

  /* exit if sending is completed or unable to send */
  nwrite = write(data->fd, data->client_buf, data->client_buf_len);
  if (nwrite == -1 && errno != EAGAIN) {
    ELOG("write()");
    tun_tcp_close(data);
    return;
  } else if (nwrite > 0) {
    tcp_recved(data->tpcb, nwrite);
    data->client_buf_len -= nwrite;
    memmove(data->client_buf + nwrite, data->client_buf, data->client_buf_len);
  }

  /* TUN_CLOSE and no buf left, should shutdown write */
  if (data->client_buf_len == 0 && data->client_status == TUN_CLOSE) {
    ELOG("shutdown clientserver write");

    epoll_ET_mod(data, epollfd,
                 EPOLLIN); /* without this step epoll will loop indefinitely */
    shutdown(data->fd, SHUT_WR);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x19360(%rip), %r15     # 0x1bff0
movq (%r15), %rdi
leaq 0x113d0(%rip), %rsi     # 0x1406a
leaq 0x11ffb(%rip), %rdx     # 0x14c9c
leaq 0x11532(%rip), %r8      # 0x141da
movl $0xba, %ecx
xorl %eax, %eax
callq 0x2170
movl 0x4(%rbx), %edi
movq 0x18(%rbx), %rsi
movslq 0x28(%rbx), %rdx
callq 0x20a0
movq %rax, %r14
cmpl $-0x1, %r14d
je 0x2d04
testl %r14d, %r14d
jle 0x2d0e
movq 0x8(%rbx), %rdi
movzwl %r14w, %esi
callq 0x7a3b
movslq 0x28(%rbx), %rdx
movslq %r14d, %rax
subq %rax, %rdx
movl %edx, 0x28(%rbx)
movq 0x18(%rbx), %rsi
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
addq %rsi, %r14
movq %r14, %rdi
callq 0x21d0
jmp 0x2d0e
callq 0x2060
cmpl $0xb, (%rax)
jne 0x2d25
cmpl $0x0, 0x28(%rbx)
jne 0x2d1a
cmpl $0x2, 0x10(%rbx)
je 0x2d5b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdi
leaq 0x1133b(%rip), %rsi     # 0x1406a
leaq 0x11f66(%rip), %rdx     # 0x14c9c
leaq 0x114e0(%rip), %r8      # 0x1421d
movl $0xc2, %ecx
xorl %eax, %eax
callq 0x2170
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x286e
movq (%r15), %rdi
leaq 0x11305(%rip), %rsi     # 0x1406a
leaq 0x11f30(%rip), %rdx     # 0x14c9c
leaq 0x11475(%rip), %r8      # 0x141e8
movl $0xcd, %ecx
xorl %eax, %eax
callq 0x2170
leaq 0x193ea(%rip), %rax     # 0x1c170
movl (%rax), %esi
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x3aba
movl 0x4(%rbx), %edi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x20b0
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/tcp.c
// Function: tun_tcp_free
static void tun_tcp_free(tun_data_t *data) {
  ELOG(__FUNCTION__);

  FREE(data->client_buf);
  FREE(data->server_buf);
  FREE(data);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x1923c(%rip), %rax     # 0x1bff0
movq (%rax), %rdi
leaq 0x112ac(%rip), %rsi     # 0x1406a
leaq 0x11ed7(%rip), %rdx     # 0x14c9c
leaq 0x113e6(%rip), %r8      # 0x141b2
movl $0xa4, %ecx
xorl %eax, %eax
callq 0x2170
movq 0x18(%rbx), %rdi
callq 0x2030
andq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
popq %rbx
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/udp.c
// Function: handle_epoll_udp
void handle_epoll_udp(uint32_t events, tun_data_t *data) {
  ELOG(__FUNCTION__);

  static char *buf = NULL;
  int nread;
  ip_addr_t saddr, daddr;
  struct pbuf *p;

  printf("%d %d\n", data->sport, data->dport);

  /* get data from udp socket fd */
  if (!buf) {
    buf = MALLOC(MTU);
  }
  nread = read(data->fd, buf, MTU);
  if (nread <= 0 || nread == MTU) {
    ELOG("error udp packet size");
    return;
  }

  /* destination information */
  if (data->type == TUN_UDP) {
    saddr.type = IPADDR_TYPE_V4;
    memcpy(&saddr.u_addr, &data->saddr, 4);
    daddr.type = IPADDR_TYPE_V4;
    memcpy(&daddr.u_addr, &data->daddr, 4);
  } else if (data->type == TUN_UDP6) {
    saddr.type = IPADDR_TYPE_V6;
    memcpy(&saddr.u_addr, &data->saddr, 16);
    daddr.type = IPADDR_TYPE_V6;
    memcpy(&daddr.u_addr, &data->daddr, 16);
  }

  /* pack data and sendto */
  p = pbuf_alloc_reference(buf, nread, PBUF_ROM);
  if (!p) {
    ELOG("pbuf_alloc_reference");
    return;
  }

  udp_sendto(data->upcb, p, &saddr, data->sport, &daddr, data->dport);

  close(data->fd);
  FREE(data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq 0x18efa(%rip), %r14     # 0x1bff0
movq (%r14), %rdi
leaq 0x10f6a(%rip), %rsi     # 0x1406a
leaq 0x12e75(%rip), %rdx     # 0x15f7c
leaq 0x11167(%rip), %r8      # 0x14275
pushq $0x4f
popq %rcx
xorl %eax, %eax
callq 0x2170
movzwl 0x30(%rbx), %esi
movzwl 0x32(%rbx), %edx
leaq 0x11121(%rip), %rdi     # 0x14248
xorl %eax, %eax
callq 0x20d0
movq 0x19633(%rip), %rsi     # 0x1c768
testq %rsi, %rsi
jne 0x314e
movl $0x5dc, %edi            # imm = 0x5DC
callq 0x3b24
movq %rax, %rsi
movq %rax, 0x1961a(%rip)     # 0x1c768
movl 0x4(%rbx), %edi
movl $0x5dc, %edx            # imm = 0x5DC
callq 0x2140
testl %eax, %eax
jle 0x31fa
cmpl $0x5dc, %eax            # imm = 0x5DC
je 0x31fa
movl (%rbx), %ecx
cmpl $0x5, %ecx
je 0x3193
cmpl $0x4, %ecx
jne 0x31ae
xorl %ecx, %ecx
movb %cl, 0x34(%rsp)
movl 0x10(%rbx), %edx
movl %edx, 0x20(%rsp)
movb %cl, 0x14(%rsp)
movl 0x20(%rbx), %ecx
movl %ecx, (%rsp)
jmp 0x31ae
movb $0x6, %cl
movb %cl, 0x34(%rsp)
movups 0x10(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
movb %cl, 0x14(%rsp)
movups 0x20(%rbx), %xmm0
movaps %xmm0, (%rsp)
movq 0x195b3(%rip), %rdi     # 0x1c768
movzwl %ax, %esi
pushq $0x1
popq %rdx
callq 0x4f69
testq %rax, %rax
je 0x3216
movq 0x8(%rbx), %rdi
movzwl 0x30(%rbx), %ecx
movzwl 0x32(%rbx), %r9d
leaq 0x20(%rsp), %rdx
movq %rsp, %r8
movq %rax, %rsi
callq 0xd1ae
movl 0x4(%rbx), %edi
callq 0x2120
movq %rbx, %rdi
callq 0x2030
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq (%r14), %rdi
leaq 0x10e66(%rip), %rsi     # 0x1406a
leaq 0x12d71(%rip), %rdx     # 0x15f7c
leaq 0x11074(%rip), %r8      # 0x14286
pushq $0x5e
jmp 0x3230
movq (%r14), %rdi
leaq 0x10e4a(%rip), %rsi     # 0x1406a
leaq 0x12d55(%rip), %rdx     # 0x15f7c
leaq 0x1106e(%rip), %r8      # 0x1429c
pushq $0x72
popq %rcx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
jmp 0x2170
nop
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/main.c
// Function: epoll_ET_add
void epoll_ET_add(tun_data_t *data, int epollfd, u32_t events) {
  struct epoll_event event;

  if (setnonblocking(data->fd) == -1) {
    ELOG("setnonblocking()");
    return;
  }
  event.data.ptr = data;
  event.events = events | EPOLLET;
  if (epoll_ctl(epollfd, EPOLL_CTL_ADD, data->fd, &event) == -1) {
    ELOG("epoll_ctl()");
    return;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movl 0x4(%rdi), %r15d
movl %r15d, %edi
movl $0x1, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2090
orl $0x800, %eax            # imm = 0x800
movl %r15d, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x2090
cmpl $-0x1, %eax
je 0x3aac
leaq 0xc(%rsp), %rcx
movq %r14, 0x4(%rcx)
orl $0x80000000, %ebp       # imm = 0x80000000
movl %ebp, (%rcx)
movl 0x4(%r14), %edx
movl %ebx, %edi
movl $0x1, %esi
callq 0x2130
cmpl $-0x1, %eax
je 0x3ab3
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x24f5
jmp 0x3aa1
callq 0x24c4
jmp 0x3aa1
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/main.c
// Function: epoll_ET_mod
void epoll_ET_mod(tun_data_t *data, int epollfd, u32_t events) {
  struct epoll_event event;

  event.data.ptr = data;
  event.events = events | EPOLLET;
  if (epoll_ctl(epollfd, EPOLL_CTL_MOD, data->fd, &event) == -1) {
    ELOG("epoll_ctl()");
    return;
  }
}

// Assembly:
subq $0x18, %rsp
leaq 0xc(%rsp), %rcx
movq %rdi, 0x4(%rcx)
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rcx)
movl 0x4(%rdi), %edx
movl %esi, %edi
movl $0x3, %esi
callq 0x2130
cmpl $-0x1, %eax
je 0x3ae8
addq $0x18, %rsp
retq
callq 0x2520
jmp 0x3ae3
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/main.c
// Function: output
static err_t output(struct pbuf *p) {
  static char buf[MTU];
  int nwrite, bufLen;

  bufLen = pbuf_copy_partial(p, buf, p->tot_len, 0);
  nwrite = write(tunfd, buf, bufLen);
  if (nwrite == -1) {
    ELOG("output()");
  }
  return ERR_OK;
}

// Assembly:
pushq %rbx
movzwl 0x10(%rdi), %edx
leaq 0x18685(%rip), %rbx     # 0x1c180
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x56cf
movl 0x18669(%rip), %edi     # 0x1c174
movzwl %ax, %edx
movq %rbx, %rsi
callq 0x20a0
cmpl $-0x1, %eax
je 0x3b1d
popq %rbx
retq
callq 0x2551
jmp 0x3b1b
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/redefine.c
// Function: MALLOC
void *MALLOC(size_t n) {
  void *p = malloc(n);
  if (!p) {
    fprintf(stderr, "\033[31mMALLOC\033[0m %s:%d\n", __FILE__, __LINE__);
    exit(EXIT_FAILURE);
  }
  return p;
}

// Assembly:
pushq %rax
callq 0x21a0
testq %rax, %rax
je 0x3b31
popq %rcx
retq
callq 0x257a
nop
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/memp.c
// Function: memp_free_pool
void
memp_free_pool(const struct memp_desc *desc, void *mem)
{
  LWIP_ASSERT("invalid pool desc", desc != NULL);
  if ((desc == NULL) || (mem == NULL)) {
    return;
  }

  do_memp_free_pool(desc, mem);
}

// Assembly:
testq %rdi, %rdi
je 0x3cca
testq %rsi, %rsi
je 0x3cc9
movq %rsi, %rdi
jmp 0x3bf2
retq
pushq %rax
leaq 0x105fa(%rip), %rdi     # 0x142cc
leaq 0x106b6(%rip), %rsi     # 0x1438f
leaq 0x106c1(%rip), %rcx     # 0x143a1
movl $0x195, %edx            # imm = 0x195
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_init
void
netif_init(void)
{
#if LWIP_HAVE_LOOPIF
#if LWIP_IPV4
#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
  ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
  IP4_ADDR(&loop_gw, 127, 0, 0, 1);
  IP4_ADDR(&loop_ipaddr, 127, 0, 0, 1);
  IP4_ADDR(&loop_netmask, 255, 0, 0, 0);
#else /* LWIP_IPV4 */
#define LOOPIF_ADDRINIT
#endif /* LWIP_IPV4 */

#if NO_SYS
  netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
#else  /* NO_SYS */
  netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
#endif /* NO_SYS */

#if LWIP_IPV6
  IP_ADDR6_HOST(loop_netif.ip6_addr, 0, 0, 0, 0x00000001UL);
  loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
#endif /* LWIP_IPV6 */

  netif_set_link_up(&loop_netif);
  netif_set_up(&loop_netif);

#endif /* LWIP_HAVE_LOOPIF */
}

// Assembly:
subq $0x18, %rsp
movl $0x100007f, %eax        # imm = 0x100007F
leaq 0xc(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x14(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x10(%rsp), %rdx
movl $0xff, (%rdx)
leaq -0x19a(%rip), %rax      # 0x3bcb
movq %rax, (%rsp)
leaq 0x18a58(%rip), %rdi     # 0x1c7c8
leaq 0x29c(%rip), %r9        # 0x4013
xorl %r8d, %r8d
callq 0x3de3
movaps 0x1067a(%rip), %xmm0    # 0x14400
movups %xmm0, 0x18a8b(%rip)    # 0x1c818
movb $0x0, 0x18a94(%rip)     # 0x1c828
movb $0x6, 0x18a91(%rip)     # 0x1c82c
movb $0x10, 0x18abe(%rip)    # 0x1c860
movb 0x18b0b(%rip), %al      # 0x1c8b3
testb $0x4, %al
jne 0x3dc6
orb $0x4, %al
movb %al, 0x18aff(%rip)      # 0x1c8b3
leaq 0x18a0d(%rip), %rdi     # 0x1c7c8
callq 0x134e8
movb 0x18aed(%rip), %al      # 0x1c8b3
testb $0x1, %al
jne 0x3dde
orb $0x1, %al
movb %al, 0x18ae1(%rip)      # 0x1c8b3
leaq 0x189ef(%rip), %rdi     # 0x1c7c8
callq 0x134e8
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_input
err_t
netif_input(struct pbuf *p, struct netif *inp)
{
  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_input: invalid pbuf", p != NULL);
  LWIP_ASSERT("netif_input: invalid netif", inp != NULL);

#if LWIP_ETHERNET
  if (inp->flags & (NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET)) {
    return ethernet_input(p, inp);
  } else
#endif /* LWIP_ETHERNET */
    return ip_input(p, inp);
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x4115
testq %rsi, %rsi
je 0x4131
popq %rax
jmp 0x3bcb
leaq 0x101b0(%rip), %rdi     # 0x142cc
leaq 0x102fd(%rip), %rsi     # 0x14420
leaq 0x10310(%rip), %rcx     # 0x1443a
movl $0xdd, %edx
jmp 0x414b
leaq 0x10194(%rip), %rdi     # 0x142cc
leaq 0x10317(%rip), %rsi     # 0x14456
leaq 0x102f4(%rip), %rcx     # 0x1443a
movl $0xde, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_do_set_ipaddr
static int
netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *old_addr)
{
  LWIP_ASSERT("invalid pointer", ipaddr != NULL);
  LWIP_ASSERT("invalid pointer", old_addr != NULL);

  /* address is actually being changed? */
  if (ip4_addr_cmp(ipaddr, netif_ip4_addr(netif)) == 0) {
    ip_addr_t new_addr;
    *ip_2_ip4(&new_addr) = *ipaddr;
    IP_SET_TYPE_VAL(new_addr, IPADDR_TYPE_V4);

    ip_addr_copy(*old_addr, *netif_ip_addr4(netif));

    LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
    netif_do_ip_addr_changed(old_addr, &new_addr);

    mib2_remove_ip4(netif);
    mib2_remove_route_ip4(0, netif);
    /* set new IP address to netif */
    ip4_addr_set(ip_2_ip4(&netif->ip_addr), ipaddr);
    IP_SET_TYPE_VAL(netif->ip_addr, IPADDR_TYPE_V4);
    mib2_add_ip4(netif);
    mib2_add_route_ip4(0, netif);

    netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4);

    NETIF_STATUS_CALLBACK(netif);
    return 1; /* address changed */
  }
  return 0; /* address unchanged */
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x42e9
testq %rdx, %rdx
je 0x4305
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
cmpl 0x8(%rdi), %eax
je 0x42e1
movl %eax, (%rsp)
movb $0x0, 0x14(%rsp)
movb 0x1c(%rbx), %al
movb %al, 0x14(%rdx)
movl 0x8(%rbx), %ecx
movl %ecx, (%rdx)
cmpb $0x6, %al
jne 0x42b0
movl 0xc(%rbx), %eax
movl %eax, 0x4(%rdx)
movl 0x10(%rbx), %eax
movl %eax, 0x8(%rdx)
movl 0x14(%rbx), %eax
movl %eax, 0xc(%rdx)
movb 0x18(%rbx), %al
jmp 0x42c1
movl $0x0, 0xc(%rdx)
movq $0x0, 0x4(%rdx)
xorl %eax, %eax
movb %al, 0x10(%rdx)
movq %rsp, %rsi
movq %rdx, %rdi
callq 0x447a
movl (%r14), %eax
movl %eax, 0x8(%rbx)
movb $0x0, 0x1c(%rbx)
movq %rbx, %rdi
callq 0x44f9
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0xffdc(%rip), %rdi      # 0x142cc
leaq 0x104ff(%rip), %rsi     # 0x147f6
leaq 0x1013c(%rip), %rcx     # 0x1443a
movl $0x1cb, %edx            # imm = 0x1CB
jmp 0x431f
leaq 0xffc0(%rip), %rdi      # 0x142cc
leaq 0x104e3(%rip), %rsi     # 0x147f6
leaq 0x10120(%rip), %rcx     # 0x1443a
movl $0x1cc, %edx            # imm = 0x1CC
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_set_link_down
void
netif_set_link_down(struct netif *netif)
{
  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("netif_set_link_down: invalid netif", netif != NULL, return);

  if (netif->flags & NETIF_FLAG_LINK_UP) {
    netif_clear_flags(netif, NETIF_FLAG_LINK_UP);
    NETIF_LINK_CALLBACK(netif);
#if LWIP_NETIF_EXT_STATUS_CALLBACK
    {
      netif_ext_callback_args_t args;
      args.link_changed.state = 0;
      netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
    }
#endif
  }
}

// Assembly:
testq %rdi, %rdi
je 0x4545
movb 0xeb(%rdi), %al
testb $0x4, %al
je 0x4544
andb $-0x5, %al
movb %al, 0xeb(%rdi)
retq
pushq %rax
leaq 0xfd7f(%rip), %rdi      # 0x142cc
leaq 0x10052(%rip), %rsi     # 0x145a6
leaq 0xfedf(%rip), %rcx      # 0x1443a
movl $0x406, %edx            # imm = 0x406
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_ip6_addr_set
void
netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6)
{
  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_ip6_addr_set: invalid netif", netif != NULL);
  LWIP_ASSERT("netif_ip6_addr_set: invalid addr6", addr6 != NULL);

  netif_ip6_addr_set_parts(netif, addr_idx, addr6->addr[0], addr6->addr[1],
                           addr6->addr[2], addr6->addr[3]);
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x47ae
testq %rdx, %rdx
je 0x47ca
movl (%rdx), %eax
movl 0x4(%rdx), %ecx
movl 0x8(%rdx), %r8d
movl 0xc(%rdx), %r9d
movsbl %sil, %esi
movl %eax, %edx
popq %rax
jmp 0x47f7
leaq 0xfb17(%rip), %rdi      # 0x142cc
leaq 0xfee9(%rip), %rsi      # 0x146a5
leaq 0xfc77(%rip), %rcx      # 0x1443a
movl $0x526, %edx            # imm = 0x526
jmp 0x47e4
leaq 0xfafb(%rip), %rdi      # 0x142cc
leaq 0xfeef(%rip), %rsi      # 0x146c7
leaq 0xfc5b(%rip), %rcx      # 0x1443a
movl $0x527, %edx            # imm = 0x527
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050