// File: /workspace/github_c_makefile_star2_O3/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 $0x2048, %rsp           # imm = 0x2048
movq %rsi, %r14
movl $0x1, 0x4(%rsp)
cmpl $0x5, %edi
jl 0x175c
movl %edi, %ebp
movq 0x18(%r14), %rdi
cmpb $0x2d, (%rdi)
jne 0x1448
cmpb $0x2d, 0x1(%rdi)
jne 0x1448
cmpb $0x0, 0x2(%rdi)
je 0x145c
leaq 0xbcd(%rip), %rsi       # 0x201c
callq 0x1130
testl %eax, %eax
jne 0x175c
movq 0x10(%r14), %rbx
leaq 0x18(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
movq %rbx, %rsi
movl $0x1, %ecx
callq 0x1b38
testl %eax, %eax
jne 0x176d
leaq 0xcf0(%rip), %rdx       # 0x2176
leaq 0x1040(%rsp), %r15
movl $0x1008, %esi           # imm = 0x1008
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10e0
movq %r15, %rdi
callq 0x1120
movq 0x2b29(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
callq 0x1170
movq 0x8(%r14), %rax
movq 0x18(%rsp), %r12
movb (%rax), %cl
testb %cl, %cl
je 0x14db
incq %rax
movzbl %cl, %ecx
movb $0x1, 0x4(%r12,%rcx)
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x14c9
leaq 0x20(%r14), %r15
addl $-0x4, %ebp
cmpb $0x0, 0x7a(%r12)
je 0x14f4
movl %ebp, %edi
movq %r15, %rsi
callq 0x1a43
movb 0x69(%r12), %r12b
leaq 0x4(%rsp), %rdx
movl %ebp, %edi
movq %r15, %rsi
callq 0x1a53
decl %eax
cmpl $0x5, %eax
ja 0x15b9
leaq 0xaea(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testb %r12b, %r12b
je 0x1723
leaq 0xc4f(%rip), %rdx       # 0x2182
jmp 0x15a8
testb %r12b, %r12b
je 0x1723
leaq 0xca1(%rip), %rdx       # 0x21e6
jmp 0x15a8
testb %r12b, %r12b
je 0x1723
movl 0x4(%rsp), %ecx
leaq 0xc4d(%rip), %rdx       # 0x21a8
jmp 0x1587
testb %r12b, %r12b
je 0x1723
movl 0x4(%rsp), %ecx
leaq 0xc4c(%rip), %rdx       # 0x21bd
jmp 0x1587
testb %r12b, %r12b
je 0x1723
movl 0x4(%rsp), %ecx
leaq 0xc0b(%rip), %rdx       # 0x2192
movl %ebp, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x180e
jmp 0x1723
testb %r12b, %r12b
je 0x1723
leaq 0xc29(%rip), %rdx       # 0x21d1
movl %ebp, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x180e
jmp 0x1723
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
setne %al
testb %r12b, %r12b
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x15e2
leaq 0xc2f(%rip), %rdx       # 0x2205
movl %ebp, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x180e
movq 0x18(%r14), %rdi
leaq 0xa2f(%rip), %rsi       # 0x201c
callq 0x1130
movq 0x18(%rsp), %rcx
leaq 0x104(%rcx), %r12
testl %eax, %eax
je 0x16d6
movq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
testq %rax, %rax
je 0x16ea
movq %rax, %rcx
subq %r12, %rcx
leaq 0x2b07(%rip), %rdx      # 0x4130
movq %rdx, 0x8(%rsp)
leaq 0xc25(%rip), %r13       # 0x225a
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r14, 0x10(%rsp)
movq %r13, %r14
movq %r12, %r13
movq %rcx, %r15
movq %rax, %r12
cmpq %rbp, %r15
jne 0x1688
movq %r13, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x1040
testl %eax, %eax
jne 0x1685
movq %r12, %r13
incq %r13
movq %r13, %rdi
movl $0xa, %esi
callq 0x10d0
movq %rax, %r12
movq %rax, %r15
subq %r13, %r15
testq %rax, %rax
jne 0x164b
jmp 0x16e0
movq %rbp, %r15
leaq 0x1(%r15), %rdx
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x1150
movq 0x10(%rsp), %r14
addq %r15, %r14
incq %r14
addq %r15, %rbp
incq %rbp
movq %rbp, 0x8(%rsp)
incq %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movq %rax, %rcx
subq %r12, %rcx
movq %r15, %rbp
testq %rax, %rax
jne 0x163a
jmp 0x16f9
movl (%rcx), %edx
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x171e
movq %r13, %r12
movq 0x10(%rsp), %r14
jmp 0x16f9
leaq 0x2a3f(%rip), %rax      # 0x4130
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x1060
movq %r12, %rdi
callq 0x10b0
addq %rax, %r14
leaq 0x2a18(%rip), %rsi      # 0x4130
movq %rbx, %rdi
movq %r14, %rdx
callq 0x18ae
leaq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x1c72
testl %eax, %eax
je 0x1746
leaq 0xae4(%rip), %rdi       # 0x2221
movl %eax, %esi
xorl %eax, %eax
callq 0x1949
movl 0x4(%rsp), %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
leaq 0x8ba(%rip), %rdi       # 0x2020
xorl %eax, %eax
callq 0x177d
leaq 0x9e4(%rip), %rdi       # 0x2158
movl %eax, %esi
xorl %eax, %eax
callq 0x177d