// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/translations.c
// Function: convertTransArgs
int * convertTransArgs(const char * passArguments) {
    char * workArguments, * parseArgument;
    int * retTranslations;
    int argIdx;
    int transCount, valid;

    // Check for help mode
    if (passArguments[0] == '?') {
        renderTranslations();
        exit(0);
    }

    // Copy arguments over to temporary area
    workArguments = calloc(strlen(passArguments)+1, 1);
    memcpy(workArguments, passArguments, strlen(passArguments)+1);

    // Count commas to calculate array size, and replace with NULLs for parsing
    for (argIdx = 0, transCount = 0 ; workArguments[argIdx] ; argIdx++) {
        if (workArguments[argIdx] == ',') {
            workArguments[argIdx] = 0;
            transCount++;
        }
    }

    transCount++;
    retTranslations = calloc(transCount+1, sizeof(int));

    // Parse arguments
    parseArgument = workArguments;
    valid = 1;

    for (argIdx = 0 ; argIdx < transCount ; argIdx++) {
        retTranslations[argIdx] = atoi(parseArgument); 
        parseArgument += strlen(parseArgument) + 1;

        // Check for valid translation ID
        if (retTranslations[argIdx] < 1 || retTranslations[argIdx] > TRANSLATION_COUNT) {
            valid = 0; break;
        }

        if (translationNames[retTranslations[argIdx] - 1][0] == 0) {
            valid = 0; break;
        }
    }

    // If invalid, only translate for standard genetic code
    if (!valid) {
        retTranslations[0] = 1;
        retTranslations[1] = 0;
    }

    return retTranslations;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0xa244
callq 0xa3e0
xorl %edi, %edi
callq 0x33b0
movq -0x8(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x31a0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30f0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x3250
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xa2de
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
jne 0xa2d1
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa2d3
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa29d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x31a0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xa3ad
movq -0x18(%rbp), %rdi
callq 0x3590
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rdi
callq 0x30f0
addq $0x1, %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
jl 0xa367
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x19, (%rax,%rcx,4)
jle 0xa370
movl $0x0, -0x2c(%rbp)
jmp 0xa3ad
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x36698(%rip), %rax     # 0x40a20
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa39d
movl $0x0, -0x2c(%rbp)
jmp 0xa3ad
jmp 0xa39f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa314
cmpl $0x0, -0x2c(%rbp)
jne 0xa3c8
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)