// File: /workspace/github_c_makefile_star2_O0/jacereda[P]fsatrace/src/fsatrace.c
// Function: main
int
main(int argc, char *const argv[])
{
	int		     err;
	int		     rc = EXIT_FAILURE;
	const char *	     out;
	struct shm	     shm;
	size_t		     sz = 0;
	char		     envout[PATH_MAX + 8];
	const unsigned char *opts;
	char *		     bopts;
	int		     verr;
	char *const *	     args = argv + 4;
	unsigned	     nargs = argc - 4;

	static char s_buf[LOGSZ];

	if (argc < 5 || (strcmp(argv[3], "--") && strcmp(argv[3], "---")))
		fatal(
		    " usage: %s <options> <output> -- <cmdline>\n"
		    "  where <options> is a combination of the following characters:\n"
		    "   v: print args vector\n"
		    "   e: print verbose errors\n"
		    "   r: dump read operations\n"
		    "   w: dump write operations\n"
		    "   m: dump file move operations\n"
		    "   d: dump file delete operations\n"
		    "   q: dump file stat operations\n",
		    argv[0]);
	out = argv[2];
	if ((err = shmInit(&shm, out, LOGSZ, 1)))
		fatal("allocating shared memory (%d)", err);
	snprintf(envout, sizeof(envout), ENVOUT "=%s", out);
	putenv(envout);
	workaround(out);
	fflush(stdout);
	opts = (const unsigned char *)argv[1];
	bopts = shm.buf + 4;
	while (*opts)
		bopts[*opts++] = 1;

	if (bopts['v'])
		procDumpArgs(nargs, args);
	verr = bopts['e'];
	switch (procRun(nargs, args, &rc)) {
	case ERR_PROC_FORK:
		if (verr)
			aerror(nargs, args, "forking process");
		break;
	case ERR_PROC_EXEC:
		if (verr)
			aerror(nargs, args, "executing command: %d", rc);
		break;
	case ERR_PROC_SIGNALED:
		if (verr)
			aerror(nargs, args, "process signaled: %d", rc);
		break;
	case ERR_PROC_STOPPED:
		if (verr)
			aerror(nargs, args, "process stopped: %d", rc);
		break;
	case ERR_PROC_UNKNOWN:
		if (verr)
			aerror(nargs, args, "unknow process error");
		break;
	case ERR_PROC_WAIT:
		if (verr)
			aerror(nargs, args, "waiting for command completion");
		break;
	default:
		if (rc) {
			if (verr)
				aerror(nargs, args,
				    "command failed with code %d", rc);
		}
		if (strcmp(argv[3], "---")) {
			uniq(s_buf, &sz, shm.buf + 4 + 256, "", 0);
			dump(out, s_buf, sz);
		} else
			dump(out, shm.buf + 4 + 256, *(uint32_t *)shm.buf);
	}
	if ((err = shmTerm(&shm, 1)))
		error("freeing shared memory (%d)", err);
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2090, %rsp           # imm = 0x2090
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x18(%rbp)
movq $0x0, -0x1050(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x2080(%rbp)
movl -0x8(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x2084(%rbp)
cmpl $0x5, -0x8(%rbp)
jl 0x139e
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x1ca2(%rip), %rsi      # 0x301d
callq 0x1130
cmpl $0x0, %eax
je 0x13b3
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x1c88(%rip), %rsi      # 0x301c
callq 0x1130
cmpl $0x0, %eax
je 0x13b3
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x1c74(%rip), %rdi      # 0x3020
movb $0x0, %al
callq 0x16f0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x1048(%rbp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
movl $0x1, %ecx
callq 0x1e20
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x13f2
movl -0x14(%rbp), %esi
leaq 0x1d6d(%rip), %rdi      # 0x3158
movb $0x0, %al
callq 0x16f0
leaq -0x2060(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x1008, %esi           # imm = 0x1008
leaq 0x1d6d(%rip), %rdx      # 0x3176
movb $0x0, %al
callq 0x10e0
leaq -0x2060(%rbp), %rdi
callq 0x1120
movq -0x20(%rbp), %rdi
callq 0x17a0
movq 0x3bac(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1170
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x2068(%rbp)
movq -0x1048(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x2070(%rbp)
movq -0x2068(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1486
movq -0x2070(%rbp), %rax
movq -0x2068(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x2068(%rbp)
movzbl (%rcx), %ecx
movb $0x1, (%rax,%rcx)
jmp 0x1455
movq -0x2070(%rbp), %rax
cmpb $0x0, 0x76(%rax)
je 0x14a5
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
callq 0x1c20
movq -0x2070(%rbp), %rax
movsbl 0x65(%rax), %eax
movl %eax, -0x2074(%rbp)
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x1c80
decl %eax
movl %eax, %ecx
movq %rcx, -0x2090(%rbp)
subl $0x5, %eax
ja 0x15f6
movq -0x2090(%rbp), %rax
leaq 0x1b16(%rip), %rcx      # 0x3004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, -0x2074(%rbp)
je 0x151b
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
leaq 0x1c6e(%rip), %rdx      # 0x3182
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x2074(%rbp)
je 0x1547
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
movl -0x18(%rbp), %ecx
leaq 0x1c52(%rip), %rdx      # 0x3192
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x2074(%rbp)
je 0x1573
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
movl -0x18(%rbp), %ecx
leaq 0x1c3c(%rip), %rdx      # 0x31a8
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x2074(%rbp)
je 0x159f
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
movl -0x18(%rbp), %ecx
leaq 0x1c25(%rip), %rdx      # 0x31bd
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x2074(%rbp)
je 0x15c8
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
leaq 0x1c10(%rip), %rdx      # 0x31d1
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x2074(%rbp)
je 0x15f1
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
leaq 0x1bfc(%rip), %rdx      # 0x31e6
movb $0x0, %al
callq 0x17b0
jmp 0x16b0
cmpl $0x0, -0x18(%rbp)
je 0x1625
cmpl $0x0, -0x2074(%rbp)
je 0x1623
movl -0x2084(%rbp), %edi
movq -0x2080(%rbp), %rsi
movl -0x18(%rbp), %ecx
leaq 0x1be9(%rip), %rdx      # 0x3205
movb $0x0, %al
callq 0x17b0
jmp 0x1625
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x19e8(%rip), %rsi      # 0x301c
callq 0x1130
cmpl $0x0, %eax
je 0x1688
movq -0x1048(%rbp), %rdx
addq $0x4, %rdx
addq $0x100, %rdx            # imm = 0x100
leaq 0x3ad9(%rip), %rdi      # 0x5130
leaq -0x1050(%rbp), %rsi
leaq 0x1bf5(%rip), %rcx      # 0x325a
xorl %eax, %eax
movl %eax, %r8d
callq 0x1860
movq -0x20(%rbp), %rdi
movq -0x1050(%rbp), %rdx
leaq 0x3aaf(%rip), %rsi      # 0x5130
callq 0x1960
jmp 0x16ae
movq -0x20(%rbp), %rdi
movq -0x1048(%rbp), %rsi
addq $0x4, %rsi
addq $0x100, %rsi            # imm = 0x100
movq -0x1048(%rbp), %rax
movl (%rax), %eax
movl %eax, %edx
callq 0x1960
jmp 0x16b0
leaq -0x1048(%rbp), %rdi
movl $0x1, %esi
callq 0x2030
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x16da
movl -0x14(%rbp), %esi
leaq 0x1b4e(%rip), %rdi      # 0x3221
movb $0x0, %al
callq 0x1a20
movl -0x18(%rbp), %eax
addq $0x2090, %rsp           # imm = 0x2090
popq %rbp
retq
nopw %cs:(%rax,%rax)