// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/quectel-mbim-proxy.c
// Function: proxy_make_server
static int proxy_make_server(const char *proxy_name)
{
    int len, flag;
    struct sockaddr_un sockaddr;
    int mbim_server_fd;

    mbim_server_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
    if (mbim_server_fd < 0) {
        mbim_debug("socket failed: %s\n", strerror(errno));
        return -1;
    }
    if (fcntl(mbim_server_fd, F_SETFL, fcntl(mbim_server_fd, F_GETFL) | O_NONBLOCK) < 0)
        mbim_debug("fcntl set server(%d) NONBLOCK attribute failed: %s\n", mbim_server_fd, strerror(errno));

    memset(&sockaddr, 0, sizeof(sockaddr));
    sockaddr.sun_family = AF_LOCAL;
    sockaddr.sun_path[0] = 0;
    snprintf(sockaddr.sun_path, UNIX_PATH_MAX, "0%s", proxy_name);
    sockaddr.sun_path[0] = '\0';  // string starts with leading '\0'
    flag = 1;
    if (setsockopt(mbim_server_fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)) < 0) {
        safe_close(mbim_server_fd);
        mbim_debug("setsockopt failed\n");
    }

    len = strlen(proxy_name) + offsetof(struct sockaddr_un, sun_path) + 1;
    if (bind(mbim_server_fd, (struct sockaddr*)&sockaddr, len) < 0) {
        safe_close(mbim_server_fd);
        mbim_debug("bind failed: %s\n", strerror(errno));
        return -1;
    }

    listen(mbim_server_fd, 4);
    return mbim_server_fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x1190
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
jge 0x20c2
jmp 0x206e
movq 0x2f5b(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
callq 0x12a0
movq %rax, -0x98(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1170
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq %rax, %rcx
leaq 0x122b(%rip), %rsi      # 0x32da
movb $0x0, %al
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x22e4
movl -0x8c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x8c(%rbp), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x1060
movl -0xa4(%rbp), %edi
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl $0x4, %esi
movb $0x0, %al
callq 0x1060
cmpl $0x0, %eax
jge 0x215d
jmp 0x2101
movq 0x2ec8(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
callq 0x12a0
movq %rax, -0xb0(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0xa8(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1170
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
movl -0xa8(%rbp), %ecx
movq %rax, %r8
leaq 0x119c(%rip), %rsi      # 0x32f0
movb $0x0, %al
callq 0x10f0
jmp 0x215d
leaq -0x86(%rbp), %rdi
xorl %esi, %esi
movl $0x6e, %edx
callq 0x10c0
movw $0x1, -0x86(%rbp)
movb $0x0, -0x84(%rbp)
leaq -0x86(%rbp), %rdi
addq $0x2, %rdi
movq -0x10(%rbp), %rcx
movl $0x6c, %esi
leaq 0x118c(%rip), %rdx      # 0x3327
movb $0x0, %al
callq 0x10a0
movb $0x0, -0x84(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x8c(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x1050
cmpl $0x0, %eax
jge 0x2228
jmp 0x21d6
cmpl $0x0, -0x8c(%rbp)
jle 0x21f4
movl -0x8c(%rbp), %edi
callq 0x10d0
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
jmp 0x21f6
jmp 0x21f8
movq 0x2dd1(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x12a0
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
leaq 0x110c(%rip), %rsi      # 0x332b
movb $0x0, %al
callq 0x10f0
jmp 0x2228
movq -0x10(%rbp), %rdi
callq 0x1080
addq $0x2, %rax
addq $0x1, %rax
movl %eax, -0x14(%rbp)
movl -0x8c(%rbp), %edi
movl -0x14(%rbp), %edx
leaq -0x86(%rbp), %rsi
callq 0x1130
cmpl $0x0, %eax
jge 0x22cb
jmp 0x2258
cmpl $0x0, -0x8c(%rbp)
jle 0x2276
movl -0x8c(%rbp), %edi
callq 0x10d0
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
jmp 0x2278
jmp 0x227a
movq 0x2d4f(%rip), %rax      # 0x4fd0
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x12a0
movq %rax, -0xc8(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1170
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq %rax, %rcx
leaq 0x1086(%rip), %rsi      # 0x3341
movb $0x0, %al
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x22e4
movl -0x8c(%rbp), %edi
movl $0x4, %esi
callq 0x1110
movl -0x8c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq