// File: /workspace/github_c_makefile_star2_O0/mabdi[P]bunney/bunny-flow.c
// Function: commit_connect
static void commit_connect(_u32 daddr,_u16 dport,_u8 udp) {
  _s32 csock;
  struct sockaddr_in sin;
  
  if (lport) { close(lsock); lport = 0; }
  
  csock = socket(AF_INET, udp ? SOCK_DGRAM : SOCK_STREAM, 0); 
  if (csock < 0) pfatal("socket() failed");
  
  sin.sin_family      = AF_INET;
  sin.sin_port        = dport;
  sin.sin_addr.s_addr = daddr;
  
try_connect_again:
  
  if (connect(csock, (struct sockaddr*)&sin, sizeof(sin))) {
  
    if (errno == ECONNREFUSED) {
      fd_set fds;
      FD_ZERO(&fds);
      FD_SET(0,&fds);

      if (select(1, &fds, 0, &fds, 0) < 0) 
        pfatal("select failed");

      if (FD_ISSET(0,&fds)) {
        debug("NOTE: connect() loop aborted by control command (something went wrong!)\n");
	close(csock);
        return;
      } else {
        sched_yield();
        goto try_connect_again;
      }

    }

    close(csock);
    debug("WARNING: Unable to initialize network connection to target.\n");
    return;
    
  }
  
  commit_data_fd(csock);
  
  close(csock);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movb %dl, %al
movw %si, %cx
movl %edi, -0x4(%rbp)
movw %cx, -0x6(%rbp)
movb %al, -0x7(%rbp)
cmpw $0x0, 0x4dc6(%rip)      # 0x81a8
je 0x33f8
movl 0x4dc2(%rip), %edi      # 0x81ac
callq 0x12a0
movw $0x0, 0x4db0(%rip)      # 0x81a8
movzbl -0x7(%rbp), %ecx
movl $0x1, %esi
movl $0x2, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl $0x2, %edi
xorl %edx, %edx
callq 0x1050
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0x347d
jmp 0x3423
movq 0x3bb6(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x22ca(%rip), %rsi      # 0x56fe
movb $0x0, %al
callq 0x11b0
movq 0x3b9e(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1bf0(%rip), %rsi      # 0x503c
leaq 0x22d1(%rip), %rdx      # 0x5724
leaq 0x1bf7(%rip), %rcx      # 0x5051
movl $0x244, %r8d            # imm = 0x244
movb $0x0, %al
callq 0x11b0
leaq 0x1cae(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movw $0x2, -0x1c(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x1a(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0xc(%rbp), %edi
leaq -0x1c(%rbp), %rsi
movl $0x10, %edx
callq 0x10f0
cmpl $0x0, %eax
je 0x35f5
callq 0x1030
cmpl $0x6f, (%rax)
jne 0x35d3
jmp 0x34bb
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpq $0x10, %rax
jae 0x3505
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 0x34d3
jmp 0x3507
movq -0xa0(%rbp), %rax
orq $0x1, %rax
movq %rax, -0xa0(%rbp)
movl $0x1, %edi
leaq -0xa0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
movq %rcx, %rsi
movq %r8, %rdx
callq 0x1120
cmpl $0x0, %eax
jge 0x3596
jmp 0x353c
movq 0x3a9d(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x21e6(%rip), %rsi      # 0x5733
movb $0x0, %al
callq 0x11b0
movq 0x3a85(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x1ad7(%rip), %rsi      # 0x503c
leaq 0x21b8(%rip), %rdx      # 0x5724
leaq 0x1ade(%rip), %rcx      # 0x5051
movl $0x254, %r8d            # imm = 0x254
movb $0x0, %al
callq 0x11b0
leaq 0x1b95(%rip), %rdi      # 0x511c
callq 0x1100
movl $0x1, %edi
callq 0x1180
movq -0xa0(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x35c9
movq 0x3a32(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x219f(%rip), %rsi      # 0x5757
movb $0x0, %al
callq 0x11b0
movl -0xc(%rbp), %edi
callq 0x12a0
jmp 0x3605
callq 0x11d0
jmp 0x3491
movl -0xc(%rbp), %edi
callq 0x12a0
movq 0x39fe(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
leaq 0x21b4(%rip), %rsi      # 0x57a0
movb $0x0, %al
callq 0x11b0
jmp 0x3605
movl -0xc(%rbp), %edi
callq 0x4370
movl -0xc(%rbp), %edi
callq 0x12a0
addq $0xb0, %rsp
popq %rbp
retq
nop