// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x20a0
movl %eax, -0x24(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x521e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
jmp 0x5569
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x1, 0x8(%rax)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x5376
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
jne 0x526c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x5368
cmpl $0x0, -0x14(%rbp)
je 0x5366
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x43, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x47, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x54, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x61, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x63, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x67, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x74, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x4e, %eax
je 0x5364
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x6e, %eax
je 0x5364
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
jmp 0x5569
jmp 0x5366
jmp 0x5368
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x523a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x8(%rax), %rdi
movl $0x4, %esi
callq 0x2140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x8(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x54be
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
jne 0x54ae
movl -0x18(%rbp), %edx
subl -0x20(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
callq 0x2180
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movb $0x0, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x54b0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x53d0
movl -0x18(%rbp), %edx
subl -0x20(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
callq 0x2180
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movb $0x0, (%rax,%rcx)
addq $0x30, %rsp
popq %rbp
retq
nop