// File: AGWA[P]logmailer/logmailer.cpp
// Function: set_cloexec(int, bool)
static void set_cloexec (int fd, bool cloexec)
{
	int		old_flags = fcntl(fd, F_GETFD);
	if (old_flags == -1) {
		throw System_error("fcntl(F_GETFD)", "", errno);
	}
	int		new_flags = old_flags;
	if (cloexec) {
		new_flags |= FD_CLOEXEC;
	} else {
		new_flags &= ~FD_CLOEXEC;
	}
	if (new_flags != old_flags && fcntl(fd, F_SETFD, new_flags) == -1) {
		throw System_error("fcntl(F_SETFD)", "", errno);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movb %sil, %al
movl %edi, -0x4(%rbp)
andb $0x1, %al
movb %al, -0x5(%rbp)
movl -0x4(%rbp), %edi
movl $0x1, %esi
movb $0x0, %al
callq 0x3170
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x4c2e
movb $0x1, -0x6a(%rbp)
movl $0x48, %edi
callq 0x3160
movq %rax, -0xd0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3510
movq -0xc8(%rbp), %rdx
leaq 0x267b(%rip), %rsi      # 0x71d0
leaq -0x30(%rbp), %rdi
callq 0x5dd0
jmp 0x4b60
leaq -0x69(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3510
movq -0xd8(%rbp), %rdx
leaq 0x26d3(%rip), %rsi      # 0x7251
leaq -0x68(%rbp), %rdi
callq 0x5dd0
jmp 0x4b89
callq 0x3030
movq -0xd0(%rbp), %rdi
movl (%rax), %ecx
leaq -0x30(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x5e80
jmp 0x4ba6
movq -0xd0(%rbp), %rdi
movb $0x0, -0x6a(%rbp)
leaq 0x41d0(%rip), %rsi      # 0x8d88
leaq 0x1331(%rip), %rdx      # 0x5ef0
callq 0x34e0
jmp 0x4db7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4c0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4bfa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3588
leaq -0x69(%rbp), %rdi
callq 0x32f0
leaq -0x30(%rbp), %rdi
callq 0x3588
leaq -0x31(%rbp), %rdi
callq 0x32f0
testb $0x1, -0x6a(%rbp)
jne 0x4c1d
jmp 0x4c29
movq -0xd0(%rbp), %rdi
callq 0x31c0
jmp 0x4dae
movl -0xc(%rbp), %eax
movl %eax, -0x70(%rbp)
testb $0x1, -0x5(%rbp)
je 0x4c45
movl -0x70(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x4c4e
movl -0x70(%rbp), %eax
andl $-0x2, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0x4da5
movl -0x4(%rbp), %edi
movl -0x70(%rbp), %edx
movl $0x2, %esi
movb $0x0, %al
callq 0x3170
cmpl $-0x1, %eax
jne 0x4da5
movb $0x1, -0xba(%rbp)
movl $0x48, %edi
callq 0x3160
movq %rax, -0xe8(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3510
movq -0xe0(%rbp), %rdx
leaq 0x2531(%rip), %rsi      # 0x71df
leaq -0x90(%rbp), %rdi
callq 0x5dd0
jmp 0x4cbc
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3510
movq -0xf0(%rbp), %rdx
leaq 0x2574(%rip), %rsi      # 0x7251
leaq -0xb8(%rbp), %rdi
callq 0x5dd0
jmp 0x4ceb
callq 0x3030
movq -0xe8(%rbp), %rdi
movl (%rax), %ecx
leaq -0x90(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x5e80
jmp 0x4d0e
movq -0xe8(%rbp), %rdi
movb $0x0, -0xba(%rbp)
leaq 0x4065(%rip), %rsi      # 0x8d88
leaq 0x11c6(%rip), %rdx      # 0x5ef0
callq 0x34e0
jmp 0x4db7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4d80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4d68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3588
leaq -0xb9(%rbp), %rdi
callq 0x32f0
leaq -0x90(%rbp), %rdi
callq 0x3588
leaq -0x91(%rbp), %rdi
callq 0x32f0
testb $0x1, -0xba(%rbp)
jne 0x4d97
jmp 0x4da3
movq -0xe8(%rbp), %rdi
callq 0x31c0
jmp 0x4dae
addq $0xf0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3500
nopw (%rax,%rax)