// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: ma_ug_hybrid_gen(usg_t*)
ma_ug_t *ma_ug_hybrid_gen(usg_t *g)
{
    int32_t *mark; uint32_t i, v, n_vtx = g->n<<1;
    uint32_t w, x, l, start, end, len; ma_utg_t *p;
    kdq_t(uint64_t) *q; ///is a queue
    ma_ug_t *ug;

    ug = (ma_ug_t*)calloc(1, sizeof(ma_ug_t));
    ug->g = asg_init();
    ///each node has two directions
    mark = (int32_t*)calloc(n_vtx, 4);

    q = kdq_init(uint64_t);
    for (v = 0; v < n_vtx; ++v) {
        // fprintf(stderr, "+[M::%s::] v::%u, n_vtx::%u\n", __func__, v, n_vtx);
        if (g->a[v>>1].del || mark[v]) continue;
        if (usg_arc_n(g, v) == 0 && usg_arc_n(g, (v^1)) != 0) continue;
        // fprintf(stderr, "-[M::%s::] v::%u, n_vtx::%u\n", __func__, v, n_vtx);
        mark[v] = 1; q->count = 0, start = v, end = v^1, len = 0;
        // forward
        w = v;
        while (1) {
            /**
             * w----->x
             * w<-----x
             * that means the only suffix of w is x, and the only prefix of x is w
             **/
            if (usg_arc_n(g, w) != 1) break;
            x = usg_arc_a(g, w)[0].v; // w->x
            if (usg_arc_n(g, x^1) != 1) break;

            /**
             * another direction of w would be marked as used (since w has been used)
            **/
            mark[x] = mark[w^1] = 1;
            ///l is the edge length, instead of overlap length
            ///note: edge length is different with overlap length
            l = asg_arc_len(usg_arc_a(g, w)[0]);
            kdq_push(uint64_t, q, (uint64_t)w<<32 | l);
            end = x^1, len += l;
            w = x;
            if (x == v) break;
        }
        if (start != (end^1) || kdq_size(q) == 0) { // linear unitig
            ///length of seq, instead of edge
            l = g->a[end>>1].len;
            kdq_push(uint64_t, q, (uint64_t)(end^1)<<32 | l);
            len += l;
        } else { // circular unitig
            start = end = UINT32_MAX;
            goto add_usg_unitig; // then it is not necessary to do the backward
        }

        // backward
        x = v;
        while (1) { // similar to forward but not the same
            if (usg_arc_n(g, x^1) != 1) break;
            w = usg_arc_a(g, x^1)[0].v ^ 1; // w->x
            if (usg_arc_n(g, w) != 1) break;
            mark[x] = mark[w^1] = 1;
            l = asg_arc_len(usg_arc_a(g, w)[0]);
            ///w is the seq id + direction, l is the length of edge
            ///push element to the front of a queue
            kdq_unshift(uint64_t, q, (uint64_t)w<<32 | l);

            // fprintf(stderr, "uId: %u, >%.*s (%u)\n", 
            // ug->u.n, (int)Get_NAME_LENGTH((R_INF), w>>1), Get_NAME((R_INF), w>>1), w>>1);

            start = w, len += l;
            x = w;
        }

        add_usg_unitig:
        if (start != UINT32_MAX) mark[start] = mark[end] = 1;
        kv_pushp(ma_utg_t, ug->u, &p);
        p->s = 0, p->start = start, p->end = end, p->len = len, p->n = kdq_size(q), p->circ = (start == UINT32_MAX);
        p->m = p->n;
        kv_roundup32(p->m);
        p->a = (uint64_t*)malloc(8 * p->m);
        //all elements are saved here
        for (i = 0; i < kdq_size(q); ++i)
            p->a[i] = kdq_at(q, i);
        // fprintf(stderr, "*[M::%s::] v::%u, n_vtx::%u\n", __func__, v, n_vtx);
    }
    kdq_destroy(uint64_t, q);
    // fprintf(stderr, "-1-[M::%s::] **************\n", __func__);
    // add arcs between unitigs; reusing mark for a different purpose
    //ug saves all unitigs
    for (v = 0; v < n_vtx; ++v) mark[v] = -1;
    // fprintf(stderr, "-2-[M::%s::] **************\n", __func__);

    //mark all start nodes and end nodes of all unitigs
    for (i = 0; i < ug->u.n; ++i) {
        if (ug->u.a[i].circ) continue;
        mark[ug->u.a[i].start] = i<<1 | 0;
        mark[ug->u.a[i].end] = i<<1 | 1;
    }
    // fprintf(stderr, "-3-[M::%s::] **************\n", __func__);
    //scan all edges
    usg_arc_t *av; uint32_t nv;
    for (v = 0; v < n_vtx; v++) {
        av = usg_arc_a(g, v); nv = usg_arc_n(g, v);
        for (i = 0; i < nv; i++) {
            if(av[i].del) continue;
            if (mark[av[i].ul>>32^1] >= 0 && mark[av[i].v] >= 0) {
                uint32_t u = mark[(av[i].ul>>32)^1]^1;
                int l = ug->u.a[u>>1].len - av[i].ol;
                if (l < 0) l = 1;
                asg_arc_t *q = asg_arc_pushp(ug->g);
                q->ol = av[i].ol, q->del = 0;
                q->ul = (uint64_t)u<<32 | l;
                q->v = mark[av[i].v]; q->ou = 0;
            }
        }
    }
    // fprintf(stderr, "-4-[M::%s::] **************\n", __func__);
    for (i = 0; i < ug->u.n; ++i)
        asg_seq_set(ug->g, i, ug->u.a[i].len, 0);
    // fprintf(stderr, "-5-[M::%s::] **************\n", __func__);
    asg_cleanup(ug->g);
    free(mark);
    return ug;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movl %eax, -0x1c(%rbp)
movl $0x1, %edi
movl $0x38, %esi
callq 0x2140
movq %rax, -0x50(%rbp)
callq 0xcd150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2140
movq %rax, -0x10(%rbp)
callq 0x35a5e0
movq %rax, -0x48(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x35a2a6
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x70(%rax)
jne 0x359d07
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x359d0c
jmp 0x35a298
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x18(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x359d73
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x18(%rbp), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x359d73
jmp 0x35a298
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
movq $0x0, 0x8(%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x18(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x1, (%rax)
je 0x359ddc
jmp 0x359ed9
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x1, (%rax)
je 0x359e47
jmp 0x359ed9
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl %eax, -0x28(%rbp)
movq -0x48(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
shlq $0x20, %rsi
movl -0x28(%rbp), %eax
orq %rax, %rsi
callq 0x35a680
movl -0x24(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0x359ed4
jmp 0x359ed9
jmp 0x359da9
movl -0x2c(%rbp), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x359ef1
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x359f34
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %eax
xorl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x20, %rsi
movl -0x28(%rbp), %eax
orq %rax, %rsi
callq 0x35a680
movl -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x359f47
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x35a07b
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x1, (%rax)
je 0x359f86
jmp 0x35a079
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x24(%rbp), %ecx
xorl $0x1, %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x1, (%rax)
je 0x359ff4
jmp 0x35a079
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl %eax, -0x28(%rbp)
movq -0x48(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %esi
shlq $0x20, %rsi
movl -0x28(%rbp), %eax
orq %rax, %rsi
callq 0x35a720
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x359f4d
jmp 0x35a07b
cmpl $-0x1, -0x2c(%rbp)
je 0x35a09d
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
jmp 0x35a09f
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x35a104
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x35a0cc
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x78(%rbp)
jmp 0x35a0d7
movl $0x2, %eax
movq %rax, -0x78(%rbp)
jmp 0x35a0d7
movq -0x78(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
imulq $0x28, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x34(%rbp), %edx
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
cmpl $-0x1, -0x2c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %edx
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
shrl %ecx
movq -0x40(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
shrl $0x2, %ecx
movq -0x40(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
shrl $0x4, %ecx
movq -0x40(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
shrl $0x8, %ecx
movq -0x40(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
shrl $0x10, %ecx
movq -0x40(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
shll $0x3, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x2270
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x35a296
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rdx
movabsq $0x3ffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFF
andq (%rdx), %rcx
movl -0x14(%rbp), %edx
addq %rdx, %rcx
movq -0x48(%rbp), %rdx
andq 0x10(%rdx), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x14(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x35a244
jmp 0x35a298
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x359cd3
movq -0x48(%rbp), %rdi
callq 0x35a750
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x35a2d7
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x35a2b6
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x35a35b
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x35a308
jmp 0x35a350
movl -0x14(%rbp), %edx
shll %edx
orl $0x0, %edx
movq -0x10(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x14(%rbp), %esi
imulq $0x28, %rsi, %rsi
addq %rsi, %rcx
movl 0x4(%rcx), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %edx
shll %edx
orl $0x1, %edx
movq -0x10(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x14(%rbp), %esi
imulq $0x28, %rsi, %rsi
addq %rsi, %rcx
movl 0x8(%rcx), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x35a2de
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x35a56d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x18(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x18(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jae 0x35a55d
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x35a3fd
jmp 0x35a54f
movq -0x10(%rbp), %rax
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
xorq $0x1, %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x35a54d
movq -0x10(%rbp), %rax
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
cmpl $0x0, (%rax,%rcx,4)
jl 0x35a54d
movq -0x10(%rbp), %rax
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
xorq $0x1, %rcx
movl (%rax,%rcx,4), %eax
xorl $0x1, %eax
movl %eax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x60(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
subl %ecx, %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0x35a4af
movl $0x1, -0x64(%rbp)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x31b110
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq -0x70(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0xc(%rax)
movq -0x70(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movl -0x60(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movslq -0x64(%rbp), %rax
orq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
movl (%rax,%rcx,4), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x70(%rbp), %rax
movw 0x10(%rax), %cx
andw $0xc000, %cx            # imm = 0xC000
orw $0x0, %cx
movw %cx, 0x10(%rax)
jmp 0x35a54f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x35a3d3
jmp 0x35a55f
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x35a362
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x35a5b7
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x14(%rbp), %esi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
callq 0xcd8f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x35a574
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xcdd10
movq -0x10(%rbp), %rdi
callq 0x2210
movq -0x50(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)