// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/aimant.c
// Function: main
int main(int argc, char **argv)
{
	char **sink_argv;
	struct sink svlogd[1];
	struct fd_tap fd0[1];
	struct getopt_x state[1];
	int pid_to_send_signal = -1;

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

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

	DEBUG_INFO("args->pid_file=[%s]", args->pid_file);
	DEBUG_INFO("args->log_file=[%s]", args->log_file);
	DEBUG_INFO("args->svlogd_path=[%s]", args->svlogd_path);
	DEBUG_INFO("args->count_to_rotate=%li", args->count_to_rotate);

	if (read_pid(args->pid_file, &pid_to_send_signal)) {
		DEBUG("invalid pid file");
		return 1;
	}

	memset(svlogd, 0, sizeof(svlogd));
	memset(fd0, 0, sizeof(fd0));

	/* spawn svlogd
	 */

	sink_argv = calloc(4, sizeof(char*));
	sink_argv[0] = args->svlogd_path;
	sink_argv[1] = "-ttt";
	sink_argv[2] = args->output_dir;
	sink_argv[3] = NULL;

	assert(sink_open(svlogd, 1 /* search path? */, sink_argv) == 0);

	/* register stdin as tap
	 */

	assert(fd_tap_open(fd0, STDIN_FILENO) == 0);

	/* unleash
	 */

	assert(doit(pid_to_send_signal, svlogd, fd0, args->log_file, args->count_to_rotate, args->exit_on_timeout) == 0);

	DEBUG_INFO("closing svlogd sink, pid=%i", svlogd->sp->pid);
	sink_close(svlogd);

	/* cleanup
	 */

	free(sink_argv);
	sink_argv = NULL;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x284(%rbp) # imm = 0xFFFFFFFF
leaq -0x280(%rbp), %rdi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x4190
cmpl $0x0, %eax
je 0x3fc8
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x280(%rbp), %rsi
callq 0x4610
movl $0x1, %edi
callq 0x2350
cmpl $0x1, -0x8(%rbp)
jne 0x3fe8
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x280(%rbp), %rsi
callq 0x4610
xorl %edi, %edi
callq 0x2350
leaq 0x12211(%rip), %rdi     # 0x16200
leaq -0x284(%rbp), %rsi
callq 0x4c90
cmpl $0x0, %eax
je 0x4028
jmp 0x4002
leaq 0xc053(%rip), %rdi      # 0x1005c
movl $0x4b0, %esi            # imm = 0x4B0
leaq 0xc5fd(%rip), %rdx      # 0x10612
movb $0x0, %al
callq 0xdfe0
movl $0x1, -0x4(%rbp)
jmp 0x4180
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x21c0
leaq -0x6c(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x21c0
movl $0x4, %edi
movl $0x8, %esi
callq 0x2210
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
leaq 0x1219a(%rip), %rcx     # 0x16200
addq $0x200, %rcx            # imm = 0x200
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
leaq 0xc5a8(%rip), %rcx      # 0x10623
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq 0x12176(%rip), %rcx     # 0x16200
addq $0x30c, %rcx            # imm = 0x30C
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
leaq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x1, %esi
callq 0x24d0
cmpl $0x0, %eax
jne 0x40ba
jmp 0x40d9
leaq 0xc567(%rip), %rdi      # 0x10628
leaq 0xbf94(%rip), %rsi      # 0x1005c
movl $0x4c0, %edx            # imm = 0x4C0
leaq 0xc57a(%rip), %rcx      # 0x1064e
callq 0x21a0
leaq -0x6c(%rbp), %rdi
xorl %esi, %esi
callq 0x2610
cmpl $0x0, %eax
jne 0x40eb
jmp 0x410a
leaq 0xc573(%rip), %rdi      # 0x10665
leaq 0xbf63(%rip), %rsi      # 0x1005c
movl $0x4c5, %edx            # imm = 0x4C5
leaq 0xc549(%rip), %rcx      # 0x1064e
callq 0x21a0
movl -0x284(%rbp), %edi
leaq -0x60(%rbp), %rsi
leaq -0x6c(%rbp), %rdx
movq 0x123e1(%rip), %r8      # 0x16500
movl 0x123e2(%rip), %r9d     # 0x16508
leaq 0x120d3(%rip), %rcx     # 0x16200
addq $0x100, %rcx            # imm = 0x100
callq 0x4f20
cmpl $0x0, %eax
jne 0x4140
jmp 0x415f
leaq 0xc542(%rip), %rdi      # 0x10689
leaq 0xbf0e(%rip), %rsi      # 0x1005c
movl $0x4ca, %edx            # imm = 0x4CA
leaq 0xc4f4(%rip), %rcx      # 0x1064e
callq 0x21a0
leaq -0x60(%rbp), %rdi
callq 0x2580
movq -0x18(%rbp), %rdi
callq 0x2050
movq $0x0, -0x18(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
nopl (%rax)