// File: /workspace/github_c_makefile_star2_O0/containers[P]conmon/src/conn_sock.c
// Function: setup_socket
static char *setup_socket(int *fd, const char *path)
{
	char *csname = NULL;
	char *bname = NULL;
	_cleanup_close_ int sfd = -1;

	if (path != NULL) {
		_cleanup_free_ char *dname_buf = NULL;
		_cleanup_free_ char *bname_buf = NULL;
		char *dname = NULL, *bname = NULL;

		csname = strdup(path);
		dname_buf = strdup(path);
		bname_buf = strdup(path);
		if (csname == NULL || dname_buf == NULL || bname_buf == NULL) {
			pexit("Failed to allocate memory");
			return NULL;
		}
		dname = dirname(dname_buf);
		if (dname == NULL)
			pexitf("Cannot get dirname for %s", csname);

		sfd = open(dname, O_CREAT | O_PATH | O_CLOEXEC, 0600);
		if (sfd < 0)
			pexit("Failed to create file for console-socket");

		bname = basename(bname_buf);
		if (bname == NULL)
			pexitf("Cannot get basename for %s", csname);
	} else {
		_cleanup_free_ const char *tmpdir = g_get_tmp_dir();

		csname = g_build_filename(tmpdir, "conmon-term.XXXXXX", NULL);
		/*
		 * Generate a temporary name. Is this unsafe? Probably, but we can
		 * replace it with a rename(2) setup if necessary.
		 */
		int unusedfd = g_mkstemp(csname);
		if (unusedfd < 0)
			pexit("Failed to generate random path for console-socket");
		close(unusedfd);
		/* XXX: This should be handled with a rename(2). */
		if (unlink(csname) < 0)
			pexit("Failed to unlink temporary random path");

		bname = csname;
	}

	/* Bind to the console socket path. */
	*fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
	if (*fd < 0)
		pexit("Failed to create socket");
	bind_relative_to_dir(sfd, *fd, bname);
	if (listen(*fd, 128) < 0)
		pexit("Failed to listen on console-socket");

	return csname;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x18(%rbp)
je 0xa9bf
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45f0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45f0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xa7ee
cmpq $0x0, -0x38(%rbp)
je 0xa7ee
cmpq $0x0, -0x40(%rbp)
jne 0xa849
jmp 0xa7f0
movq 0xb7f9(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x4812(%rip), %rsi      # 0xf013
leaq 0x6edc(%rip), %rdx      # 0x116e4
movb $0x0, %al
callq 0x4830
leaq 0x20732(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa83f
leaq 0x2071e(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x480c(%rip), %rsi      # 0xf03d
leaq 0x6eac(%rip), %rcx      # 0x116e4
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movq -0x38(%rbp), %rdi
callq 0x4080
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa8b2
jmp 0xa85f
movq 0xb78a(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x6e8a(%rip), %rsi      # 0x116fe
movb $0x0, %al
callq 0x4830
leaq 0x206c6(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa8a8
leaq 0x206b2(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movl $0x3, %edi
leaq 0x6e87(%rip), %rsi      # 0x11728
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movq -0x48(%rbp), %rdi
movl $0x280040, %esi         # imm = 0x280040
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x48d0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0xa92b
jmp 0xa8d2
movq 0xb717(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x4730(%rip), %rsi      # 0xf013
leaq 0x6e73(%rip), %rdx      # 0x1175d
movb $0x0, %al
callq 0x4830
leaq 0x20650(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa921
leaq 0x2063c(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x472a(%rip), %rsi      # 0xf03d
leaq 0x6e43(%rip), %rcx      # 0x1175d
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movq -0x40(%rbp), %rdi
callq 0x43b0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xa994
jmp 0xa941
movq 0xb6a8(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x6e30(%rip), %rsi      # 0x11786
movb $0x0, %al
callq 0x4830
leaq 0x205e4(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa98a
leaq 0x205d0(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movl $0x3, %edi
leaq 0x6e2e(%rip), %rsi      # 0x117b1
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movl $0x0, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xb660
leaq -0x38(%rbp), %rdi
callq 0xb660
movl -0x54(%rbp), %eax
testl %eax, %eax
jne 0xabdf
jmp 0xa9ba
jmp 0xaad1
callq 0x4040
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
leaq 0x6e14(%rip), %rsi      # 0x117e7
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x46a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x47c0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0xaa4f
jmp 0xa9f6
movq 0xb5f3(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x460c(%rip), %rsi      # 0xf013
leaq 0x6dec(%rip), %rdx      # 0x117fa
movb $0x0, %al
callq 0x4830
leaq 0x2052c(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xaa45
leaq 0x20518(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x4606(%rip), %rsi      # 0xf03d
leaq 0x6dbc(%rip), %rcx      # 0x117fa
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movl -0x64(%rbp), %edi
callq 0x4100
movq -0x20(%rbp), %rdi
callq 0x4290
cmpl $0x0, %eax
jge 0xaac0
jmp 0xaa67
movq 0xb582(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x459b(%rip), %rsi      # 0xf013
leaq 0x6dad(%rip), %rdx      # 0x1182c
movb $0x0, %al
callq 0x4830
leaq 0x204bb(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xaab6
leaq 0x204a7(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x4595(%rip), %rsi      # 0xf03d
leaq 0x6d7d(%rip), %rcx      # 0x1182c
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xb660
movl $0x1, %edi
movl $0x80001, %esi          # imm = 0x80001
xorl %edx, %edx
callq 0x4580
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jge 0xab4e
jmp 0xaaf5
movq 0xb4f4(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x450d(%rip), %rsi      # 0xf013
leaq 0x6d46(%rip), %rdx      # 0x11853
movb $0x0, %al
callq 0x4830
leaq 0x2042d(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xab44
leaq 0x20419(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x4507(%rip), %rsi      # 0xf03d
leaq 0x6d16(%rip), %rcx      # 0x11853
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movl -0x2c(%rbp), %edi
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x28(%rbp), %rdx
callq 0xb680
movq -0x10(%rbp), %rax
movl (%rax), %edi
movl $0x80, %esi
callq 0x43c0
cmpl $0x0, %eax
jge 0xabd0
jmp 0xab77
movq 0xb472(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x448b(%rip), %rsi      # 0xf013
leaq 0x6cdc(%rip), %rdx      # 0x1186b
movb $0x0, %al
callq 0x4830
leaq 0x203ab(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xabc6
leaq 0x20397(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x4485(%rip), %rsi      # 0xf03d
leaq 0x6cac(%rip), %rcx      # 0x1186b
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x54(%rbp)
leaq -0x2c(%rbp), %rdi
callq 0xb630
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)