// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/includes/dinit-client.h
// Function: connect_to_daemon(char const*)
inline int connect_to_daemon(const char *control_socket_path)
{
    int socknum = socket(AF_UNIX, SOCK_STREAM, 0);
    if (socknum == -1) {
        throw general_error(errno, "opening socket");
    }

    struct sockaddr_un * name;
    uint sockaddr_size = offsetof(struct sockaddr_un, sun_path) + strlen(control_socket_path) + 1;
    name = (struct sockaddr_un *) malloc(sockaddr_size);
    if (name == nullptr) {
        throw general_error(ENOMEM);
    }

    name->sun_family = AF_UNIX;
    strcpy(name->sun_path, control_socket_path);

    int connr = connect(socknum, (struct sockaddr *) name, sockaddr_size);
    free(name);

    if (connr == -1) {
        throw control_sock_conn_err(errno, control_socket_path);
    }

    return socknum;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2060
cmpl $-0x1, %eax
je 0x454b
movl %eax, %ebp
movq %rbx, %rdi
callq 0x20e0
movq %rax, %r14
addl $0x3, %r14d
movq %r14, %rdi
callq 0x22c0
testq %rax, %rax
je 0x45cd
movq %rax, %r15
movw $0x1, (%rax)
movq %rax, %rdi
addq $0x2, %rdi
movq %rbx, %rsi
callq 0x21d0
movl %ebp, %edi
movq %r15, %rsi
movl %r14d, %edx
callq 0x2190
movl %eax, %r14d
movq %r15, %rdi
callq 0x2260
cmpl $-0x1, %r14d
je 0x4609
movl %ebp, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x2100
movq %rax, %rbx
callq 0x2040
movl (%rax), %eax
leaq 0x40(%rsp), %r14
xorl %ecx, %ecx
movb %cl, (%r14)
movl %eax, (%rbx)
leaq 0x2389(%rip), %rax      # 0x68fb
movq %rax, 0x8(%rbx)
leaq 0x20(%rbx), %rax
movq %rax, 0x10(%rbx)
movb (%r14), %al
movb %al, 0x20(%rbx)
movq 0x1(%r14), %rax
movq %rax, 0x21(%rbx)
movl 0x9(%r14), %eax
movl %eax, 0x29(%rbx)
movzwl 0xd(%r14), %eax
movw %ax, 0x2d(%rbx)
movb 0xf(%r14), %al
movb %al, 0x2f(%rbx)
movq %rcx, 0x18(%rbx)
movq %r14, -0x10(%r14)
movq %rcx, -0x8(%r14)
movb %cl, (%r14)
leaq 0x47cf(%rip), %rsi      # 0x8d88
leaq 0x3ea(%rip), %rdx       # 0x49aa
movq %rbx, %rdi
callq 0x2390
jmp 0x46c0
movl $0x30, %edi
callq 0x2100
movl $0xc, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
leaq 0x20(%rax), %rdx
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movb $0x0, 0x20(%rax)
leaq 0x478e(%rip), %rsi      # 0x8d88
leaq 0x3a9(%rip), %rdx       # 0x49aa
movq %rax, %rdi
callq 0x2390
movl $0x30, %edi
callq 0x2100
movq %rax, %r15
movq %rax, %r14
callq 0x2040
movl (%rax), %ebp
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %rbx, %rsi
callq 0x496c
leaq 0x60(%rsp), %rax
leaq 0x20(%rsp), %r12
movq -0x10(%r12), %rcx
cmpq %r12, %rcx
jne 0x4653
movups (%r12), %xmm0
movups %xmm0, (%rax)
movq %rax, %rcx
jmp 0x465d
movq 0x20(%rsp), %rdx
movq %rdx, 0x60(%rsp)
movq 0x18(%rsp), %rdx
movq %r12, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movl %ebp, (%r14)
leaq 0x22b5(%rip), %rsi      # 0x6934
movq %rsi, 0x8(%r14)
addq $0x20, %r15
movq %r15, 0x10(%r14)
cmpq %rax, %rcx
jne 0x4699
movups (%rax), %xmm0
movups %xmm0, (%r15)
jmp 0x46a6
movq %rcx, 0x10(%r14)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%r14)
movq %rdx, 0x18(%r14)
leaq 0x46e7(%rip), %rsi      # 0x8d98
leaq 0x2f2(%rip), %rdx       # 0x49aa
movq %r14, %rdi
callq 0x2390
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x46fb
movq 0x20(%rsp), %rsi
jmp 0x46f3
movq %rax, %rbx
movq %r14, %rdi
callq 0x2150
jmp 0x46fb
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x46fb
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x23b0