// File: /workspace/github_c_makefile_star2_O1/starius[P]dna-complement/dna-complement-int.c
// Function: main
int main(int argc, char** argv) {
    if (argc < 1 + 3) {
        fprintf(stderr, "Usage: %s table16g input output\n", argv[0]);
        return 1;
    }
    const char* table16g_fname = argv[1];
    int table16g_fd = open(table16g_fname, O_RDONLY);
    size_t table16g_size =
        (size_t)(256*256) * (size_t)(256*256) * sizeof(int);
    unsigned int* int_translate = mmap(
            0, // target address
            table16g_size, // size
            PROT_READ, // protection
            MAP_PRIVATE, // flags
            table16g_fd, // file descriptor
            0 // offset
            );
    if (!int_translate) {
        fprintf(stderr, "Can't mmap table16g\n");
        return 1;
    }
    const char* input_fname = argv[2];
    const char* output_fname = argv[3];
    FILE* input = fopen(input_fname, "rb");
    if (!input) {
        fprintf(stderr, "Can't open %s: %s\n",
                input_fname, strerror(errno));
        return 1;
    }
    FILE* output = fopen(output_fname, "wb");
    if (!output) {
        fprintf(stderr, "Can't open %s: %s\n",
                output_fname, strerror(errno));
        return 1;
    }
    char input_buffer[BUFSIZE];
    int* input_it;
    int* input_buffer_end = (int*)(input_buffer + BUFSIZE);
#ifdef SAME_BUFFER
# define output_buffer input_buffer
# define output_it input_it
#else
    char output_buffer[BUFSIZE];
    int* output_it;
#endif
    size_t nread;
    while (nread = fread(input_buffer, 1, BUFSIZE, input)) {
        for (input_it = (unsigned int*)input_buffer
#ifndef SAME_BUFFER
             , output_it = (unsigned int*)output_buffer
#endif
             ; input_it < input_buffer_end; input_it++
#ifndef SAME_BUFFER
             , output_it++
#endif
             )
        {
            *output_it = int_translate[*input_it];
        }
        fwrite(output_buffer, 1, nread, output);
    }
    fclose(input);
    fclose(output);
    munmap(int_translate, table16g_size);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x200008, %rsp         # imm = 0x200008
movq %rsi, %r15
cmpl $0x3, %edi
jle 0x13c0
movabsq $0x400000000, %rbx      # imm = 0x400000000
movq 0x8(%r15), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1090
movl $0x1, %ebp
xorl %edi, %edi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x2, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1060
testq %rax, %rax
je 0x13ca
movq %rax, %r14
movq 0x10(%r15), %r12
movq 0x18(%r15), %r13
leaq 0xd50(%rip), %rsi       # 0x203a
movq %r12, %rdi
callq 0x10a0
testq %rax, %rax
je 0x13d1
movq %rax, %r15
leaq 0xd4b(%rip), %rsi       # 0x2050
movq %r13, %rdi
callq 0x10a0
testq %rax, %rax
je 0x13db
movq %rax, %r12
movq %rsp, %rdi
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rcx
callq 0x1040
testq %rax, %rax
je 0x138f
leaq 0x100000(%rsp), %r13
movq %rsp, %rbp
movq $-0x4, %rcx
movslq 0x4(%rsp,%rcx), %rdx
movl (%r14,%rdx,4), %edx
movl %edx, 0x100004(%rsp,%rcx)
addq $0x4, %rcx
cmpq $0xffffc, %rcx          # imm = 0xFFFFC
jb 0x1345
movl $0x1, %esi
movq %r13, %rdi
movq %rax, %rdx
movq %r12, %rcx
callq 0x10b0
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbp, %rdi
movq %r15, %rcx
callq 0x1040
testq %rax, %rax
jne 0x133e
movq %r15, %rdi
callq 0x1050
movq %r12, %rdi
callq 0x1050
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1080
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x200008, %rsp         # imm = 0x200008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1172
jmp 0x13e3
callq 0x1156
jmp 0x13ac
movq %r12, %rdi
callq 0x111b
jmp 0x13e3
movq %r13, %rdi
callq 0x10e0
movl $0x1, %ebp
jmp 0x13ac