// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/CommandLines.cpp
// Function: get_hic_enzymes(char*, enzyme**, int)
void get_hic_enzymes(char *argv, enzyme** x, int check_name)
{
    int i, k, pre_i, len = strlen(argv);
    (*x) = (enzyme*)calloc(1, sizeof(enzyme));
    if(len == 0)
    {
        (*x)->n = 0; (*x)->l = NULL; (*x)->a = NULL;
        return;
    }


    (*x)->n = 1;
    for (i = pre_i = 0; i < len; i++)
    {
        if(argv[i] == ',')
        {
            (*x)->n++;
            continue;
        } 
        
        if(check_name)
        {
            if(argv[i] != 'A' && argv[i] != 'C' && argv[i] != 'G' && argv[i] != 'T' &&
                argv[i] != 'a' && argv[i] != 'c' && argv[i] != 'g' && argv[i] != 't' && 
                argv[i] != 'N' && argv[i] != 'n')
            {
                (*x)->n = 0;
                (*x)->l = NULL;
                (*x)->a = NULL;
                return;
            }
        }
        
    }
    (*x)->l = (int*)calloc((*x)->n, sizeof(int));
    (*x)->a = (char**)calloc((*x)->n, sizeof(char*));

    for (i = pre_i = k = 0; i < len; i++)
    {
        if(argv[i] == ',')
        {
            (*x)->l[k] = i - pre_i;
            (*x)->a[k] = (char*)malloc(sizeof(char)*((*x)->l[k]+1));
            memcpy((*x)->a[k], argv + pre_i, (*x)->l[k]);
            (*x)->a[k][(*x)->l[k]] = '\0';
            pre_i = i + 1;
            k++;
        }
    }

    (*x)->l[k] = i - pre_i;
    (*x)->a[k] = (char*)malloc(sizeof(char)*((*x)->l[k]+1));
    memcpy((*x)->a[k], argv + pre_i, (*x)->l[k]);
    (*x)->a[k][(*x)->l[k]] = '\0';
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
callq 0x2090
movq %rax, %r15
movl $0x1, %edi
movl $0x18, %esi
callq 0x2120
movq %rax, %r12
movq %rbx, 0x10(%rsp)
movq %rax, (%rbx)
testl %r15d, %r15d
je 0x31282
movl $0x1, 0x8(%r12)
movq 0x8(%rsp), %rbx
jle 0x311bf
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movabsq $0x8204500082045, %rdx  # imm = 0x8204500082045
movzbl (%rbx,%rcx), %esi
cmpl $0x2c, %esi
jne 0x3119d
incl 0x8(%r12)
jmp 0x311b7
testl %ebp, %ebp
je 0x311b7
addl $-0x41, %esi
cmpl $0x33, %esi
ja 0x31282
btq %rsi, %rdx
jae 0x31282
incq %rcx
cmpq %rcx, %rax
jne 0x3118d
movslq 0x8(%r12), %r13
movl $0x4, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%r12)
movl $0x8, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, 0x10(%r12)
testl %r15d, %r15d
jle 0x31298
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x10(%rsp), %r14
cmpb $0x2c, (%rbx,%r12)
jne 0x31275
movl %r12d, %eax
subl %ebp, %eax
movq %r15, %rbx
movq (%r14), %r15
movq (%r15), %rcx
movslq %r13d, %r13
movl %eax, (%rcx,%r13,4)
incl %eax
movslq %eax, %rdi
callq 0x2280
movq 0x10(%r15), %rcx
movq %rbx, %r15
movq 0x8(%rsp), %rbx
movq %rax, (%rcx,%r13,8)
movq (%r14), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
movq (%rax,%r13,8), %rdi
movslq %ebp, %rsi
addq %rbx, %rsi
movslq (%rcx,%r13,4), %rdx
callq 0x2160
movq (%r14), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
movq (%rax,%r13,8), %rax
movslq (%rcx,%r13,4), %rcx
movb $0x0, (%rax,%rcx)
incl %r13d
leal 0x1(%r12), %ebp
incq %r12
cmpq %r12, %r15
jne 0x31204
movslq %r13d, %r15
jmp 0x312a0
movl $0x0, 0x8(%r12)
xorl %eax, %eax
movq %rax, (%r12)
movq %rax, 0x10(%r12)
jmp 0x312fe
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r12d, %r12d
subl %ebp, %r12d
movq 0x10(%rsp), %rbx
movq (%rbx), %r13
movq (%r13), %rax
movl %r12d, (%rax,%r15,4)
incl %r12d
movslq %r12d, %rdi
callq 0x2280
movq 0x10(%r13), %rcx
movq %rax, (%rcx,%r15,8)
movq (%rbx), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
movq (%rax,%r15,8), %rdi
movslq %ebp, %rax
movq 0x8(%rsp), %rsi
addq %rax, %rsi
movslq (%rcx,%r15,4), %rdx
callq 0x2160
movq (%rbx), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
movq (%rax,%r15,8), %rax
movslq (%rcx,%r15,4), %rcx
movb $0x0, (%rax,%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq