// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2058, %rsp           # imm = 0x2058
movq %rsi, %r15
movl $0x1, 0xc(%rsp)
cmpl $0x5, %edi
jl 0x1617
movl %edi, %ebp
movq 0x18(%r15), %rdi
cmpb $0x2d, (%rdi)
jne 0x1358
cmpb $0x2d, 0x1(%rdi)
jne 0x1358
cmpb $0x0, 0x2(%rdi)
je 0x136c
leaq 0xcbd(%rip), %rsi       # 0x201c
callq 0x1130
testl %eax, %eax
jne 0x1617
movq 0x10(%r15), %rbx
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %rcx
movl $0x1000000, %edx        # imm = 0x1000000
movq %rbx, %rsi
callq 0x1ac0
testl %eax, %eax
jne 0x1628
leaq 0x20(%r15), %r14
addl $-0x4, %ebp
leaq 0xddb(%rip), %rdx       # 0x2176
leaq 0x1050(%rsp), %r12
movl $0x1008, %esi           # imm = 0x1008
movq %r12, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10e0
movq %r12, %rdi
callq 0x1120
movq 0x2c14(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
callq 0x1170
movq 0x8(%r15), %rax
movq 0x28(%rsp), %r12
movzbl (%rax), %ecx
testq %rcx, %rcx
je 0x13e8
incq %rax
movb $0x1, 0x4(%r12,%rcx)
jmp 0x13d5
cmpb $0x0, 0x7a(%r12)
je 0x13fa
movl %ebp, %edi
movq %r14, %rsi
callq 0x199f
movb 0x69(%r12), %r12b
leaq 0xc(%rsp), %rdx
movl %ebp, %edi
movq %r14, %rsi
callq 0x19e8
decl %eax
cmpl $0x5, %eax
ja 0x14bf
leaq 0xbe4(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testb %r12b, %r12b
je 0x15e0
leaq 0xd49(%rip), %rdx       # 0x2182
jmp 0x14ae
testb %r12b, %r12b
je 0x15e0
leaq 0xd9b(%rip), %rdx       # 0x21e6
jmp 0x14ae
testb %r12b, %r12b
je 0x15e0
movl 0xc(%rsp), %ecx
leaq 0xd47(%rip), %rdx       # 0x21a8
jmp 0x148d
testb %r12b, %r12b
je 0x15e0
movl 0xc(%rsp), %ecx
leaq 0xd46(%rip), %rdx       # 0x21bd
jmp 0x148d
testb %r12b, %r12b
je 0x15e0
movl 0xc(%rsp), %ecx
leaq 0xd05(%rip), %rdx       # 0x2192
movl %ebp, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x16c7
jmp 0x15e0
testb %r12b, %r12b
je 0x15e0
leaq 0xd23(%rip), %rdx       # 0x21d1
movl %ebp, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x16c7
jmp 0x15e0
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
setne %al
testb %r12b, %r12b
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x14e8
leaq 0xd29(%rip), %rdx       # 0x2205
movl %ebp, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x16c7
movq 0x18(%r15), %rdi
leaq 0xb29(%rip), %rsi       # 0x201c
callq 0x1130
movq 0x28(%rsp), %rcx
leaq 0x104(%rcx), %r13
testl %eax, %eax
je 0x15d3
movq %rbx, 0x20(%rsp)
leaq 0xd42(%rip), %rbx       # 0x225a
leaq 0x2c11(%rip), %rax      # 0x4130
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
pushq $0xa
popq %rbp
xorl %r15d, %r15d
movq %r13, %r14
movq %r13, %rdi
movl %ebp, %esi
callq 0x10d0
testq %rax, %rax
je 0x15a8
movq %rax, %r13
movq %rax, %r12
subq %r14, %r12
cmpq %r15, %r12
jne 0x156d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
jne 0x156a
incq %r13
jmp 0x1533
movq %r15, %r12
leaq 0x1(%r12), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1150
movq 0x18(%rsp), %rax
addq %r12, %rax
incq %rax
movq %rax, 0x18(%rsp)
addq %r12, %rbx
incq %rbx
movq %rbx, 0x10(%rsp)
incq %r13
movq %r14, %rbx
movq %r12, %r15
jmp 0x1533
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x1060
movq %r14, %rdi
callq 0x10b0
movq 0x18(%rsp), %rdx
addq %rax, %rdx
leaq 0x2b64(%rip), %rsi      # 0x4130
movq 0x20(%rsp), %rdi
jmp 0x15db
movl (%rcx), %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1767
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x1bdd
testl %eax, %eax
je 0x1601
leaq 0xc29(%rip), %rdi       # 0x2221
movl %eax, %esi
xorl %eax, %eax
callq 0x1800
movl 0xc(%rsp), %eax
addq $0x2058, %rsp           # imm = 0x2058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rsi
leaq 0x9ff(%rip), %rdi       # 0x2020
xorl %eax, %eax
callq 0x1638
leaq 0xb29(%rip), %rdi       # 0x2158
movl %eax, %esi
xorl %eax, %eax
callq 0x1638