// File: /workspace/github_c_makefile_star2_O0/mabdi[P]bunney/bunny-flow.c
// Function: commit_tcp_accept
static void commit_tcp_accept(_u16 port) {
  _s32 csock, i;
  struct sockaddr_in sin;
  fd_set fds;
  
  /* The idea here is that as long as FLOW_TCP_ACCEPT is called for 
     the same port, we shouldn't dispose of the listener socket,
     as to minimize the risk of refused connections. */
  
  if (lport != port) {
    if (lport) close(lsock);
  
    lsock = socket(AF_INET, SOCK_STREAM, 0); 
    if (lsock < 0) pfatal("socket() failed");
  
    sin.sin_family      = AF_INET;
    sin.sin_addr.s_addr = INADDR_ANY;
    sin.sin_port        = port;
    
    if (bind(lsock, (struct sockaddr*)&sin, sizeof(sin)))
      pfatal("bind() failed");
      
    if (listen(lsock, 10)) pfatal("listen() failed");
    
    lport = port;
    
  }
  
  /* This shouldn't happen, but if the user configures some overly 
     aggressive timeouts, the traced process may get killed before
     it connects to read its input. To avoid a deadlock, we need to 
     bail out of an accept() wait if new control commands are available. */
  
  FD_ZERO(&fds);
  FD_SET(0,&fds);
  FD_SET(lsock,&fds);
  
  if (select(lsock + 1, &fds, 0, &fds, 0) < 0) 
    pfatal("select failed");

  if (FD_ISSET(0,&fds)) {
    debug("NOTE: accept() aborted by control command (something went wrong!)\n");
    return;
  }

  csock = accept(lsock, (struct sockaddr*)&sin, &i);
  if (csock < 0) pfatal("accept() failed");
  
  commit_data_fd(csock);
  close(csock);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movw %di, %ax
movw %ax, -0x2(%rbp)
movzwl 0x4b7f(%rip), %eax      # 0x81a8
movzwl -0x2(%rbp), %ecx
cmpl %ecx, %eax
je 0x37cc
cmpw $0x0, 0x4b6b(%rip)      # 0x81a8
je 0x364a
movl 0x4b67(%rip), %edi      # 0x81ac
callq 0x12a0
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1050
movl %eax, 0x4b4b(%rip)      # 0x81ac
cmpl $0x0, 0x4b44(%rip)      # 0x81ac
jge 0x36c6
jmp 0x366c
movq 0x396d(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x2081(%rip), %rsi      # 0x56fe
movb $0x0, %al
callq 0x11b0
movq 0x3955(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x19a7(%rip), %rsi      # 0x503c
leaq 0x2141(%rip), %rdx      # 0x57dd
leaq 0x19ae(%rip), %rcx      # 0x5051
movl $0x27c, %r8d            # imm = 0x27C
movb $0x0, %al
callq 0x11b0
leaq 0x1a65(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movw $0x2, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movw -0x2(%rbp), %ax
movw %ax, -0x1a(%rbp)
movl 0x4acb(%rip), %edi      # 0x81ac
leaq -0x1c(%rbp), %rsi
movl $0x10, %edx
callq 0x1040
cmpl $0x0, %eax
je 0x3750
jmp 0x36f6
movq 0x38e3(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x20e8(%rip), %rsi      # 0x57ef
movb $0x0, %al
callq 0x11b0
movq 0x38cb(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x191d(%rip), %rsi      # 0x503c
leaq 0x20b7(%rip), %rdx      # 0x57dd
leaq 0x1924(%rip), %rcx      # 0x5051
movl $0x283, %r8d            # imm = 0x283
movb $0x0, %al
callq 0x11b0
leaq 0x19db(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movl 0x4a56(%rip), %edi      # 0x81ac
movl $0xa, %esi
callq 0x1140
cmpl $0x0, %eax
je 0x37c1
jmp 0x3767
movq 0x3872(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x209b(%rip), %rsi      # 0x5813
movb $0x0, %al
callq 0x11b0
movq 0x385a(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x18ac(%rip), %rsi      # 0x503c
leaq 0x2046(%rip), %rdx      # 0x57dd
leaq 0x18b3(%rip), %rcx      # 0x5051
movl $0x285, %r8d            # imm = 0x285
movb $0x0, %al
callq 0x11b0
leaq 0x196a(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movw -0x2(%rbp), %ax
movw %ax, 0x49dc(%rip)       # 0x81a8
jmp 0x37ce
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpq $0x10, %rax
jae 0x3818
movq -0xb0(%rbp), %rax
movl -0xa4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x37e6
jmp 0x381a
movq -0xa0(%rbp), %rax
orq $0x1, %rax
movq %rax, -0xa0(%rbp)
movl 0x497a(%rip), %eax      # 0x81ac
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl 0x495d(%rip), %eax      # 0x81ac
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0xa0(%rbp,%rax,8), %rcx
movq %rcx, -0xa0(%rbp,%rax,8)
movl 0x493d(%rip), %edi      # 0x81ac
addl $0x1, %edi
leaq -0xa0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
movq %rcx, %rsi
movq %r8, %rdx
callq 0x1120
cmpl $0x0, %eax
jge 0x38ea
jmp 0x3890
movq 0x3749(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1e92(%rip), %rsi      # 0x5733
movb $0x0, %al
callq 0x11b0
movq 0x3731(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1783(%rip), %rsi      # 0x503c
leaq 0x1f1d(%rip), %rdx      # 0x57dd
leaq 0x178a(%rip), %rcx      # 0x5051
movl $0x295, %r8d            # imm = 0x295
movb $0x0, %al
callq 0x11b0
leaq 0x1841(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movq -0xa0(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x3918
movq 0x36de(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1f2d(%rip), %rsi      # 0x5839
movb $0x0, %al
callq 0x11b0
jmp 0x39a0
movl 0x488e(%rip), %edi      # 0x81ac
leaq -0x1c(%rbp), %rsi
leaq -0xc(%rbp), %rdx
callq 0x1070
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jge 0x3990
jmp 0x3936
movq 0x36a3(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1f35(%rip), %rsi      # 0x587c
movb $0x0, %al
callq 0x11b0
movq 0x368b(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x16dd(%rip), %rsi      # 0x503c
leaq 0x1e77(%rip), %rdx      # 0x57dd
leaq 0x16e4(%rip), %rcx      # 0x5051
movl $0x29d, %r8d            # imm = 0x29D
movb $0x0, %al
callq 0x11b0
leaq 0x179b(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movl -0x8(%rbp), %edi
callq 0x4370
movl -0x8(%rbp), %edi
callq 0x12a0
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)