// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/main.c
// Function: add_log_dest
static int add_log_dest(const char *progname, struct logger *log,
	const char *arg)
{
	FILE *dest;
	bool do_free = false;
	const char *eq = strchr(arg, '='); // Pointer to equals sign.
	if (eq) {
		const char *fname = eq + 1;
		if (*fname) {
			// Open the file to append so FILEs to the same physical
			// file work out as expected (hopefully.)
			if (!(dest = fopen(fname, "w")) // Clear the file.
			 || !(dest = freopen(fname, "a+", dest))) {
				fprintf(stderr,
					"%s: Error opening log file %s: %s\n",
					progname, fname, strerror(errno));
				return -1;
			}
			do_free = true;
		} else {
			dest = stderr;
		}
	} else {
		fprintf(stderr,
			"%s: No log level destination given; use -l%s=...\n",
			progname, arg);
		return -1;
	}
	int which;
	size_t name_size = eq - arg;
	if (!strncasecmp("all=", arg, name_size + 1)) {
		which = LOGGER_ALL;
	} else if (!strncasecmp("info=", arg, name_size + 1)) {
		which = LOGGER_INFO;
	} else if (!strncasecmp("warning=", arg, name_size + 1)) {
		which = LOGGER_WARNING;
	} else if (!strncasecmp("error=", arg, name_size + 1)) {
		which = LOGGER_ERROR;
	} else {
		fprintf(stderr, "%s: Invalid log name: %.*s\n",
			progname, (int)name_size, arg);
		return -1;
	}
	close_old_file(log, which);
	logger_set_output(log, which, dest, do_free);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movb $0x0, -0x29(%rbp)
movq -0x20(%rbp), %rdi
movl $0x3d, %esi
callq 0x22c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xaa9f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpb $0x0, (%rax)
je 0xaa8f
movq -0x40(%rbp), %rdi
leaq 0x67d2(%rip), %rsi      # 0x111db
callq 0x2160
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xaa36
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x7391(%rip), %rsi      # 0x11db8
callq 0x2400
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xaa89
movq 0xb5ab(%rip), %rax      # 0x15fe8
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x2320
movl (%rax), %edi
callq 0x2260
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq %rax, %r8
leaq 0x7345(%rip), %rsi      # 0x11dbb
movb $0x0, %al
callq 0x24c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xabd5
movb $0x1, -0x29(%rbp)
jmp 0xaa9d
movq 0xb552(%rip), %rax      # 0x15fe8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xaacb
movq 0xb542(%rip), %rax      # 0x15fe8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x7326(%rip), %rsi      # 0x11dde
movb $0x0, %al
callq 0x24c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xabd5
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x1, %rdx
leaq 0x7323(%rip), %rdi      # 0x11e10
callq 0x2350
cmpl $0x0, %eax
jne 0xab03
movl $0x7, -0x44(%rbp)
jmp 0xabaa
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x1, %rdx
leaq 0x72ff(%rip), %rdi      # 0x11e15
callq 0x2350
cmpl $0x0, %eax
jne 0xab29
movl $0x1, -0x44(%rbp)
jmp 0xaba8
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x1, %rdx
leaq 0x72df(%rip), %rdi      # 0x11e1b
callq 0x2350
cmpl $0x0, %eax
jne 0xab4f
movl $0x2, -0x44(%rbp)
jmp 0xaba6
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x1, %rdx
leaq 0x72c2(%rip), %rdi      # 0x11e24
callq 0x2350
cmpl $0x0, %eax
jne 0xab75
movl $0x4, -0x44(%rbp)
jmp 0xaba4
movq 0xb46c(%rip), %rax      # 0x15fe8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %r8
leaq 0x7297(%rip), %rsi      # 0x11e2b
movb $0x0, %al
callq 0x24c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xabd5
jmp 0xaba6
jmp 0xaba8
jmp 0xabaa
movq -0x18(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xad70
movq -0x18(%rbp), %rdi
movl -0x44(%rbp), %esi
movq -0x28(%rbp), %rdx
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xa150
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop