// File: /workspace/github_c_makefile_star2_O2/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, %r14
cmpl $0x3, %edi
jle 0x12f3
movabsq $0x400000000, %r15      # imm = 0x400000000
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1090
pushq $0x1
popq %rbx
pushq $0x2
popq %rcx
xorl %edi, %edi
movq %r15, %rsi
movl %ebx, %edx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1060
testq %rax, %rax
je 0x1313
movq %rax, %r15
movq 0x10(%r14), %r13
movq 0x18(%r14), %rbp
leaq 0xe07(%rip), %rsi       # 0x203a
movq %r13, %rdi
callq 0x10a0
testq %rax, %rax
je 0x1331
movq %rax, %r12
leaq 0xe02(%rip), %rsi       # 0x2050
movq %rbp, %rdi
callq 0x10a0
testq %rax, %rax
je 0x1356
movq %rax, %r13
leaq 0x100000(%rsp), %rbx
pushq $0x1
popq %rbp
movq %rsp, %r14
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rcx
callq 0x1040
testq %rax, %rax
je 0x12bb
xorl %ecx, %ecx
cmpq $0xfffff, %rcx          # imm = 0xFFFFF
ja 0x12a8
movslq 0x100000(%rsp,%rcx), %rdx
movl (%r15,%rdx,4), %edx
movl %edx, (%rsp,%rcx)
addq $0x4, %rcx
jmp 0x128a
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movq %r13, %rcx
callq 0x10b0
jmp 0x1270
movq %r12, %rdi
callq 0x1050
movq %r13, %rdi
callq 0x1050
movq %r15, %rdi
movabsq $0x400000000, %rsi      # imm = 0x400000000
callq 0x1080
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x200008, %rsp         # imm = 0x200008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2cfe(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0xcfd(%rip), %rsi       # 0x2004
xorl %eax, %eax
callq 0x1070
pushq $0x1
popq %rbx
jmp 0x12df
movq 0x2cde(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xd01(%rip), %rdi       # 0x2025
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
callq 0x10b0
jmp 0x12df
movq 0x2cc0(%rip), %rax      # 0x3ff8
movq (%rax), %r14
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xcef(%rip), %rsi       # 0x203d
movq %r14, %rdi
movq %r13, %rdx
jmp 0x1379
movq 0x2c9b(%rip), %rax      # 0x3ff8
movq (%rax), %r14
callq 0x1030
movl (%rax), %edi
callq 0x10c0
leaq 0xcca(%rip), %rsi       # 0x203d
movq %r14, %rdi
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1070
jmp 0x12df