// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/chargenx.c
// Function: write_pid
static int write_pid(const char *pid_file)
{
	int i;
	int fd;
	char buf[100];
	if ((fd = open(pid_file, O_WRONLY | O_CREAT, 0644)) < 0) {
		int save_errno = errno;
		assert(fd == -1);
		DEBUG("open(pid_file=[%s], O_WRONLY | O_CREAT, 0644), errno=%i", pid_file, save_errno);
		errno = save_errno;
		perror(pid_file);
		return -1;
	}
	if ((i = lockf(fd, F_TLOCK, 0)) < 0) {
		int save_errno = errno;
		assert(i == -1);
		DEBUG("lockf(fd, F_TLOCK, 0), errno=%i", save_errno);
		errno = save_errno;
		perror(pid_file);
		return -1;
	}
	i = snprintf(buf, sizeof(buf), "%i\n", getpid());
	assert(write_exact(fd, buf, i) == i);
	assert(ftruncate(fd, i) == 0);
	return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x41, %esi
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0x2210
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jge 0x3ee9
callq 0x2060
movl (%rax), %eax
movl %eax, -0x84(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x3e75
jmp 0x3e94
leaq 0x49df(%rip), %rdi      # 0x885b
leaq 0x43d9(%rip), %rsi      # 0x825c
movl $0x1cb, %edx            # imm = 0x1CB
leaq 0x4a41(%rip), %rcx      # 0x88d0
callq 0x2140
jmp 0x3e96
movq -0x10(%rbp), %rcx
movl -0x84(%rbp), %r8d
leaq 0x43b4(%rip), %rdi      # 0x825c
movl $0x1cc, %esi            # imm = 0x1CC
leaq 0x4a38(%rip), %rdx      # 0x88ec
movb $0x0, %al
callq 0x7000
movl -0x84(%rbp), %eax
movl %eax, -0x8c(%rbp)
callq 0x2060
movl -0x8c(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x2220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4026
movl -0x18(%rbp), %edi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x2160
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jge 0x3f8a
callq 0x2060
movl (%rax), %eax
movl %eax, -0x88(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x3f1b
jmp 0x3f3a
leaq 0x4a02(%rip), %rdi      # 0x8924
leaq 0x4333(%rip), %rsi      # 0x825c
movl $0x1d3, %edx            # imm = 0x1D3
leaq 0x499b(%rip), %rcx      # 0x88d0
callq 0x2140
jmp 0x3f3c
movl -0x88(%rbp), %ecx
leaq 0x4313(%rip), %rdi      # 0x825c
movl $0x1d4, %esi            # imm = 0x1D4
leaq 0x49d7(%rip), %rdx      # 0x892c
movb $0x0, %al
callq 0x7000
movl -0x88(%rbp), %eax
movl %eax, -0x90(%rbp)
callq 0x2060
movl -0x90(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x2220
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4026
leaq -0x80(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x20d0
movq -0x98(%rbp), %rdi
movl %eax, %ecx
movl $0x64, %esi
leaq 0x46bb(%rip), %rdx      # 0x866a
movb $0x0, %al
callq 0x2110
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %edi
leaq -0x80(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x44d0
cmpl -0x14(%rbp), %eax
jne 0x3fcf
jmp 0x3fee
leaq 0x4976(%rip), %rdi      # 0x894c
leaq 0x427f(%rip), %rsi      # 0x825c
movl $0x1da, %edx            # imm = 0x1DA
leaq 0x48e7(%rip), %rcx      # 0x88d0
callq 0x2140
movl -0x18(%rbp), %edi
movslq -0x14(%rbp), %rsi
callq 0x2120
cmpl $0x0, %eax
jne 0x4001
jmp 0x4020
leaq 0x4961(%rip), %rdi      # 0x8969
leaq 0x424d(%rip), %rsi      # 0x825c
movl $0x1db, %edx            # imm = 0x1DB
leaq 0x48b5(%rip), %rcx      # 0x88d0
callq 0x2140
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)