// File: /workspace/github_c_makefile_star2_O0/mloar[P]charset/fromucs.c
// Function: charset_from_unicode
int charset_from_unicode(const wchar_t **input, int *inlen,
			 char *output, int outlen,
			 int charset, charset_state *state, int *error)
{
    charset_spec const *spec = charset_find_spec(charset);
    charset_state localstate = CHARSET_INIT_STATE;
    struct charset_emit_param param;
    int locallen;

    if (!input) {
	locallen = 1;
	inlen = &locallen;
    }

    param.output = output;
    param.outlen = outlen;
    param.writtenlen = 0;
    param.stopped = 0;

    if (state)
	localstate = *state;	       /* structure copy */
    if (error)
	*error = FALSE;

    while (*inlen > 0) {
	int lenbefore = param.writtenlen;
	int ret;

	if (input)
	    ret = spec->write(spec, **input, &localstate,
			      charset_emit, &param);
	else
	    ret = spec->write(spec, -1, &localstate, charset_emit, &param);
	if (error && !ret) {
	    /*
	     * We have hit a difficult character, which the user
	     * wants to know about. Leave now.
	     */
	    *error = TRUE;
	    return lenbefore;
	}
	if (param.stopped) {
	    /*
	     * The emit function has _tried_ to output some
	     * characters, but ran up against the end of the
	     * buffer. Leave immediately, and return what happened
	     * _before_ attempting to process this character.
	     */
	    return lenbefore;
	}
	if (state)
	    *state = localstate;       /* structure copy */
	if (input)
	    (*input)++;
	(*inlen)--;
    }
    return param.writtenlen;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl -0x28(%rbp), %edi
callq 0x6e50
movq %rax, -0x38(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x6060
cmpq $0x0, -0x10(%rbp)
jne 0x68f5
movl $0x1, -0x64(%rbp)
leaq -0x64(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x692b
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x693c
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x693e
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x6a17
movl -0x54(%rbp), %eax
movl %eax, -0x68(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x6984
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq (%rcx), %rsi
leaq -0x48(%rbp), %rdx
leaq 0xb7(%rip), %rcx        # 0x6a30
leaq -0x60(%rbp), %r8
callq *%rax
movl %eax, -0x6c(%rbp)
jmp 0x69ab
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rdi
movq $-0x1, %rsi
leaq -0x48(%rbp), %rdx
leaq 0x8e(%rip), %rcx        # 0x6a30
leaq -0x60(%rbp), %r8
callq *%rax
movl %eax, -0x6c(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x69ca
cmpl $0x0, -0x6c(%rbp)
jne 0x69ca
movq 0x10(%rbp), %rax
movl $0x1, (%rax)
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6a1d
cmpl $0x0, -0x50(%rbp)
je 0x69d8
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6a1d
cmpq $0x0, -0x30(%rbp)
je 0x69f2
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x6a07
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
jmp 0x693e
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)