// File: dacunni[P]stlloader/stlcopy.cpp
// Function: main
int main(int argc, char ** argv)
{
    if(argc < 2) {
        std::cerr << "Please supply an input file\n";
        return EXIT_FAILURE;
    }
    if(argc < 3) {
        std::cerr << "Please supply an output file\n";
        return EXIT_FAILURE;
    }

    stlloader::Format format = stlloader::Format::ascii;
    if(argc > 3) {
        std::string format_arg(argv[3]);
        if(format_arg == "binary") format = stlloader::Format::binary;
        else if(format_arg == "ascii") format = stlloader::Format::ascii;
        else {
            std::cerr << "Unexpected output format: " << format_arg << '\n';
            return EXIT_FAILURE;
        }
    }

    stlloader::Mesh mesh;
    stlloader::parse_file(argv[1], mesh);
    stlloader::write_file(argv[2], mesh, format);

    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x4ede
movq 0x5122(%rip), %rdi      # 0x9fe8
leaq 0x21f8(%rip), %rsi      # 0x70c5
callq 0x3270
movl $0x1, -0x4(%rbp)
jmp 0x50d5
cmpl $0x3, -0x8(%rbp)
jge 0x4f03
movq 0x50fd(%rip), %rdi      # 0x9fe8
leaq 0x21f0(%rip), %rsi      # 0x70e2
callq 0x3270
movl $0x1, -0x4(%rbp)
jmp 0x50d5
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x8(%rbp)
jle 0x505d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3450
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x5290
jmp 0x4f4c
leaq -0x39(%rbp), %rdi
callq 0x32b0
leaq 0x21a4(%rip), %rsi      # 0x7100
leaq -0x38(%rbp), %rdi
callq 0x5230
movb %al, -0xb9(%rbp)
jmp 0x4f6d
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x4f79
jmp 0x4fb9
movl $0x1, -0x14(%rbp)
jmp 0x5040
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x32b0
jmp 0x50e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3190
jmp 0x50e1
leaq 0x2147(%rip), %rsi      # 0x7107
leaq -0x38(%rbp), %rdi
callq 0x5230
movb %al, -0xba(%rbp)
jmp 0x4fd1
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x4fdd
jmp 0x4fe6
movl $0x0, -0x14(%rbp)
jmp 0x503e
movq 0x4ffb(%rip), %rdi      # 0x9fe8
leaq 0x2119(%rip), %rsi      # 0x710d
callq 0x3270
movq %rax, -0xc8(%rbp)
jmp 0x5002
movq -0xc8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3260
movq %rax, -0xd0(%rbp)
jmp 0x501b
movq -0xd0(%rbp), %rdi
movl $0xa, %esi
callq 0x3300
jmp 0x502e
movl $0x1, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x5047
jmp 0x5040
movl $0x0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3190
movl -0x50(%rbp), %eax
testl %eax, %eax
je 0x505b
jmp 0x5059
jmp 0x50d5
jmp 0x505d
leaq -0xa8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x55a0
movq -0xd8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x44d0
jmp 0x5086
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x14(%rbp), %edx
leaq -0xa8(%rbp), %rsi
callq 0x4e10
jmp 0x509f
movl $0x0, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x55e0
jmp 0x50d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x55e0
jmp 0x50e1
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3440
nopw (%rax,%rax)