// File: /workspace/github_c_makefile_star2_O0/containers[P]conmon/src/conn_sock.c
// Function: bind_relative_to_dir
static void bind_relative_to_dir(int dir_fd, int sock_fd, const char *path)
{
	struct sockaddr_un addr;

	/*
	 * To be able to access the location of the attach socket, without first creating the attach socket
	 * but also be able to handle arbitrary length paths, we open the parent dir (base_path), and then use
	 * the corresponding entry in `/proc/self/fd` to act as the path to base_path, then we use the socket_relative_name
	 * to actually refer to the file where the socket will be created below.
	 */
	addr.sun_family = AF_UNIX;
	if (dir_fd == -1) {
		strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
	} else {
		snprintf(addr.sun_path, sizeof(addr.sun_path), "/proc/self/fd/%d/%s", dir_fd, path);
	}
	ndebugf("addr{sun_family=AF_UNIX, sun_path=%s}", addr.sun_path);

	if (fchmod(sock_fd, 0700))
		pexit("Failed to change console-socket permissions");
	if (bind(sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
		pexit("Failed to bind to console-socket");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movw $0x1, -0x7e(%rbp)
cmpl $-0x1, -0x4(%rbp)
jne 0xb6b9
leaq -0x7e(%rbp), %rdi
addq $0x2, %rdi
movq -0x10(%rbp), %rsi
movl $0x6b, %edx
callq 0x4700
jmp 0xb6db
leaq -0x7e(%rbp), %rdi
addq $0x2, %rdi
movl -0x4(%rbp), %ecx
movq -0x10(%rbp), %r8
movl $0x6c, %esi
leaq 0x61ba(%rip), %rdx      # 0x1188e
movb $0x0, %al
callq 0x40c0
leaq 0xadc2(%rip), %rax      # 0x164a4
cmpl $0x3, (%rax)
jb 0xb73e
jmp 0xb6e9
movq 0xa900(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq -0x7e(%rbp), %rdx
addq $0x2, %rdx
leaq 0x61a0(%rip), %rsi      # 0x118a2
movb $0x0, %al
callq 0x4830
leaq 0x1f838(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xb73a
leaq 0x1f824(%rip), %rax     # 0x2af40
movq (%rax), %rdx
leaq -0x7e(%rbp), %rcx
addq $0x2, %rcx
movl $0x6, %edi
leaq 0x61a2(%rip), %rsi      # 0x118d5
movb $0x0, %al
callq 0x4120
jmp 0xb73c
jmp 0xb73e
movl -0x8(%rbp), %edi
movl $0x1c0, %esi            # imm = 0x1C0
callq 0x4510
cmpl $0x0, %eax
je 0xb7ab
jmp 0xb752
movq 0xa897(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x38b0(%rip), %rsi      # 0xf013
leaq 0x61aa(%rip), %rdx      # 0x11914
movb $0x0, %al
callq 0x4830
leaq 0x1f7d0(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xb7a1
leaq 0x1f7bc(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x38aa(%rip), %rsi      # 0xf03d
leaq 0x617a(%rip), %rcx      # 0x11914
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movl -0x8(%rbp), %edi
leaq -0x7e(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
movl $0x6e, %edx
callq 0x47f0
cmpl $0x0, %eax
jge 0xb82a
jmp 0xb7d1
movq 0xa818(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x3831(%rip), %rsi      # 0xf013
leaq 0x6157(%rip), %rdx      # 0x11940
movb $0x0, %al
callq 0x4830
leaq 0x1f751(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xb820
leaq 0x1f73d(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x382b(%rip), %rsi      # 0xf03d
leaq 0x6127(%rip), %rcx      # 0x11940
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)