// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/filedata.c
// Function: file_write
int file_write(const char *filename, struct databuf *dbuf)
{
    if (strncmp(filename, "-", 1) == 0)
    {
        dbuf_dump(dbuf);
        return 0;
    }

    switch (get_filetype(filename))
    {
        case FILETYPE_BINARY:
            return binfile_write(filename, dbuf);

        case FILETYPE_INTELHEX:
            return hexfile_write(filename, dbuf);

        default:
            return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
cmpb $0x2d, (%rdi)
jne 0x40ad
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movabsq $0x100000000, %r15      # imm = 0x100000000
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
cmpl 0x4(%rbx), %eax
jae 0x41d3
movq %rax, 0x18(%rsp)
movl %eax, %r13d
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %rbp
xorl %r12d, %r12d
xorl %r14d, %r14d
movslq %r14d, %rax
cmpq $0x10, %r12
je 0x3ff8
leaq (%r12,%r13), %rcx
movl 0x4(%rbx), %edx
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq %rdx, %rcx
jae 0x3fd1
movzbl (%rbp,%r12), %edx
leaq 0x4a8f(%rip), %rsi      # 0x8a57
xorl %eax, %eax
callq 0x2270
jmp 0x3fdd
movb $0x0, 0x2(%rdi)
movw $0x2020, (%rdi)         # imm = 0x2020
pushq $0x2
popq %rax
addl %r14d, %eax
testb $0x1, %r12b
je 0x3ff0
movslq %eax, %rcx
incl %eax
movb $0x20, 0x20(%rsp,%rcx)
incq %r12
movl %eax, %r14d
jmp 0x3f9e
movl 0x4(%rbx), %ecx
leaq (%rsp,%rax), %r12
addq $0x20, %r12
shlq $0x20, %rax
xorl %edi, %edi
pushq $0x1
popq %rdx
xorl %r14d, %r14d
pushq $0x2e
popq %r11
movq 0x18(%rsp), %rsi
cmpq $0x10, %rdi
je 0x4054
leaq (%rdi,%r13), %r9
movb $0x20, %r8b
cmpq %rcx, %r9
jae 0x4048
movzbl (%rbp,%rdi), %r9d
leal -0x20(%r9), %r10d
movl %r9d, %r8d
cmpb $0x5f, %r10b
jb 0x4040
movl %r11d, %r8d
cmpb $-0x1, %r9b
cmovnel %r14d, %edx
movb %r8b, (%r12,%rdi)
incq %rdi
addq %r15, %rax
jmp 0x4018
pushq $0x10
popq %rbp
testl %esi, %esi
je 0x4082
leal 0x10(%rsi), %ebp
cmpl %ecx, %ebp
jae 0x4082
testl %edx, %edx
je 0x4082
cmpl $0x0, 0xc(%rsp)
jne 0x40a6
leaq 0x4a55(%rip), %rdi      # 0x8ac9
callq 0x2080
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0x40a6
sarq $0x20, %rax
movb $0x0, 0x20(%rsp,%rax)
movl $0x0, 0xc(%rsp)
leaq 0x49c5(%rip), %rdi      # 0x8a5f
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x20f0
movl %ebp, %eax
jmp 0x3f7e
movq %rdi, %r15
callq 0x3bf4
pushq $-0x1
popq %r14
cmpl $0x2, %eax
je 0x410b
cmpl $0x1, %eax
jne 0x41d3
movq %r15, %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x41e8
movl %eax, %ebp
leaq 0x8(%rbx), %rsi
movl 0x4(%rbx), %edx
movl %eax, %edi
callq 0x2090
movl 0x4(%rbx), %ecx
cmpq %rcx, %rax
jne 0x41ff
movl %ebp, %edi
callq 0x2140
jmp 0x41d0
leaq 0x441c(%rip), %rsi      # 0x852e
movq %r15, %rdi
callq 0x2220
testq %rax, %rax
je 0x41f1
movq %rax, %r15
movl 0x4(%rbx), %eax
addq $0x8, %rbx
xorl %edx, %edx
movl %eax, %ecx
xorl %r12d, %r12d
cmpq %rdx, %rax
je 0x4159
cmpl %edx, %ecx
movl %edx, %esi
cmovbl %ecx, %esi
cmpl %edx, %r12d
movl %edx, %edi
cmoval %r12d, %edi
cmpb $-0x1, (%rbx,%rdx)
cmovnel %esi, %ecx
cmovnel %edi, %r12d
incq %rdx
jmp 0x4134
movl %ecx, %edx
andl $-0x10, %edx
xorl %r13d, %r13d
cmpl %r12d, %ecx
cmovael %eax, %r12d
cmovbl %edx, %r13d
addl $0xf, %r12d
andl $-0x10, %r12d
leaq 0x20(%rsp), %r14
movq %r13, %rbp
cmpq %r12, %rbp
jae 0x41aa
movb $0x10, 0x20(%rsp)
movw %bp, 0x22(%rsp)
movb $0x0, 0x24(%rsp)
leaq (%rbx,%rbp), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x4255
addq $0x10, %rbp
jmp 0x417c
leaq 0x20(%rsp), %rsi
movb $0x0, (%rsi)
movw %r13w, 0x2(%rsi)
movb $0x1, 0x4(%rsi)
andq $0x0, 0x8(%rsi)
movq %r15, %rdi
callq 0x4255
movq %r15, %rdi
callq 0x20a0
xorl %r14d, %r14d
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x487b(%rip), %rdi      # 0x8a6a
jmp 0x41f8
leaq 0x48a3(%rip), %rdi      # 0x8a9b
callq 0x2240
jmp 0x41d3
leaq 0x487c(%rip), %rdi      # 0x8a82
callq 0x2240
movl %ebp, %edi
callq 0x2140
jmp 0x41d3