// File: chhylp123[P]hifiasm/./POA.h
// Function: add_mismatchEdge_weight(Graph*, unsigned long, char, int)
inline void add_mismatchEdge_weight(Graph* g, uint64_t in_node, char base, int last_operation)
{
    long long i = 0;
    long long nodeID;
    Edge_alloc* edge = &(g->g_nodes.list[in_node].mismatch_edges);

    for (i = 0; i < (long long)edge->length; i++)
    {
        nodeID = edge->list[i].out_node;
        if(g->g_nodes.list[nodeID].base == base)
        {
            edge->list[i].weight++;
            ///if last operation is insertion
            if (last_operation == 2)
            {
                edge->list[i].num_insertions++;
            }
            
            break;
        }
    }

    ///there are no such edge
    if (i == (long long)edge->length)
    {
        nodeID  = add_Node_Graph(g, base);
        
        ///the length of match edge is 0, while the length of mismatch edge is 1
        append_Edge_alloc(edge, in_node, nodeID, 1, 1);
        ///if last operation is insertion
        if (last_operation == 2)
        {
            edge->list[edge->length - 1].num_insertions++;
        }

        ///add the mismatch_edges of new node to the backbone
        append_Edge_alloc(&(g->g_nodes.list[nodeID].mismatch_edges), nodeID, in_node + 1, 1, 0);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %ecx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x2ca9c
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x38, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movsbl 0x18(%rax), %eax
movsbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2ca89
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x38, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
cmpl $0x2, -0x18(%rbp)
jne 0x2ca87
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x38, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
jmp 0x2ca9c
jmp 0x2ca8b
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2ca03
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x2cb37
movq -0x8(%rbp), %rdi
movsbl -0x11(%rbp), %esi
callq 0x2c930
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x1, %r8d
movq %r8, %rcx
callq 0x2b990
cmpl $0x2, -0x18(%rbp)
jne 0x2cb05
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rax
shlq $0x7, %rax
addq %rax, %rdi
addq $0x20, %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x1, %rdx
movl $0x1, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x2b990
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)