LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x10(%rsp)
movq %rdi, %r14
andq $0x0, 0x8(%rsp)
leaq 0xf4f(%rip), %rsi       # 0x6c8a
callq 0x1040
testl %eax, %eax
je 0x5db3
xorl %ebp, %ebp
movq %r14, %r15
movsbl (%r15), %r12d
testl %r12d, %r12d
je 0x5d8e
cmpb $0x3a, %r12b
jne 0x5d65
cmpl $0x1, %ebp
jg 0x5df1
incl %ebp
jmp 0x5d89
callq 0x1200
movq (%rax), %rax
movslq %r12d, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x5df1
movslq %ebp, %rax
imull $0xa, 0x8(%rsp,%rax,4), %ecx
addl %r12d, %ecx
addl $-0x30, %ecx
movl %ecx, 0x8(%rsp,%rax,4)
incq %r15
jmp 0x5d49
cmpl $0x2, %ebp
jl 0x5df1
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 0x5de1
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)
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x4200(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0xeb5(%rip), %rsi       # 0x6cb7
movq %r14, %rdx
xorl %eax, %eax
callq 0x1140
pushq $-0x1
popq %r14
jmp 0x5de1
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
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 0x5e91
movb (%r12), %cl
pushq $0x1
popq %rbp
movl %ebp, %eax
shll %cl, %eax
movslq %eax, %rsi
movq 0x18(%r12), %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x10b0
cmpq %r15, %rax
je 0x5e86
movq 0x18(%r12), %rdi
callq 0x1150
testl %eax, %eax
je 0x5e9a
movb (%r12), %cl
shll %cl, %ebp
movslq %ebp, %rdx
imulq %r15, %rdx
movq %r14, %rdi
movl $0xcc, %esi
callq 0x1110
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xee7(%rip), %rdi       # 0x6d7f
jmp 0x5ea1
leaq 0xef6(%rip), %rdi       # 0x6d97
callq 0x11b0
pushq $-0x1
popq %rbx
jmp 0x5e86
// File: /workspace/github_c_makefile_star2_O2/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 0x5f09
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 0x5f27
movb (%r12), %cl
pushq $0x1
popq %rax
shll %cl, %eax
movslq %eax, %rsi
movq 0x18(%r12), %rcx
movq %r15, %rdi
movq %r14, %rdx
callq 0x11e0
cmpq %r14, %rax
jne 0x5f30
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x40e8(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0xe95(%rip), %rdi       # 0x6daf
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
jmp 0x5f3c
leaq 0xea6(%rip), %rdi       # 0x6dd4
jmp 0x5f37
leaq 0xeb6(%rip), %rdi       # 0x6ded
callq 0x11b0
pushq $-0x1
popq %rbx
jmp 0x5efb
// File: /workspace/github_c_makefile_star2_O2/accre[P]Cprogramming/file_IO.c
// Function: main
int main()
{
   
   // first example is reading from a file
   FILE *fp_in;
   fp_in = fopen("input_file.txt","r");
   // it's good practice to check whether the file
   // was actually opened successfully. fopen() will
   // fail if the file does not exist, for instance.
   if ( fp_in == NULL ) {
      printf("input_file.txt not opened, exiting...\n");
      exit(0);
   }
   int x,y,z;
   int i;
   for (i=0; i<3; i++) {
      fscanf(fp_in,"%d %d %d",&x,&y,&z);
      printf("x: %d y: %d z: %d\n",x,y,z);
   }
   fclose(fp_in);

   // now an example of writing to a file
   FILE *fp_out;
   fp_out = fopen("output_file.txt","w");
   if ( fp_out == NULL ) {
      printf("output_file.txt not opened, exiting...\n");
      exit(0);
   }
   for ( i=0 ; i < 50 ; i++ ) {
      fprintf(fp_out,"%d %d\n",i,i*10);
   } 
   fclose(fp_out);

   return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0xe53(%rip), %rdi       # 0x2004
leaq 0xe5b(%rip), %rsi       # 0x2013
callq 0x1080
testq %rax, %rax
je 0x1283
movq %rax, %rbx
pushq $0x3
popq %r14
leaq 0x14(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0xe3b(%rip), %rbp       # 0x201e
subl $0x1, %r14d
jb 0x121b
movq %rbx, %rdi
leaq 0xe22(%rip), %rsi       # 0x2015
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x1030
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
movl 0xc(%rsp), %ecx
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1060
jmp 0x11e3
movq %rbx, %rdi
callq 0x1050
leaq 0xe07(%rip), %rdi       # 0x2031
leaq 0xe10(%rip), %rsi       # 0x2041
callq 0x1080
testq %rax, %rax
je 0x128c
movq %rax, %rbx
leaq 0xdfe(%rip), %r14       # 0x2043
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpl $0x32, %r15d
je 0x126a
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1070
incl %r15d
addl $0xa, %ebp
jmp 0x124a
movq %rbx, %rdi
callq 0x1050
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xde7(%rip), %rdi       # 0x2071
jmp 0x1293
leaq 0xdb7(%rip), %rdi       # 0x204a
callq 0x1040
xorl %edi, %edi
callq 0x1090
// File: /workspace/github_c_makefile_star2_O2/arq5x[P]grabix/grabix.cpp
// Function: usage()
int usage()
{
    cout << "usage: grabix index bgzf_file " << endl;
    cout << "       grabix grab bgzf_file line_start [line_end] " << endl;
    cout << endl;
    cout << "examples:" << endl;
    cout << "       # create a grabix index (big.vcf.gz.gbi)" << endl;
    cout << "       grabix index big.vcf.gz" << endl;
    cout << endl;
    cout << "       # extract the 100th line." << endl;
    cout << "       grabix grab big.vcf.gz 100 [line_end] " << endl;
    cout << endl;
    cout << "       # extract the 100th through the 200th lines." << endl;
    cout << "       grabix grab big.vcf.gz 100 200 " << endl;
    cout << endl;
    cout << "       # extract the 100 random lines." << endl;
    cout << "       grabix random big.vcf.gz 100" << endl;
    cout << endl;
    cout << "       # Is the file bgzipped?" << endl;
    cout << "       grabix check big.vcf.gz" << endl;
    cout << endl;
    cout << "       # get total number of lines in the file (minus the header)." << endl;
    cout << "       grabix size big.vcf.gz" << endl;
    cout << "version: " << VERSION << "\n";
    cout << endl;
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbx
movq 0x56b4(%rip), %rbx      # 0x7fd0
leaq 0x27ad(%rip), %rsi      # 0x50d0
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x27b5(%rip), %rsi      # 0x50ef
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x27ca(%rip), %rsi      # 0x5123
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x27bd(%rip), %rsi      # 0x512d
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x27d6(%rip), %rsi      # 0x515d
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x27d6(%rip), %rsi      # 0x517c
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x27e0(%rip), %rsi      # 0x519d
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x27ef(%rip), %rsi      # 0x51cb
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x280c(%rip), %rsi      # 0x51ff
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x2814(%rip), %rsi      # 0x5226
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x2824(%rip), %rsi      # 0x524d
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x2829(%rip), %rsi      # 0x5271
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x2831(%rip), %rsi      # 0x5290
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2100
leaq 0x2831(%rip), %rsi      # 0x52af
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x285d(%rip), %rsi      # 0x52f2
movq %rbx, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
leaq 0x2864(%rip), %rsi      # 0x5310
movq %rbx, %rdi
callq 0x2220
leaq 0x285f(%rip), %rsi      # 0x531a
movq %rax, %rdi
callq 0x2220
leaq 0x2559(%rip), %rsi      # 0x5023
movq %rax, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2100
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/arq5x[P]grabix/grabix.cpp
// Function: load_index(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, index_info&)
void load_index(string bgzf_file, index_info &index)
{
    string index_file_name = bgzf_file + ".gbi";
    // open the index file for reading
    ifstream index_file(index_file_name.c_str(), ios::in);

    if ( !index_file ) {
        cerr << "[grabix] could not find index file: " << index_file_name << ". Exiting!" << endl;
        exit (1);
    }
    else {
        string line;
        getline (index_file, line);
        index.header_end = atol(line.c_str());

        getline (index_file, line);
        index.num_lines = atol(line.c_str());

        while (index_file >> line)
        {
            index.chunk_offsets.push_back(atol(line.c_str()));
        }
    }
    index_file.close();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x254b(%rip), %rdx      # 0x5383
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x350a
movq (%r14), %rsi
leaq 0x50(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2410
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x70(%rsp,%rax)
jne 0x2f31
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2040
leaq 0x10(%rsp), %r14
movq (%r14), %rdi
callq 0x22d0
movq %rax, (%rbx)
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x2040
leaq 0x10(%rsp), %r14
movq (%r14), %rdi
callq 0x22d0
movq %rax, 0x20(%rbx)
addq $0x8, %rbx
leaq 0x50(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2efa
movq 0x10(%rsp), %rdi
callq 0x22d0
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3706
jmp 0x2ec5
leaq 0x10(%rsp), %rdi
callq 0x20e0
leaq 0x50(%rsp), %rdi
callq 0x2050
leaq 0x50(%rsp), %rdi
callq 0x2060
leaq 0x30(%rsp), %rdi
callq 0x20e0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x50b8(%rip), %rdi      # 0x7ff0
leaq 0x2449(%rip), %rsi      # 0x5388
callq 0x2220
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
leaq 0x2455(%rip), %rsi      # 0x53ad
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2100
pushq $0x1
popq %rdi
callq 0x22e0
movq %rax, %rbx
jmp 0x2f95
movq %rax, %rbx
jmp 0x2f8b
jmp 0x2f7e
jmp 0x2f7e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20e0
leaq 0x50(%rsp), %rdi
callq 0x2060
leaq 0x30(%rsp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x23f0
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testb $0x3, 0x2(%rdi)
je 0x4076
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %ebp, %ebp
movslq %ebp, %rax
movq %rbx, %rcx
subq %rax, %rcx
jbe 0x406d
movslq 0xc(%r15), %rdi
movl $0xff00, %eax           # imm = 0xFF00
subq %rdi, %rax
cmpq %rax, %rcx
cmoval %eax, %ecx
addq 0x18(%r15), %rdi
movslq %ecx, %r12
movq %r14, %rsi
movq %r12, %rdx
callq 0x21b0
movl 0xc(%r15), %eax
addl %r12d, %eax
movl %eax, 0xc(%r15)
addq %r12, %r14
addl %r12d, %ebp
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x4017
movq %r15, %rdi
callq 0x3e73
testl %eax, %eax
je 0x4017
movslq %ebp, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x151d(%rip), %rdi      # 0x559a
leaq 0x1481(%rip), %rsi      # 0x5505
leaq 0x151c(%rip), %rcx      # 0x55a7
movl $0x239, %edx            # imm = 0x239
callq 0x2150
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/tests/msleep/main.c
// Function: main
int
main(int argc, char * argv[])
{
	int msec;
	struct timespec ts;

	WARNP_INIT;

	/* Parse command line. */
	if (argc != 2) {
		fprintf(stderr, "usage: %s milliseconds\n", argv[0]);
		goto err0;
	}
	if (PARSENUM(&msec, argv[1], 0, INT_MAX)) {
		warnp("PARSNEUM");
		goto err0;
	}

	/* Sleep for the desired time. */
	ts.tv_sec = msec / 1000;
	ts.tv_nsec = (msec % 1000) * 1000000;
	if (nanosleep(&ts, NULL)) {
		warnp("nanosleep");
		goto err0;
	}

	/* Success! */
	exit(0);

err0:
	/* Failure! */
	exit(1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x1277
callq 0x1364
cmpl $0x2, %ebx
je 0x129f
movq 0x2d75(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0xd74(%rip), %rsi       # 0x2004
xorl %eax, %eax
callq 0x10e0
pushq $0x1
popq %rdi
callq 0x1120
callq 0x1070
andl $0x0, (%rax)
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x12cf
leaq 0xd78(%rip), %rdi       # 0x202f
leaq 0xd7b(%rip), %rsi       # 0x2039
leaq 0xd96(%rip), %rcx       # 0x205b
movl $0xa7, %edx
callq 0x10a0
movq %rax, %rbx
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1040
movq (%r15), %rdx
pushq $0x16
popq %rcx
cmpq %r14, %rdx
je 0x12fe
cmpb $0x0, (%rdx)
jne 0x12fe
movq %rax, %rcx
shrq $0x1f, %rcx
je 0x1313
pushq $0x22
popq %rcx
movl %ecx, (%rbx)
leaq 0xd15(%rip), %rdi       # 0x201c
xorl %eax, %eax
callq 0x13e1
andl $0x0, (%rbx)
jmp 0x1297
cmpl $0x0, (%rbx)
jne 0x1300
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movq %rsp, %rdi
movq %rax, (%rdi)
imull $0xf4240, %edx, %eax    # imm = 0xF4240
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x1090
testl %eax, %eax
jne 0x1343
xorl %edi, %edi
callq 0x1120
cmpl $0x0, (%rbx)
jne 0x135b
leaq 0xcd6(%rip), %rdi       # 0x2025
xorl %eax, %eax
callq 0x1570
jmp 0x1297
leaq 0xcc3(%rip), %rdi       # 0x2025
jmp 0x1307
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rsi
movl %r15d, %edi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2090
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %r15d, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x2090
cmpl $-0x1, %eax
je 0x2c26
leaq 0xc(%rsp), %rcx
movq %r14, 0x4(%rcx)
orl $0x80000000, %ebp       # imm = 0x80000000
movl %ebp, (%rcx)
movl 0x4(%r14), %edx
pushq $0x1
popq %rsi
movl %ebx, %edi
callq 0x2130
cmpl $-0x1, %eax
je 0x2c5b
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a3c3(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x11433(%rip), %rsi     # 0x1406a
leaq 0x113f4(%rip), %rdx     # 0x14032
leaq 0x1146a(%rip), %r8      # 0x140af
movl $0x8b, %ecx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2170
movq 0x1a38e(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x113fe(%rip), %rsi     # 0x1406a
leaq 0x113bf(%rip), %rdx     # 0x14032
leaq 0x11446(%rip), %r8      # 0x140c0
movl $0x91, %ecx
xorl %eax, %eax
callq 0x2170
jmp 0x2c1b
// File: /workspace/github_c_makefile_star2_O2/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
movl %esi, %eax
leaq 0xc(%rsp), %rcx
movq %rdi, 0x4(%rcx)
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rcx)
movl 0x4(%rdi), %edx
pushq $0x3
popq %rsi
movl %eax, %edi
callq 0x2130
cmpl $-0x1, %eax
je 0x2cb6
addq $0x18, %rsp
retq
movq 0x1a333(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x113a3(%rip), %rsi     # 0x1406a
leaq 0x11364(%rip), %rdx     # 0x14032
leaq 0x113eb(%rip), %r8      # 0x140c0
movl $0x9d, %ecx
xorl %eax, %eax
callq 0x2170
jmp 0x2cb1
// File: /workspace/github_c_makefile_star2_O2/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 0x1a491(%rip), %rbx     # 0x1d180
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x54e3
movl 0x1a475(%rip), %edi     # 0x1d174
movzwl %ax, %edx
movq %rbx, %rsi
callq 0x20a0
cmpl $-0x1, %eax
je 0x2d11
popq %rbx
retq
movq 0x1a2d8(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x11348(%rip), %rsi     # 0x1406a
leaq 0x11309(%rip), %rdx     # 0x14032
leaq 0x1139c(%rip), %r8      # 0x140cc
pushq $0x7c
popq %rcx
xorl %eax, %eax
popq %rbx
jmp 0x2170
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x2d49
popq %rcx
retq
movq 0x1a2a0(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x11381(%rip), %rsi     # 0x140db
leaq 0x11391(%rip), %rdx     # 0x140f2
pushq $0x6
popq %rcx
xorl %eax, %eax
callq 0x2170
pushq $0x1
popq %rdi
callq 0x2200
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x19fa8(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x11018(%rip), %rsi     # 0x1406a
leaq 0x11c5a(%rip), %rdx     # 0x14cb3
leaq 0x1116c(%rip), %r8      # 0x141cc
movl $0xac, %ecx
xorl %eax, %eax
callq 0x2170
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x8161
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x81ed
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x816b
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x81ac
movq 0x8(%rbx), %rdi
callq 0x6c1b
movl 0x4(%rbx), %edi
callq 0x2120
movq %rbx, %rdi
popq %rbx
jmp 0x357c
// File: /workspace/github_c_makefile_star2_O2/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 0x19f2e(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x10f9e(%rip), %rsi     # 0x1406a
leaq 0x11be0(%rip), %rdx     # 0x14cb3
leaq 0x110c2(%rip), %r8      # 0x1419c
movl $0x86, %ecx
xorl %eax, %eax
callq 0x2170
leaq 0x110bd(%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 0x357c
// File: /workspace/github_c_makefile_star2_O2/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 0x19ecc(%rip), %r15     # 0x1cff0
movq (%r15), %rdi
leaq 0x10f3c(%rip), %rsi     # 0x1406a
leaq 0x11b7e(%rip), %rdx     # 0x14cb3
leaq 0x1101d(%rip), %r8      # 0x14159
pushq $0x55
popq %rcx
xorl %eax, %eax
callq 0x2170
testb %bpl, %bpl
jne 0x322c
testq %r14, %r14
je 0x31a6
movzwl 0x10(%r14), %eax
movslq 0x28(%rbx), %rsi
leal (%rsi,%rax), %ecx
cmpl $0x10000, %ecx          # imm = 0x10000
jge 0x31d9
addq 0x18(%rbx), %rsi
movzwl %ax, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x54e3
cmpw 0x10(%r14), %ax
jne 0x31f5
movzwl %ax, %eax
addl %eax, 0x28(%rbx)
movq %r14, %rdi
callq 0x4e16
movl 0x14(%rbx), %eax
decl %eax
cmpl $0x1, %eax
ja 0x321f
movq %rbx, %rdi
callq 0x3452
jmp 0x321f
movq (%r15), %rdi
leaq 0x10eba(%rip), %rsi     # 0x1406a
leaq 0x11afc(%rip), %rdx     # 0x14cb3
leaq 0x10fa8(%rip), %r8      # 0x14166
pushq $0x60
popq %rcx
xorl %eax, %eax
callq 0x2170
movl 0x14(%rbx), %eax
cmpl $0x2, %eax
je 0x3217
movl $0x2, 0x10(%rbx)
jmp 0x3191
movq (%r15), %rdi
leaq 0x10e87(%rip), %rsi     # 0x1406a
leaq 0x11ac9(%rip), %rdx     # 0x14cb3
leaq 0x10f83(%rip), %r8      # 0x14174
pushq $0x6c
jmp 0x320f
movq (%r15), %rdi
leaq 0x10e6b(%rip), %rsi     # 0x1406a
leaq 0x11aad(%rip), %rdx     # 0x14cb3
leaq 0x10f7b(%rip), %r8      # 0x14188
pushq $0x74
popq %rcx
xorl %eax, %eax
callq 0x2170
movq %rbx, %rdi
callq 0x303d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rbx
callq 0x2060
movl (%rax), %edi
callq 0x2220
leaq 0x10dc2(%rip), %rsi     # 0x14004
leaq 0x11a6a(%rip), %rdx     # 0x14cb3
pushq $0x57
popq %rcx
movq %rbx, %rdi
movq %rax, %r8
xorl %eax, %eax
callq 0x2170
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/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 0x19d48(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x10db8(%rip), %rsi     # 0x1406a
leaq 0x119fa(%rip), %rdx     # 0x14cb3
leaq 0x10e88(%rip), %r8      # 0x14148
movl $0x97, %ecx
xorl %eax, %eax
callq 0x2170
cmpl $0x0, 0x14(%rbx)
jne 0x32d9
movl $0x1, 0x14(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
testb $0x1, %bpl
jne 0x32ed
popq %rbx
popq %rbp
jmp 0x3452
popq %rbx
popq %rbp
jmp 0x32f1
// File: /workspace/github_c_makefile_star2_O2/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 0x19cf0(%rip), %r15     # 0x1cff0
movq (%r15), %rdi
leaq 0x10d60(%rip), %rsi     # 0x1406a
leaq 0x119a2(%rip), %rdx     # 0x14cb3
leaq 0x10eec(%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 0x337d
cmpl $-0x1, %r14d
jne 0x3390
callq 0x2060
cmpl $0xb, (%rax)
je 0x33e0
movq (%r15), %rdi
leaq 0x10d05(%rip), %rsi     # 0x1406a
leaq 0x11947(%rip), %rdx     # 0x14cb3
leaq 0x10e9f(%rip), %r8      # 0x14212
movl $0xe0, %ecx
jmp 0x3446
cmpl $0x2, 0x10(%rbx)
jne 0x33d9
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x303d
testl %r14d, %r14d
jle 0x33e0
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 0xa5c4
cmpb $-0x1, %al
je 0x33e0
movzbl %al, %eax
testl %eax, %eax
jne 0x3429
subl %r14d, 0x2c(%rbx)
movq 0x8(%rbx), %rdi
callq 0xb804
jmp 0x33e0
movl $0x2, 0x14(%rbx)
cmpl $0x0, 0x2c(%rbx)
jne 0x33ec
cmpl $0x2, 0x14(%rbx)
je 0x33f2
popq %rbx
popq %r14
popq %r15
retq
movq (%r15), %rdi
leaq 0x10c6e(%rip), %rsi     # 0x1406a
leaq 0x118b0(%rip), %rdx     # 0x14cb3
leaq 0x10e1b(%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 0x6e5a
movq (%r15), %rdi
leaq 0x10c37(%rip), %rsi     # 0x1406a
leaq 0x11879(%rip), %rdx     # 0x14cb3
leaq 0x10dd8(%rip), %r8      # 0x14219
movl $0xf7, %ecx
xorl %eax, %eax
callq 0x2170
jmp 0x3383
// File: /workspace/github_c_makefile_star2_O2/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 0x19b8d(%rip), %r15     # 0x1cff0
movq (%r15), %rdi
leaq 0x10bfd(%rip), %rsi     # 0x1406a
leaq 0x1183f(%rip), %rdx     # 0x14cb3
leaq 0x10d5f(%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 0x34d7
testl %r14d, %r14d
jle 0x34e1
movq 0x8(%rbx), %rdi
movzwl %r14w, %esi
callq 0x7777
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 0x34e1
callq 0x2060
cmpl $0xb, (%rax)
jne 0x34f8
cmpl $0x0, 0x28(%rbx)
jne 0x34ed
cmpl $0x2, 0x10(%rbx)
je 0x352e
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rdi
leaq 0x10b68(%rip), %rsi     # 0x1406a
leaq 0x117aa(%rip), %rdx     # 0x14cb3
leaq 0x10d0d(%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 0x303d
movq (%r15), %rdi
leaq 0x10b32(%rip), %rsi     # 0x1406a
leaq 0x11774(%rip), %rdx     # 0x14cb3
leaq 0x10ca2(%rip), %r8      # 0x141e8
movl $0xcd, %ecx
xorl %eax, %eax
callq 0x2170
leaq 0x19c17(%rip), %rax     # 0x1d170
movl (%rax), %esi
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x2c88
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_O2/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 0x19a69(%rip), %rax     # 0x1cff0
movq (%rax), %rdi
leaq 0x10ad9(%rip), %rsi     # 0x1406a
leaq 0x1171b(%rip), %rdx     # 0x14cb3
leaq 0x10c13(%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
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x19726(%rip), %r14     # 0x1cff0
movq (%r14), %rdi
leaq 0x10796(%rip), %rsi     # 0x1406a
leaq 0x126b9(%rip), %rdx     # 0x15f94
leaq 0x10993(%rip), %r8      # 0x14275
pushq $0x4f
popq %rcx
xorl %eax, %eax
callq 0x2170
movzwl 0x30(%rbx), %esi
movzwl 0x32(%rbx), %edx
leaq 0x1094d(%rip), %rdi     # 0x14248
xorl %eax, %eax
callq 0x20d0
movq 0x19e5f(%rip), %rsi     # 0x1d768
testq %rsi, %rsi
jne 0x3922
movl $0x5dc, %edi            # imm = 0x5DC
callq 0x2d3c
movq %rax, %rsi
movq %rax, 0x19e46(%rip)     # 0x1d768
movl 0x4(%rbx), %edi
movl $0x5dc, %edx            # imm = 0x5DC
callq 0x2140
testl %eax, %eax
jle 0x39ce
cmpl $0x5dc, %eax            # imm = 0x5DC
je 0x39ce
movl (%rbx), %ecx
cmpl $0x5, %ecx
je 0x3967
cmpl $0x4, %ecx
jne 0x3982
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 0x3982
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 0x19ddf(%rip), %rdi     # 0x1d768
movzwl %ax, %esi
pushq $0x1
popq %rdx
callq 0x4da5
testq %rax, %rax
je 0x39ea
movq 0x8(%rbx), %rdi
movzwl 0x30(%rbx), %ecx
movzwl 0x32(%rbx), %r9d
leaq 0x20(%rsp), %rdx
movq %rsp, %r8
movq %rax, %rsi
callq 0xcc12
movl 0x4(%rbx), %edi
callq 0x2120
movq %rbx, %rdi
callq 0x2030
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq (%r14), %rdi
leaq 0x10692(%rip), %rsi     # 0x1406a
leaq 0x125b5(%rip), %rdx     # 0x15f94
leaq 0x108a0(%rip), %r8      # 0x14286
pushq $0x5e
jmp 0x3a04
movq (%r14), %rdi
leaq 0x10676(%rip), %rsi     # 0x1406a
leaq 0x12599(%rip), %rdx     # 0x15f94
leaq 0x1089a(%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_O2/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 0x3b9f
testq %rsi, %rsi
je 0x3b9e
movq %rsi, %rdi
jmp 0x3ace
retq
pushq %rax
leaq 0x10725(%rip), %rdi     # 0x142cc
leaq 0x107e1(%rip), %rsi     # 0x1438f
leaq 0x107ec(%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_O2/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 0x3fc3
testq %rsi, %rsi
je 0x3fdf
popq %rax
jmp 0x3aa7
leaq 0x10302(%rip), %rdi     # 0x142cc
leaq 0x1044f(%rip), %rsi     # 0x14420
leaq 0x10462(%rip), %rcx     # 0x1443a
movl $0xdd, %edx
jmp 0x3ff9
leaq 0x102e6(%rip), %rdi     # 0x142cc
leaq 0x10469(%rip), %rsi     # 0x14456
leaq 0x10446(%rip), %rcx     # 0x1443a
movl $0xde, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/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 0x4191
testq %rdx, %rdx
je 0x41ad
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
cmpl 0x8(%rdi), %eax
je 0x4189
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 0x415e
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 0x4169
andl $0x0, 0xc(%rdx)
andq $0x0, 0x4(%rdx)
xorl %eax, %eax
movb %al, 0x10(%rdx)
movq %rsp, %rsi
movq %rdx, %rdi
callq 0x4318
movl (%r14), %eax
movl %eax, 0x8(%rbx)
movb $0x0, 0x1c(%rbx)
movq %rbx, %rdi
callq 0x4397
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x10134(%rip), %rdi     # 0x142cc
leaq 0x10657(%rip), %rsi     # 0x147f6
leaq 0x10294(%rip), %rcx     # 0x1443a
movl $0x1cb, %edx            # imm = 0x1CB
jmp 0x41c7
leaq 0x10118(%rip), %rdi     # 0x142cc
leaq 0x1063b(%rip), %rsi     # 0x147f6
leaq 0x10278(%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_O2/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 0x43e3
movb 0xeb(%rdi), %al
testb $0x4, %al
je 0x43e2
andb $-0x5, %al
movb %al, 0xeb(%rdi)
retq
pushq %rax
leaq 0xfee1(%rip), %rdi      # 0x142cc
leaq 0x101b4(%rip), %rsi     # 0x145a6
leaq 0x10041(%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_O2/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 0x463d
testq %rdx, %rdx
je 0x4659
movl (%rdx), %eax
movl 0x4(%rdx), %ecx
movl 0x8(%rdx), %r8d
movl 0xc(%rdx), %r9d
movsbl %sil, %esi
movl %eax, %edx
popq %rax
jmp 0x4686
leaq 0xfc88(%rip), %rdi      # 0x142cc
leaq 0x1005a(%rip), %rsi     # 0x146a5
leaq 0xfde8(%rip), %rcx      # 0x1443a
movl $0x526, %edx            # imm = 0x526
jmp 0x4673
leaq 0xfc6c(%rip), %rdi      # 0x142cc
leaq 0x10060(%rip), %rsi     # 0x146c7
leaq 0xfdcc(%rip), %rcx      # 0x1443a
movl $0x527, %edx            # imm = 0x527
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_get_ip6_addr_match
s8_t
netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr)
{
  s8_t i;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_get_ip6_addr_match: invalid netif", netif != NULL);
  LWIP_ASSERT("netif_get_ip6_addr_match: invalid ip6addr", ip6addr != NULL);

#if LWIP_IPV6_SCOPES
  if (ip6_addr_has_zone(ip6addr) && !ip6_addr_test_zone(ip6addr, netif)) {
    return -1; /* wrong zone, no match */
  }
#endif /* LWIP_IPV6_SCOPES */

  for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
    if (!ip6_addr_isinvalid(netif_ip6_addr_state(netif, i)) &&
        ip6_addr_cmp_zoneless(netif_ip6_addr(netif, i), ip6addr)) {
      return i;
    }
  }
  return -1;
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x489e
testq %rsi, %rsi
je 0x48ba
movb 0x10(%rsi), %cl
testb %cl, %cl
je 0x485d
movb 0xee(%rdi), %dl
incb %dl
movb $-0x1, %al
cmpb %dl, %cl
jne 0x489c
leaq 0x5c(%rdi), %rcx
xorl %eax, %eax
cmpq $0x3, %rax
je 0x489a
cmpb $0x0, 0x98(%rdi,%rax)
je 0x4891
movl -0xc(%rcx), %edx
cmpl (%rsi), %edx
jne 0x4891
movl -0x8(%rcx), %edx
cmpl 0x4(%rsi), %edx
jne 0x4891
movl -0x4(%rcx), %edx
cmpl 0x8(%rsi), %edx
jne 0x4891
movl (%rcx), %edx
cmpl 0xc(%rsi), %edx
je 0x489c
incq %rax
addq $0x18, %rcx
jmp 0x4863
movb $-0x1, %al
popq %rcx
retq
leaq 0xfa27(%rip), %rdi      # 0x142cc
leaq 0xfe59(%rip), %rsi      # 0x14705
leaq 0xfb87(%rip), %rcx      # 0x1443a
movl $0x5be, %edx            # imm = 0x5BE
jmp 0x48d4
leaq 0xfa0b(%rip), %rdi      # 0x142cc
leaq 0xfe65(%rip), %rsi      # 0x1472d
leaq 0xfb6b(%rip), %rcx      # 0x1443a
movl $0x5bf, %edx            # imm = 0x5BF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_add_ip6_address
err_t
netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
{
  s8_t i;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_add_ip6_address: invalid netif", netif != NULL);
  LWIP_ASSERT("netif_add_ip6_address: invalid ip6addr", ip6addr != NULL);

  i = netif_get_ip6_addr_match(netif, ip6addr);
  if (i >= 0) {
    /* Address already added */
    if (chosen_idx != NULL) {
      *chosen_idx = i;
    }
    return ERR_OK;
  }

  /* Find a free slot. The first one is reserved for link-local addresses. */
  for (i = ip6_addr_islinklocal(ip6addr) ? 0 : 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
    if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
      ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
      ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
      netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
      if (chosen_idx != NULL) {
        *chosen_idx = i;
      }
      return ERR_OK;
    }
  }

  if (chosen_idx != NULL) {
    *chosen_idx = -1;
  }
  return ERR_VAL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x4b00
movq %rsi, %r12
testq %rsi, %rsi
je 0x4b1c
movq %rdx, %rbx
movq %rdi, %r15
movq %r12, %rsi
callq 0x483d
testb %al, %al
js 0x4a60
movl %eax, %r14d
jmp 0x4aea
movl (%r12), %edx
movl %edx, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
xorl %r14d, %r14d
cmpl $0x80fe, %ecx           # imm = 0x80FE
setne %r14b
imulq $0x18, %r14, %rax
addq %r15, %rax
addq $0x64, %rax
cmpq $0x3, %r14
je 0x4a9e
cmpb $0x0, 0x98(%r15,%r14)
je 0x4aa5
incq %r14
addq $0x18, %rax
jmp 0x4a84
movb $-0x1, %r14b
movb $-0x6, %al
jmp 0x4aec
movl %edx, -0x14(%rax)
movl 0x4(%r12), %edx
movl %edx, -0x10(%rax)
movl 0x8(%r12), %edx
movl %edx, -0xc(%rax)
movl 0xc(%r12), %edx
movl %edx, -0x8(%rax)
movb $0x6, (%rax)
cmpl $0x80fe, %ecx           # imm = 0x80FE
jne 0x4ad6
movb 0xee(%r15), %cl
incb %cl
jmp 0x4ad8
xorl %ecx, %ecx
movb %cl, -0x4(%rax)
movsbl %r14b, %esi
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x479d
xorl %eax, %eax
testq %rbx, %rbx
je 0x4af4
movb %r14b, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xf7c5(%rip), %rdi      # 0x142cc
leaq 0xfc7b(%rip), %rsi      # 0x14789
leaq 0xf925(%rip), %rcx      # 0x1443a
movl $0x623, %edx            # imm = 0x623
jmp 0x4b36
leaq 0xf7a9(%rip), %rdi      # 0x142cc
leaq 0xfc84(%rip), %rsi      # 0x147ae
leaq 0xf909(%rip), %rcx      # 0x1443a
movl $0x624, %edx            # imm = 0x624
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_find
struct netif *
netif_find(const char *name)
{
  struct netif *netif;
  u8_t num;

  LWIP_ASSERT_CORE_LOCKED();

  if (name == NULL) {
    return NULL;
  }

  num = (u8_t)atoi(&name[2]);

  NETIF_FOREACH(netif) {
    if (num == netif->num &&
        name[0] == netif->name[0] &&
        name[1] == netif->name[1]) {
      LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
      return netif;
    }
  }
  LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
  return NULL;
}

// Assembly:
testq %rdi, %rdi
je 0x4ba8
pushq %rbx
movq %rdi, %rbx
addq $0x2, %rdi
callq 0x21f0
movl %eax, %ecx
leaq 0x18d5b(%rip), %rax     # 0x1d8d8
movq (%rax), %rax
testq %rax, %rax
je 0x4ba4
cmpb %cl, 0xee(%rax)
jne 0x4b7d
movb (%rbx), %dl
cmpb 0xec(%rax), %dl
jne 0x4b7d
movb 0x1(%rbx), %dl
cmpb 0xed(%rax), %dl
jne 0x4b7d
jmp 0x4ba6
xorl %eax, %eax
popq %rbx
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_index_to_name
char *
netif_index_to_name(u8_t idx, char *name)
{
  struct netif *netif = netif_get_by_index(idx);

  if (netif != NULL) {
    name[0] = netif->name[0];
    name[1] = netif->name[1];
    lwip_itoa(&name[2], NETIF_NAMESIZE - 2, netif_index_to_num(idx));
    return name;
  }
  return NULL;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
callq 0x4bee
testq %rax, %rax
je 0x4be2
movb 0xec(%rax), %cl
movb %cl, (%rbx)
movb 0xed(%rax), %al
movb %al, 0x1(%rbx)
leaq 0x2(%rbx), %rdi
movzbl %bpl, %edx
decl %edx
pushq $0x4
popq %rsi
callq 0x12fb5
jmp 0x4be4
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq