// File: /workspace/github_c_makefile_star2_O0/hcmiya[P]opuscomment/src/parse-tags.c
// Function: toutf8
static void toutf8(int fdu8) {
	size_t const buflen = STACK_BUF_LEN / 2;
	char ubuf[STACK_BUF_LEN];
	char *lbuf = ubuf + buflen;
	
	iconv_t cd = iconv_new("UTF-8", O.tag_raw ? "UTF-8" : nl_langinfo(CODESET));
	size_t readlen, remain, total;
	remain = 0; total = 0;
	while ((readlen = fread(&lbuf[remain], 1, buflen - remain, edit_input)) != 0) {
		total += readlen;
		if (total > TAG_LENGTH_LIMIT__INPUT) {
			mainerror(err_main_long_input);
		}
		if (O.tag_escape != TAG_ESCAPE_NUL && strnlen(&lbuf[remain], readlen) != readlen) {
			err_bin();
		}
		size_t llen = readlen + remain;
		remain = llen;
		for (;;) {
			size_t ulen = buflen;
			char *lp = lbuf, *up = ubuf;
			size_t iconvret = iconv(cd, &lp, &remain, &up, &ulen);
			int ie = errno;
			if (iconvret == (size_t)-1) {
				switch (ie) {
				case EILSEQ:
					oserror();
					break;
				case EINVAL:
				case E2BIG:
					break;
				}
				memcpy(lbuf, lp, remain);
			}
			write(fdu8, ubuf, up - ubuf);
			if (iconvret != (size_t)-1 || ie == EINVAL) break;
		}
	}
	if (fclose(edit_input) == EOF) {
		readerror();
	}
	if (remain) {
		errno = EILSEQ;
		readerror();
	}
	char *up = ubuf; readlen = buflen;
	remain = iconv(cd, NULL, NULL, &up, &readlen);
	if (remain == (size_t)-1) oserror();
	iconv_close(cd);
	write(fdu8, ubuf, up - ubuf);
	close(fdu8);
	if (O.edit == EDIT_WRITE && !total && O.tag_deferred) {
		mainerror(err_main_no_input);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1080, %rsp           # imm = 0x1080
movl %edi, -0x4(%rbp)
movq $0x800, -0x10(%rbp)     # imm = 0x800
leaq -0x1010(%rbp), %rax
addq $0x800, %rax            # imm = 0x800
movq %rax, -0x1018(%rbp)
leaq 0x19eb7(%rip), %rax     # 0x1d6c8
testb $0x1, 0x15(%rax)
je 0x3827
leaq 0x67e6(%rip), %rax      # 0xa004
movq %rax, -0x1078(%rbp)
jmp 0x3838
movl $0xe, %edi
callq 0x2320
movq %rax, -0x1078(%rbp)
movq -0x1078(%rbp), %rsi
leaq 0x67be(%rip), %rdi      # 0xa004
callq 0x2a50
movq %rax, -0x1020(%rbp)
movq $0x0, -0x1030(%rbp)
movq $0x0, -0x1038(%rbp)
movq -0x1018(%rbp), %rdi
addq -0x1030(%rbp), %rdi
movl $0x800, %edx            # imm = 0x800
subq -0x1030(%rbp), %rdx
movq 0x9d1f(%rip), %rcx      # 0xd5a8
movl $0x1, %esi
callq 0x20e0
movq %rax, -0x1028(%rbp)
cmpq $0x0, %rax
je 0x3a26
movq -0x1028(%rbp), %rax
addq -0x1038(%rbp), %rax
movq %rax, -0x1038(%rbp)
cmpq $0x7800000, -0x1038(%rbp) # imm = 0x7800000
jbe 0x38d2
movl $0xb, %edi
movb $0x0, %al
callq 0x8570
leaq 0x19def(%rip), %rax     # 0x1d6c8
cmpl $0x2, 0x10(%rax)
je 0x3907
movq -0x1018(%rbp), %rdi
addq -0x1030(%rbp), %rdi
movq -0x1028(%rbp), %rsi
callq 0x21d0
cmpq -0x1028(%rbp), %rax
je 0x3907
callq 0x3420
movq -0x1028(%rbp), %rax
addq -0x1030(%rbp), %rax
movq %rax, -0x1040(%rbp)
movq -0x1040(%rbp), %rax
movq %rax, -0x1030(%rbp)
movq $0x800, -0x1048(%rbp) # imm = 0x800
movq -0x1018(%rbp), %rax
movq %rax, -0x1050(%rbp)
leaq -0x1010(%rbp), %rax
movq %rax, -0x1058(%rbp)
movq -0x1020(%rbp), %rdi
leaq -0x1050(%rbp), %rsi
leaq -0x1030(%rbp), %rdx
leaq -0x1058(%rbp), %rcx
leaq -0x1048(%rbp), %r8
callq 0x20b0
movq %rax, -0x1060(%rbp)
callq 0x2050
movl (%rax), %eax
movl %eax, -0x1064(%rbp)
cmpq $-0x1, -0x1060(%rbp)
jne 0x39e7
movl -0x1064(%rbp), %eax
movl %eax, -0x107c(%rbp)
subl $0x7, %eax
je 0x39cb
jmp 0x39aa
movl -0x107c(%rbp), %eax
subl $0x16, %eax
je 0x39cb
jmp 0x39b7
movl -0x107c(%rbp), %eax
subl $0x54, %eax
jne 0x39cd
jmp 0x39c4
callq 0x8880
jmp 0x39cd
jmp 0x39cd
movq -0x1018(%rbp), %rdi
movq -0x1050(%rbp), %rsi
movq -0x1030(%rbp), %rdx
callq 0x22d0
movl -0x4(%rbp), %edi
leaq -0x1010(%rbp), %rsi
movq -0x1058(%rbp), %rdx
leaq -0x1010(%rbp), %rax
subq %rax, %rdx
callq 0x2100
cmpq $-0x1, -0x1060(%rbp)
jne 0x3a1a
cmpl $0x16, -0x1064(%rbp)
jne 0x3a1c
jmp 0x3a21
jmp 0x392a
jmp 0x3868
movq 0x9b7b(%rip), %rdi      # 0xd5a8
callq 0x2120
cmpl $-0x1, %eax
jne 0x3a3c
callq 0x4720
cmpq $0x0, -0x1030(%rbp)
je 0x3a56
callq 0x2050
movl $0x54, (%rax)
callq 0x4720
leaq -0x1010(%rbp), %rax
movq %rax, -0x1070(%rbp)
movq $0x800, -0x1028(%rbp) # imm = 0x800
movq -0x1020(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x1070(%rbp), %rcx
leaq -0x1028(%rbp), %r8
movq %rdx, %rsi
callq 0x20b0
movq %rax, -0x1030(%rbp)
cmpq $-0x1, -0x1030(%rbp)
jne 0x3aa6
callq 0x8880
movq -0x1020(%rbp), %rdi
callq 0x2390
movl -0x4(%rbp), %edi
leaq -0x1010(%rbp), %rsi
movq -0x1070(%rbp), %rdx
leaq -0x1010(%rbp), %rax
subq %rax, %rdx
callq 0x2100
movl -0x4(%rbp), %edi
callq 0x21e0
leaq 0x19be7(%rip), %rax     # 0x1d6c8
cmpl $0x2, (%rax)
jne 0x3b09
cmpq $0x0, -0x1038(%rbp)
jne 0x3b09
leaq 0x19bd1(%rip), %rax     # 0x1d6c8
testb $0x1, 0x20(%rax)
je 0x3b09
movl $0xc, %edi
movb $0x0, %al
callq 0x8570
addq $0x1080, %rsp           # imm = 0x1080
popq %rbp
retq
nopw %cs:(%rax,%rax)