// File: /workspace/github_c_makefile_star2_O0/hcmiya[P]opuscomment/src/read.c
// Function: open_output_file
void open_output_file(void) {
	if (O.edit == EDIT_LIST) {
		built_stream = fopen("/dev/null", "w");
		if (!built_stream) {
			fileerror(O.out);
		}
		remove_tmp = false;
		
		tag_output_to_file = O.tag_filename && strcmp(O.tag_filename, "-") != 0;
		if (tag_output_to_file) {
			FILE *tmp = freopen(O.tag_filename, "w", stdout);
			if (!tmp) {
				fileerror(O.tag_filename);
			}
		}
		
		tag_output = O.tag_deferred ? tmpfile() : stdout;
	}
	else if (O.out) {
		if (strcmp(O.out, "-") == 0) {
			built_stream = stdout;
		}
		else {
			built_stream = fopen(O.out, "w");
			if (!built_stream) {
				fileerror(O.out);
			}
		}
		remove_tmp = false;
	}
	else {
		if (input_is_regular_file) {
			char const *tmpl = "opuscomment.XXXXXX";
			outtmp = calloc(strlen(O.in) + strlen(tmpl) + 1, 1);
			char *p = strrchr(O.in, '/');
			if (p) {
				p++;
				strncpy(outtmp, O.in, p - O.in);
				strcpy(outtmp + (p - O.in), tmpl);
			}
			else {
				strcpy(outtmp, tmpl);
			}
			int fd = mkstemp(outtmp);
			if (fd == -1) {
				oserror();
			}
			remove_tmp = true;
			atexit(cleanup);
			built_stream = fdopen(fd, "w+");
		}
		else {
			built_stream = stdout;
		}
	}
	non_opus_stream = tmpfile();
	
	// スレッド間通信で使っているパイプがエラー後のexit内での始末にSIGPIPEを発するのでその対策
	atexit(exit_without_sigpipe);
	switch (O.edit) {
	case EDIT_WRITE:
	case EDIT_APPEND:
		// 編集入力タグパースを別スレッド化 parse_tags.c へ
		pthread_create(&parser_thread, NULL, parse_tags, NULL);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x18739(%rip), %rax     # 0x1d6c8
cmpl $0x1, (%rax)
jne 0x50a1
leaq 0x5131(%rip), %rdi      # 0xa0d0
leaq 0x5134(%rip), %rsi      # 0xa0da
callq 0x23e0
movq %rax, %rcx
leaq 0x1876b(%rip), %rax     # 0x1d720
movq %rcx, (%rax)
leaq 0x18761(%rip), %rax     # 0x1d720
cmpq $0x0, (%rax)
jne 0x4fd5
leaq 0x186fc(%rip), %rax     # 0x1d6c8
movq 0x30(%rax), %rdi
callq 0x8960
movb $0x0, 0x863c(%rip)      # 0xd618
xorl %eax, %eax
leaq 0x186e3(%rip), %rcx     # 0x1d6c8
cmpq $0x0, 0x18(%rcx)
movb %al, -0x1d(%rbp)
je 0x500f
leaq 0x186d2(%rip), %rax     # 0x1d6c8
movq 0x18(%rax), %rdi
leaq 0x503e(%rip), %rsi      # 0xa03f
callq 0x2270
cmpl $0x0, %eax
setne %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %cl
andb $0x1, %cl
leaq 0x18714(%rip), %rax     # 0x1d730
movb %cl, (%rax)
leaq 0x1870b(%rip), %rax     # 0x1d730
testb $0x1, (%rax)
je 0x5068
leaq 0x18697(%rip), %rax     # 0x1d6c8
movq 0x18(%rax), %rdi
movq 0x7f84(%rip), %rax      # 0xcfc0
movq (%rax), %rdx
leaq 0x5094(%rip), %rsi      # 0xa0da
callq 0x21c0
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x5066
leaq 0x1866b(%rip), %rax     # 0x1d6c8
movq 0x18(%rax), %rdi
callq 0x8960
jmp 0x5068
leaq 0x18659(%rip), %rax     # 0x1d6c8
testb $0x1, 0x20(%rax)
je 0x5080
callq 0x2260
movq %rax, -0x28(%rbp)
jmp 0x508e
movq 0x7f39(%rip), %rax      # 0xcfc0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
leaq 0x1868f(%rip), %rax     # 0x1d728
movq %rcx, (%rax)
jmp 0x5277
leaq 0x18620(%rip), %rax     # 0x1d6c8
cmpq $0x0, 0x30(%rax)
je 0x5134
leaq 0x1860e(%rip), %rax     # 0x1d6c8
movq 0x30(%rax), %rdi
leaq 0x4f7a(%rip), %rsi      # 0xa03f
callq 0x2270
cmpl $0x0, %eax
jne 0x50e5
movq 0x7eea(%rip), %rax      # 0xcfc0
movq (%rax), %rcx
leaq 0x18640(%rip), %rax     # 0x1d720
movq %rcx, (%rax)
jmp 0x5128
leaq 0x185dc(%rip), %rax     # 0x1d6c8
movq 0x30(%rax), %rdi
leaq 0x4fe3(%rip), %rsi      # 0xa0da
callq 0x23e0
movq %rax, %rcx
leaq 0x1861a(%rip), %rax     # 0x1d720
movq %rcx, (%rax)
leaq 0x18610(%rip), %rax     # 0x1d720
cmpq $0x0, (%rax)
jne 0x5126
leaq 0x185ab(%rip), %rax     # 0x1d6c8
movq 0x30(%rax), %rdi
callq 0x8960
jmp 0x5128
movb $0x0, 0x84e9(%rip)      # 0xd618
jmp 0x5275
leaq 0x185cd(%rip), %rax     # 0x1d708
testb $0x1, (%rax)
je 0x525f
leaq 0x4f91(%rip), %rax      # 0xa0dc
movq %rax, -0x10(%rbp)
leaq 0x18572(%rip), %rax     # 0x1d6c8
movq 0x28(%rax), %rdi
callq 0x2130
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2130
movq -0x30(%rbp), %rdi
addq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2250
movq %rax, 0x8488(%rip)      # 0xd610
leaq 0x18539(%rip), %rax     # 0x1d6c8
movq 0x28(%rax), %rdi
movl $0x2f, %esi
callq 0x2180
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5204
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq 0x8455(%rip), %rdi      # 0xd610
leaq 0x18506(%rip), %rax     # 0x1d6c8
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rdx
leaq 0x184f7(%rip), %rax     # 0x1d6c8
movq 0x28(%rax), %rax
subq %rax, %rdx
callq 0x2070
movq 0x842c(%rip), %rdi      # 0xd610
movq -0x18(%rbp), %rax
leaq 0x184d9(%rip), %rcx     # 0x1d6c8
movq 0x28(%rcx), %rcx
subq %rcx, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x2090
jmp 0x5214
movq 0x8405(%rip), %rdi      # 0xd610
movq -0x10(%rbp), %rsi
callq 0x2090
movq 0x83f5(%rip), %rdi      # 0xd610
callq 0x2330
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x522e
callq 0x8880
movb $0x1, 0x83e3(%rip)      # 0xd618
leaq 0x94(%rip), %rdi        # 0x52d0
callq 0x9630
movl -0x1c(%rbp), %edi
leaq 0x4ea4(%rip), %rsi      # 0xa0ef
callq 0x2360
movq %rax, %rcx
leaq 0x184c6(%rip), %rax     # 0x1d720
movq %rcx, (%rax)
jmp 0x5273
movq 0x7d5a(%rip), %rax      # 0xcfc0
movq (%rax), %rcx
leaq 0x184b0(%rip), %rax     # 0x1d720
movq %rcx, (%rax)
jmp 0x5275
jmp 0x5277
callq 0x2260
movq %rax, 0x839d(%rip)      # 0xd620
leaq 0x66(%rip), %rdi        # 0x52f0
callq 0x9630
leaq 0x18432(%rip), %rax     # 0x1d6c8
movl (%rax), %eax
addl $-0x2, %eax
subl $0x1, %eax
ja 0x52bc
jmp 0x52a2
leaq 0x1848f(%rip), %rdi     # 0x1d738
xorl %eax, %eax
movl %eax, %ecx
leaq -0x1c54(%rip), %rdx     # 0x3660
movq %rcx, %rsi
callq 0x23b0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)