// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movq %rsi, %rbx
cmpb $0x2d, (%rdi)
jne 0x4b19
cmpl $0x0, 0x4(%rbx)
je 0x4c4e
leaq 0x8(%rbx), %rax
movq %rax, 0x8(%rsp)
movabsq $0x100000000, %r12      # imm = 0x100000000
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
movl %r14d, %ebp
movq 0x8(%rsp), %rax
leaq (%rax,%rbp), %r13
xorl %r14d, %r14d
xorl %r15d, %r15d
leaq (%r14,%rbp), %rax
movl 0x4(%rbx), %ecx
movslq %r15d, %rdx
leaq (%rsp,%rdx), %rdi
addq $0x10, %rdi
cmpq %rcx, %rax
jae 0x4a2b
movzbl (%r13,%r14), %edx
leaq 0x4047(%rip), %rsi      # 0x8a69
xorl %eax, %eax
callq 0x2270
jmp 0x4a39
movb $0x0, 0x2(%rdi)
movw $0x2020, (%rdi)         # imm = 0x2020
movl $0x2, %eax
addl %eax, %r15d
testb $0x1, %r14b
je 0x4a4d
movslq %r15d, %rax
incl %r15d
movb $0x20, 0x10(%rsp,%rax)
incq %r14
cmpq $0x10, %r14
jne 0x49fe
movl 0x4(%rbx), %ecx
movslq %r15d, %rax
leaq (%rsp,%rax), %rsi
addq $0x10, %rsi
shlq $0x20, %rax
movl $0x1, %edx
xorl %edi, %edi
xorl %r11d, %r11d
leaq (%rdi,%rbp), %r9
movb $0x20, %r8b
cmpq %rcx, %r9
jae 0x4a9f
movzbl (%r13,%rdi), %r9d
leal -0x20(%r9), %r10d
movl %r9d, %r8d
cmpb $0x5f, %r10b
jb 0x4a97
movl $0x2e, %r8d
cmpb $-0x1, %r9b
cmovnel %r11d, %edx
movb %r8b, (%rsi,%rdi)
incq %rdi
addq %r12, %rax
cmpq $0x10, %rdi
jne 0x4a72
testq %rbp, %rbp
je 0x4ade
leal 0x10(%rbp), %r14d
cmpl %ecx, %r14d
jae 0x4ae4
testl %edx, %edx
je 0x4ae4
cmpl $0x0, 0x4(%rsp)
jne 0x4b0a
leaq 0x400c(%rip), %rdi      # 0x8adb
callq 0x2080
movl $0x1, 0x4(%rsp)
jmp 0x4b0a
movl $0x10, %r14d
sarq $0x20, %rax
movb $0x0, 0x10(%rsp,%rax)
movl $0x0, 0x4(%rsp)
leaq 0x3f75(%rip), %rdi      # 0x8a71
movl %ebp, %esi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x20f0
cmpl 0x4(%rbx), %r14d
jb 0x49ec
jmp 0x4c4e
movq %rdi, %r14
callq 0x47ff
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
je 0x4b7a
cmpl $0x1, %eax
jne 0x4c50
movq %r14, %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x4c64
movl %eax, %r14d
leaq 0x8(%rbx), %rsi
movl 0x4(%rbx), %edx
movl %eax, %edi
callq 0x2090
movl 0x4(%rbx), %ecx
cmpq %rcx, %rax
jne 0x4c7b
movl %r14d, %edi
callq 0x2140
jmp 0x4c4e
leaq 0x39ad(%rip), %rsi      # 0x852e
movq %r14, %rdi
callq 0x2220
testq %rax, %rax
je 0x4c6d
movq %rax, %r14
movl 0x4(%rbx), %ecx
xorl %ebp, %ebp
movl $0x0, %edx
movl $0x0, %eax
testq %rcx, %rcx
je 0x4bd3
xorl %esi, %esi
xorl %eax, %eax
movl %ecx, %edx
cmpl %esi, %edx
movl %esi, %edi
cmovbl %edx, %edi
cmpl %esi, %eax
movl %esi, %r8d
cmoval %eax, %r8d
cmpb $-0x1, 0x8(%rbx,%rsi)
cmovnel %edi, %edx
cmovnel %r8d, %eax
incq %rsi
cmpq %rsi, %rcx
jne 0x4baf
movl %edx, %esi
andl $-0x10, %esi
cmpl %eax, %edx
cmovael %ecx, %eax
cmovbl %esi, %ebp
addl $0xf, %eax
andl $-0x10, %eax
cmpl %eax, %ebp
jae 0x4c26
addq $0x8, %rbx
movl %ebp, %r12d
movl %eax, %r13d
leaq 0x10(%rsp), %r15
movb $0x10, 0x10(%rsp)
movw %r12w, 0x12(%rsp)
movb $0x0, 0x14(%rsp)
leaq (%rbx,%r12), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4f76
addq $0x10, %r12
cmpq %r13, %r12
jb 0x4bf9
leaq 0x10(%rsp), %rsi
movb $0x0, (%rsi)
movw %bp, 0x2(%rsi)
movb $0x1, 0x4(%rsi)
movq $0x0, 0x8(%rsi)
movq %r14, %rdi
callq 0x4f76
movq %r14, %rdi
callq 0x20a0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e11(%rip), %rdi      # 0x8a7c
jmp 0x4c74
leaq 0x3e39(%rip), %rdi      # 0x8aad
callq 0x2240
jmp 0x4c50
leaq 0x3e12(%rip), %rdi      # 0x8a94
callq 0x2240
movl %r14d, %edi
callq 0x2140
jmp 0x4c50