// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/chargenx.c
// Function: main
int main(int argc, char **argv)
{
	int pid_fd = -1;
	struct getopt_x state[1];

	if (process_args(state, argc, argv)) {
		help(argv[0], state);
		exit(1);
	}

	if (args->daemonize) {
		if (daemonize(1 /* close_all_descriptors */, 1 /* preserve_stderr */)) return -1;
		signal(SIGUSR1, signal_SIGUSR1);
	} else {
		signal(SIGHUP, signal_SIGHUP);
		signal(SIGTERM, signal_SIGTERM);
		signal(SIGUSR1, signal_SIGUSR1);
	}

	/* after daemonize, both stdin and stdout points to /dev/null
	 */

	if (*args->err_file) if (open_stderr()) return -1;
	if (*args->out_file) {
		if (open_stdout()) return -1;
		DEBUG("stdout successfully redirected to [%s]", args->out_file);
	}

	if (*args->pid_file && (pid_fd = write_pid(args->pid_file)) < 0) {
		DEBUG("error: failed to write pid or acquire lock");
		return -1;
	}

	DEBUG("program [%s] started", argv[0]);

	if (args->start_delay) usleep(args->start_delay);

	DEBUG("program [%s] after start delay", argv[0]);

	if (doit()) return 1;

	DEBUG("program [%s] before end delay", argv[0]);

	if (args->end_delay) usleep(args->end_delay);

	DEBUG("program [%s] finished", argv[0]);

	if (*args->out_file) close(STDOUT_FILENO);
	if (*args->err_file) close(STDERR_FILENO);

	if (pid_fd != -1) close(pid_fd);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
leaq -0x220(%rbp), %rdi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x2620
cmpl $0x0, %eax
je 0x23e5
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x220(%rbp), %rsi
callq 0x2e40
movl $0x1, %edi
callq 0x2240
cmpl $0x0, 0x910c(%rip)      # 0xb4f8
je 0x241e
movl $0x1, %esi
movl %esi, %edi
callq 0x3b50
cmpl $0x0, %eax
je 0x240b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2612
movl $0xa, %edi
leaq 0x19b9(%rip), %rsi      # 0x3dd0
callq 0x21b0
jmp 0x2451
movl $0x1, %edi
leaq 0x19c6(%rip), %rsi      # 0x3df0
callq 0x21b0
movl $0xf, %edi
leaq 0x19d5(%rip), %rsi      # 0x3e10
callq 0x21b0
movl $0xa, %edi
leaq 0x1984(%rip), %rsi      # 0x3dd0
callq 0x21b0
cmpb $0x0, 0x8f9c(%rip)      # 0xb3f4
je 0x2472
callq 0x4700
cmpl $0x0, %eax
je 0x2470
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2612
jmp 0x2472
cmpb $0x0, 0x8e7b(%rip)      # 0xb2f4
je 0x24bd
callq 0x46c0
cmpl $0x0, %eax
je 0x2491
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2612
jmp 0x2493
leaq 0x5dc2(%rip), %rdi      # 0x825c
movl $0x148, %esi            # imm = 0x148
leaq 0x5dc1(%rip), %rdx      # 0x8267
leaq 0x8cb3(%rip), %rcx      # 0xb160
addq $0x194, %rcx            # imm = 0x194
movb $0x0, %al
callq 0x7000
jmp 0x24bd
movsbl 0x8c9c(%rip), %eax      # 0xb160
cmpl $0x0, %eax
je 0x2505
leaq 0x8c90(%rip), %rdi      # 0xb160
callq 0x3e30
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jge 0x2505
jmp 0x24df
leaq 0x5d76(%rip), %rdi      # 0x825c
movl $0x14c, %esi            # imm = 0x14C
leaq 0x5d9c(%rip), %rdx      # 0x828e
movb $0x0, %al
callq 0x7000
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2612
jmp 0x2507
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0x5d47(%rip), %rdi      # 0x825c
movl $0x150, %esi            # imm = 0x150
leaq 0x5d98(%rip), %rdx      # 0x82b9
movb $0x0, %al
callq 0x7000
cmpq $0x0, 0x8d30(%rip)      # 0xb260
je 0x2540
movq 0x8d27(%rip), %rax      # 0xb260
movl %eax, %edi
callq 0x2280
jmp 0x2542
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0x5d0c(%rip), %rdi      # 0x825c
movl $0x154, %esi            # imm = 0x154
leaq 0x5d72(%rip), %rdx      # 0x82ce
movb $0x0, %al
callq 0x7000
callq 0x4040
cmpl $0x0, %eax
je 0x2579
movl $0x1, -0x4(%rbp)
jmp 0x2612
jmp 0x257b
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0x5cd3(%rip), %rdi      # 0x825c
movl $0x158, %esi            # imm = 0x158
leaq 0x5d58(%rip), %rdx      # 0x82ed
movb $0x0, %al
callq 0x7000
cmpq $0x0, 0x8cd4(%rip)      # 0xb278
je 0x25b4
movq 0x8ccb(%rip), %rax      # 0xb278
movl %eax, %edi
callq 0x2280
jmp 0x25b6
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0x5c98(%rip), %rdi      # 0x825c
movl $0x15c, %esi            # imm = 0x15C
leaq 0x5d3b(%rip), %rdx      # 0x830b
movb $0x0, %al
callq 0x7000
cmpb $0x0, 0x8d16(%rip)      # 0xb2f4
je 0x25ea
movl $0x1, %edi
callq 0x2180
cmpb $0x0, 0x8e03(%rip)      # 0xb3f4
je 0x25fd
movl $0x2, %edi
callq 0x2180
cmpl $-0x1, -0x14(%rbp)
je 0x260b
movl -0x14(%rbp), %edi
callq 0x2180
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nop