// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/quectel-mbim-proxy.c
// Function: handle_client_connect
static int handle_client_connect(int server_fd)
{
    int i, client_fd;
    struct sockaddr_in cli_addr;
    socklen_t len = sizeof(cli_addr);

    client_fd = accept(server_fd, (struct sockaddr *)&cli_addr, &len);
    if (client_fd < 0) {
        mbim_debug("proxy accept failed: %s\n", strerror(errno));
        return -1;
    }

    if (fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL) | O_NONBLOCK) < 0)
        mbim_debug("fcntl set client(%d) NONBLOCK attribute failed: %s\n", client_fd, strerror(errno));

    for (i = 0; i < CM_MAX_CLIENT; i++) {
        if (cm_clients[i].client_fd <= 0) {
            cm_clients[i].client_fd = client_fd;
            cm_clients[i].client_idx= i+1;
            mbim_debug("%s client_fd=%d, client_idx=%d\n", __func__, cm_clients[i].client_fd, cm_clients[i].client_idx);
            return 0;
        }
    }

    close(client_fd);
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movl $0x10, -0x24(%rbp)
movl -0x8(%rbp), %edi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x1150
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jge 0x1ef5
jmp 0x1ead
movq 0x311c(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x12a0
movq %rax, -0x30(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1170
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq %rax, %rcx
leaq 0x138f(%rip), %rsi      # 0x3271
movb $0x0, %al
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x202d
movl -0x10(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x10(%rbp), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x1060
movl -0x3c(%rbp), %edi
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl $0x4, %esi
movb $0x0, %al
callq 0x1060
cmpl $0x0, %eax
jge 0x1f6f
jmp 0x1f28
movq 0x30a1(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x12a0
movq %rax, -0x48(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1170
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl -0x40(%rbp), %ecx
movq %rax, %r8
leaq 0x1327(%rip), %rsi      # 0x328d
movb $0x0, %al
callq 0x10f0
jmp 0x1f6f
movl $0x0, -0xc(%rbp)
cmpl $0x20, -0xc(%rbp)
jge 0x201e
movslq -0xc(%rbp), %rcx
leaq 0x31f5(%rip), %rax      # 0x5180
cmpl $0x0, (%rax,%rcx,8)
jg 0x200e
movl -0x10(%rbp), %edx
movslq -0xc(%rbp), %rcx
leaq 0x31e1(%rip), %rax      # 0x5180
movl %edx, (%rax,%rcx,8)
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq -0xc(%rbp), %rcx
leaq 0x31cd(%rip), %rax      # 0x5180
movl %edx, 0x4(%rax,%rcx,8)
movq 0x3012(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x12a0
movq -0x58(%rbp), %rdi
movq %rax, %rdx
movslq -0xc(%rbp), %rcx
leaq 0x31a4(%rip), %rax      # 0x5180
movl (%rax,%rcx,8), %r8d
movslq -0xc(%rbp), %rcx
leaq 0x3195(%rip), %rax      # 0x5180
movl 0x4(%rax,%rcx,8), %r9d
leaq 0x123e(%rip), %rsi      # 0x3235
leaq 0x12c6(%rip), %rcx      # 0x32c4
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x4(%rbp)
jmp 0x202d
jmp 0x2010
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1f76
movl -0x10(%rbp), %edi
callq 0x10d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)