// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/quectel-qmi-proxy.c
// Function: create_local_server
static int create_local_server(const char *name) {
    int sockfd = -1;
    int reuse_addr = 1;
    struct sockaddr_un sockaddr;
    socklen_t alen;

    /*Create server socket*/
    SYSCHECK(sockfd = socket(AF_LOCAL, SOCK_STREAM, 0));

    memset(&sockaddr, 0, sizeof(sockaddr));
    sockaddr.sun_family = AF_LOCAL;
    sockaddr.sun_path[0] = 0;
    memcpy(sockaddr.sun_path + 1, name, strlen(name) );

    alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1;
    SYSCHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr)));
    if(bind(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) {
        close(sockfd);
        dprintf("bind %s errno: %d (%s)\n", name, errno, strerror(errno));
        return -1;
    }

    dprintf("local server: %s sockfd = %d\n", name, sockfd);
    cfmakenoblock(sockfd);
    listen(sockfd, 1);    

    return sockfd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x18(%rbp)
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x1230
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jge 0x2f0b
jmp 0x2e95
movq 0x3134(%rip), %rax      # 0x5fd0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x1340
movq %rax, -0xa0(%rbp)
callq 0x1050
movl (%rax), %edi
callq 0x1200
movq %rax, -0x98(%rbp)
callq 0x1050
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %r9
movl (%rax), %eax
leaq 0x15d1(%rip), %rsi      # 0x44b9
leaq 0x15eb(%rip), %rcx      # 0x44da
movl $0x1e8, %r8d            # imm = 0x1E8
movl %eax, (%rsp)
movb $0x0, %al
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x313a
jmp 0x2f0d
leaq -0x86(%rbp), %rdi
xorl %esi, %esi
movl $0x6e, %edx
callq 0x10d0
movw $0x1, -0x86(%rbp)
movb $0x0, -0x84(%rbp)
leaq -0x86(%rbp), %rax
addq $0x2, %rax
addq $0x1, %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10a0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq %rax, %rdx
callq 0x1130
movq -0x10(%rbp), %rdi
callq 0x10a0
addq $0x2, %rax
addq $0x1, %rax
movl %eax, -0x8c(%rbp)
movl -0x14(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x1070
cmpl $0x0, %eax
jge 0x3020
jmp 0x2faa
movq 0x301f(%rip), %rax      # 0x5fd0
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x1340
movq %rax, -0xc8(%rbp)
callq 0x1050
movl (%rax), %edi
callq 0x1200
movq %rax, -0xc0(%rbp)
callq 0x1050
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq -0xc0(%rbp), %r9
movl (%rax), %eax
leaq 0x14bc(%rip), %rsi      # 0x44b9
leaq 0x14d6(%rip), %rcx      # 0x44da
movl $0x1f0, %r8d            # imm = 0x1F0
movl %eax, (%rsp)
movb $0x0, %al
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x313a
jmp 0x3022
movl -0x14(%rbp), %edi
movl -0x8c(%rbp), %edx
leaq -0x86(%rbp), %rsi
callq 0x1170
cmpl $0x0, %eax
jge 0x30bb
movl -0x14(%rbp), %edi
callq 0x10e0
movq 0x2f85(%rip), %rax      # 0x5fd0
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
callq 0x1340
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
callq 0x1050
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
callq 0x1050
movl (%rax), %edi
callq 0x1200
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movq -0xe0(%rbp), %rcx
movl -0xd4(%rbp), %r8d
movq %rax, %r9
leaq 0x1443(%rip), %rsi      # 0x44ee
movb $0x0, %al
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x313a
jmp 0x30bd
movq 0x2f0c(%rip), %rax      # 0x5fd0
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
callq 0x1340
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movl -0x14(%rbp), %r8d
leaq 0x141d(%rip), %rsi      # 0x4509
movb $0x0, %al
callq 0x1120
jmp 0x30f5
movl -0x14(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0x14(%rbp), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0x1080
movl -0xfc(%rbp), %edi
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl $0x4, %esi
movb $0x0, %al
callq 0x1080
movl -0x14(%rbp), %edi
movl $0x1, %esi
callq 0x1150
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq