// File: /workspace/github_cpp_makefile_star2_O1/qema[P]orca-py/liborca.cpp
// Function: count4()
void count4() {
    clock_t startTime, endTime;
    startTime = clock();
    clock_t startTime_all, endTime_all;
    startTime_all = startTime;
    int frac,frac_prev;

    // precompute triangles that span over edges
    //printf("stage 1 - precomputing common nodes\n");
    int *tri = (int*)calloc(m,sizeof(int));
    frac_prev=-1;
    for (int i=0;i<m;i++) {
        frac = 100LL*i/m;
        if (frac!=frac_prev) {
            //printf("%d%%\r",frac);
            frac_prev=frac;
        }
        int x=edges[i].a, y=edges[i].b;
        for (int xi=0,yi=0; xi<deg[x] && yi<deg[y]; ) {
            if (adj[x][xi]==adj[y][yi]) { tri[i]++; xi++; yi++; }
            else if (adj[x][xi]<adj[y][yi]) { xi++; }
            else { yi++; }
        }
    }
    endTime = clock();
    //printf("%.2f\n", (double)(endTime-startTime)/CLOCKS_PER_SEC);
    startTime = endTime;

    // count full graphlets
    //printf("stage 2 - counting full graphlets\n");
    int64 *C4 = (int64*)calloc(n,sizeof(int64));
    int *neigh = (int*)malloc(n*sizeof(int)), nn;
    frac_prev=-1;
    for (int x=0;x<n;x++) {
        frac = 100LL*x/n;
        if (frac!=frac_prev) {
            //printf("%d%%\r",frac);
            frac_prev=frac;
        }
        for (int nx=0;nx<deg[x];nx++) {
            int y=adj[x][nx];
            if (y >= x) break;
            nn=0;
            for (int ny=0;ny<deg[y];ny++) {
                int z=adj[y][ny];
                if (z >= y) break;
                if (adjacent(x,z)==0) continue;
                neigh[nn++]=z;
            }
            for (int i=0;i<nn;i++) {
                int z = neigh[i];
                for (int j=i+1;j<nn;j++) {
                    int zz = neigh[j];
                    if (adjacent(z,zz)) {
                        C4[x]++; C4[y]++; C4[z]++; C4[zz]++;
                    }
                }
            }
        }
    }
    endTime = clock();
    //printf("%.2f\n", (double)(endTime-startTime)/CLOCKS_PER_SEC);
    startTime = endTime;

    // set up a system of equations relating orbits for every node
    //printf("stage 3 - building systems of equations\n");
    int *common = (int*)calloc(n,sizeof(int));
    int *common_list = (int*)malloc(n*sizeof(int)), nc=0;
    frac_prev=-1;
    for (int x=0;x<n;x++) {
        frac = 100LL*x/n;
        if (frac!=frac_prev) {
            //printf("%d%%\r",frac);
            frac_prev=frac;
        }

        int64 f_12_14=0, f_10_13=0;
        int64 f_13_14=0, f_11_13=0;
        int64 f_7_11=0, f_5_8=0;
        int64 f_6_9=0, f_9_12=0, f_4_8=0, f_8_12=0;
        int64 f_14=C4[x];

        for (int i=0;i<nc;i++) common[common_list[i]]=0;
        nc=0;

        orbit[x][0]=deg[x];
        // x - middle node
        for (int nx1=0;nx1<deg[x];nx1++) {
            int y=inc[x][nx1].first, ey=inc[x][nx1].second;
            for (int ny=0;ny<deg[y];ny++) {
                int z=inc[y][ny].first, ez=inc[y][ny].second;
                if (adjacent(x,z)) { // triangle
                    if (z<y) {
                        f_12_14 += tri[ez]-1;
                        f_10_13 += (deg[y]-1-tri[ez])+(deg[z]-1-tri[ez]);
                    }
                } else {
                    if (common[z]==0) common_list[nc++]=z;
                    common[z]++;
                }
            }
            for (int nx2=nx1+1;nx2<deg[x];nx2++) {
                int z=inc[x][nx2].first, ez=inc[x][nx2].second;
                if (adjacent(y,z)) { // triangle
                    orbit[x][3]++;
                    f_13_14 += (tri[ey]-1)+(tri[ez]-1);
                    f_11_13 += (deg[x]-1-tri[ey])+(deg[x]-1-tri[ez]);
                } else { // path
                    orbit[x][2]++;
                    f_7_11 += (deg[x]-1-tri[ey]-1)+(deg[x]-1-tri[ez]-1);
                    f_5_8 += (deg[y]-1-tri[ey])+(deg[z]-1-tri[ez]);
                }
            }
        }
        // x - side node
        for (int nx1=0;nx1<deg[x];nx1++) {
            int y=inc[x][nx1].first, ey=inc[x][nx1].second;
            for (int ny=0;ny<deg[y];ny++) {
                int z=inc[y][ny].first, ez=inc[y][ny].second;
                if (x==z) continue;
                if (!adjacent(x,z)) { // path
                    orbit[x][1]++;
                    f_6_9 += (deg[y]-1-tri[ey]-1);
                    f_9_12 += tri[ez];
                    f_4_8 += (deg[z]-1-tri[ez]);
                    f_8_12 += (common[z]-1);
                }
            }
        }

        // solve system of equations
        orbit[x][14]=(f_14);
        orbit[x][13]=(f_13_14-6*f_14)/2;
        orbit[x][12]=(f_12_14-3*f_14);
        orbit[x][11]=(f_11_13-f_13_14+6*f_14)/2;
        orbit[x][10]=(f_10_13-f_13_14+6*f_14);
        orbit[x][9]=(f_9_12-2*f_12_14+6*f_14)/2;
        orbit[x][8]=(f_8_12-2*f_12_14+6*f_14)/2;
        orbit[x][7]=(f_13_14+f_7_11-f_11_13-6*f_14)/6;
        orbit[x][6]=(2*f_12_14+f_6_9-f_9_12-6*f_14)/2;
        orbit[x][5]=(2*f_12_14+f_5_8-f_8_12-6*f_14);
        orbit[x][4]=(2*f_12_14+f_4_8-f_8_12-6*f_14);
    }

    endTime = clock();
    //printf("%.2f\n", (double)(endTime-startTime)/CLOCKS_PER_SEC);

    endTime_all = endTime;
    //printf("total: %.2f\n", (double)(endTime_all-startTime_all)/CLOCKS_PER_SEC);

    free(tri);
    free(C4);
    free(neigh);
    free(common);
    free(common_list);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
callq 0x5120
movq 0xe865(%rip), %rax      # 0x13f50
movslq (%rax), %r14
movl $0x4, %esi
movq %r14, %rdi
callq 0x5110
movq %rax, 0x30(%rsp)
testq %r14, %r14
jle 0x5782
movq 0xe8ac(%rip), %rax      # 0x13fb8
movq (%rax), %rax
movq 0xe8b2(%rip), %rcx      # 0x13fc8
movq (%rcx), %rcx
movq 0xe878(%rip), %rdx      # 0x13f98
movq (%rdx), %rdx
xorl %esi, %esi
movslq (%rax,%rsi,8), %rdi
movl (%rcx,%rdi,4), %r8d
testl %r8d, %r8d
jle 0x577a
movslq 0x4(%rax,%rsi,8), %r9
movl (%rcx,%r9,4), %r10d
xorl %r11d, %r11d
xorl %ebx, %ebx
cmpl %r10d, %ebx
jge 0x577a
movq (%rdx,%rdi,8), %r15
movslq %r11d, %r12
movq (%rdx,%r9,8), %r13
movslq %ebx, %rbp
movl (%r13,%rbp,4), %ebp
cmpl %ebp, (%r15,%r12,4)
jne 0x576c
movq 0x30(%rsp), %r15
incl (%r15,%rsi,4)
incl %r11d
jmp 0x5773
jge 0x5773
incl %r11d
jmp 0x5775
incl %ebx
cmpl %r8d, %r11d
jl 0x5740
incq %rsi
cmpq %r14, %rsi
jne 0x5725
callq 0x5120
movq 0xe812(%rip), %rax      # 0x13fa0
movslq (%rax), %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x5110
movq %rax, 0x78(%rsp)
leaq (,%r15,4), %rdi
callq 0x5280
movq %rax, 0x48(%rsp)
testq %r15, %r15
jle 0x5948
xorl %r14d, %r14d
movq 0xe800(%rip), %rbx      # 0x13fc8
movq 0xe7c9(%rip), %r15      # 0x13f98
movq (%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0x5932
xorl %edx, %edx
movq (%r15), %rax
movq (%rax,%r14,8), %rax
movl %edx, %ecx
movslq (%rax,%rcx,4), %r13
cmpq %r13, %r14
jle 0x5932
movq (%rbx), %rax
cmpl $0x0, (%rax,%r13,4)
movl %edx, 0x38(%rsp)
jle 0x586b
xorl %r12d, %r12d
movl $0x0, 0x8(%rsp)
movq (%r15), %rax
movq (%rax,%r13,8), %rax
movl (%rax,%r12,4), %ebp
movl $0xd, %ecx
cmpl %r13d, %ebp
jge 0x5851
movl %r14d, %edi
movl %ebp, %esi
movq 0xe779(%rip), %rax      # 0x13fa8
callq *(%rax)
movl $0xf, %ecx
testb %al, %al
je 0x5851
movl 0x8(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x8(%rsp)
movq 0x48(%rsp), %rcx
movl %ebp, (%rcx,%rax,4)
xorl %ecx, %ecx
cmpl $0xf, %ecx
je 0x585a
testl %ecx, %ecx
jne 0x5873
incq %r12
movq (%rbx), %rax
movslq (%rax,%r13,4), %rax
cmpq %rax, %r12
jl 0x580e
jmp 0x5873
movl $0x0, 0x8(%rsp)
movq %r13, 0x20(%rsp)
movq %r14, %rbx
movl 0x8(%rsp), %eax
testl %eax, %eax
jle 0x5907
movl %eax, %ecx
movq %rcx, %r14
movq 0x48(%rsp), %r13
xorl %eax, %eax
movq %rcx, 0x40(%rsp)
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rsp)
cmpq %rcx, %rdx
jae 0x58f1
movq 0x48(%rsp), %rcx
movslq (%rcx,%rax,4), %r12
movl $0x1, %r15d
movl (%r13,%r15,4), %ebp
movl %r12d, %edi
movl %ebp, %esi
movq 0xe6e2(%rip), %rax      # 0x13fa8
callq *(%rax)
testb %al, %al
je 0x58e9
movq 0x78(%rsp), %rcx
incq (%rcx,%rbx,8)
movq 0x20(%rsp), %rax
incq (%rcx,%rax,8)
incq (%rcx,%r12,8)
movslq %ebp, %rax
incq (%rcx,%rax,8)
incq %r15
cmpl %r15d, %r14d
jne 0x58b5
addq $0x4, %r13
decq %r14
movq 0x40(%rsp), %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jne 0x5898
movq %rbx, %r14
cmpq 0x20(%rsp), %rbx
movq 0xe6b2(%rip), %rbx      # 0x13fc8
movq 0xe67b(%rip), %r15      # 0x13f98
movl 0x38(%rsp), %edx
jle 0x5932
incl %edx
movq (%rbx), %rax
cmpl (%rax,%r14,4), %edx
jl 0x57df
incq %r14
movq 0xe664(%rip), %rax      # 0x13fa0
movslq (%rax), %rax
cmpq %rax, %r14
jl 0x57cf
callq 0x5120
movq 0xe64c(%rip), %rax      # 0x13fa0
movslq (%rax), %r15
movl $0x4, %esi
movq %r15, %rdi
callq 0x5110
movq %rax, %r12
leaq (,%r15,4), %rdi
callq 0x5280
movq %rax, %rbx
testq %r15, %r15
jle 0x5f09
xorl %ebp, %ebp
movq 0xe63f(%rip), %r8       # 0x13fc8
xorl %eax, %eax
movq %r12, 0x8(%rsp)
movq %rbx, 0x80(%rsp)
testl %eax, %eax
jle 0x59b4
movl %eax, %eax
xorl %ecx, %ecx
movslq (%rbx,%rcx,4), %rdx
movl $0x0, (%r12,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x59a0
movq 0x78(%rsp), %rax
movq (%rax,%rbp,8), %rax
movq %rax, 0x88(%rsp)
movq (%r8), %rax
movslq (%rax,%rbp,4), %rax
movq 0xe575(%rip), %rcx      # 0x13f48
movq (%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movq %rax, (%rcx)
movq (%r8), %rax
cmpl $0x0, (%rax,%rbp,4)
jle 0x5c33
xorl %ecx, %ecx
movl $0x1, %eax
movq %rax, 0x28(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movl $0x0, 0x14(%rsp)
movq 0xe555(%rip), %rax      # 0x13f90
movq (%rax), %rax
movq (%rax,%rbp,8), %rax
movslq (%rax,%rcx,8), %r13
movq %rcx, 0x18(%rsp)
movslq 0x4(%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
movq (%r8), %rax
cmpl $0x0, (%rax,%r13,4)
jle 0x5b1e
xorl %ebx, %ebx
movq 0xe524(%rip), %rax      # 0x13f90
movq (%rax), %rax
movq (%rax,%r13,8), %rax
movl (%rax,%rbx,8), %r14d
movslq %r14d, %r15
movslq 0x4(%rax,%rbx,8), %r12
movl %ebp, %edi
movl %r15d, %esi
movq 0xe51d(%rip), %rax      # 0x13fa8
callq *(%rax)
testb %al, %al
je 0x5acf
cmpl %r13d, %r14d
jge 0x5b04
movq 0x30(%rsp), %rax
movl (%rax,%r12,4), %eax
leal -0x1(%rax), %ecx
movslq %ecx, %rcx
addq %rcx, 0x60(%rsp)
movq 0xe517(%rip), %r8       # 0x13fc8
movq (%r8), %rcx
movl (%rcx,%r13,4), %edx
movl (%rcx,%r15,4), %ecx
addl %eax, %eax
subl %eax, %edx
leal (%rdx,%rcx), %eax
addl $-0x2, %eax
cltq
addq %rax, 0x58(%rsp)
jmp 0x5b0b
movq 0x8(%rsp), %rdx
movl (%rdx,%r15,4), %eax
testl %eax, %eax
jne 0x5af5
movl 0x14(%rsp), %esi
movslq %esi, %rcx
incl %esi
movl %esi, 0x14(%rsp)
movq 0x80(%rsp), %rsi
movl %r14d, (%rsi,%rcx,4)
movq 0xe4cc(%rip), %r8       # 0x13fc8
incl %eax
movl %eax, (%rdx,%r15,4)
jmp 0x5b0b
movq 0xe4bd(%rip), %r8       # 0x13fc8
incq %rbx
movq (%r8), %rax
movslq (%rax,%r13,4), %rax
cmpq %rax, %rbx
jl 0x5a65
movq 0x18(%rsp), %rcx
incq %rcx
movq (%r8), %rax
movslq (%rax,%rbp,4), %rax
movq %rcx, 0x18(%rsp)
cmpq %rax, %rcx
jge 0x5c17
movq 0x28(%rsp), %rbx
movq 0xe449(%rip), %rax      # 0x13f90
movq (%rax), %rax
movq (%rax,%rbp,8), %rax
movl (%rax,%rbx,8), %r15d
movslq 0x4(%rax,%rbx,8), %r14
movl %r13d, %edi
movl %r15d, %esi
movq 0xe444(%rip), %rax      # 0x13fa8
callq *(%rax)
movq 0xe3db(%rip), %rcx      # 0x13f48
movq (%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
testb %al, %al
je 0x5bbb
incq 0x18(%rcx)
movq 0x30(%rsp), %rcx
movq 0x20(%rsp), %rax
movl (%rcx,%rax,4), %eax
movl (%rcx,%r14,4), %ecx
leal (%rcx,%rax), %edx
addl $-0x2, %edx
movslq %edx, %rdx
addq %rdx, 0x38(%rsp)
movq 0xe426(%rip), %r8       # 0x13fc8
movq (%r8), %rdx
movl (%rdx,%rbp,4), %edx
addl %edx, %edx
addl %eax, %ecx
subl %ecx, %edx
addl $-0x2, %edx
movslq %edx, %rax
addq %rax, 0x68(%rsp)
jmp 0x5c04
movslq %r15d, %rax
incq 0x10(%rcx)
movq 0xe3ff(%rip), %r8       # 0x13fc8
movq (%r8), %rcx
movl (%rcx,%rbp,4), %edx
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl (%rdi,%rsi,4), %esi
addl %edx, %edx
addl (%rdi,%r14,4), %esi
subl %esi, %edx
addl $-0x4, %edx
movslq %edx, %rdx
addq %rdx, 0x70(%rsp)
movl (%rcx,%r13,4), %edx
movl (%rcx,%rax,4), %eax
subl %esi, %edx
addl %edx, %eax
addl $-0x2, %eax
cltq
addq %rax, 0x40(%rsp)
incq %rbx
movq (%r8), %rax
movslq (%rax,%rbp,4), %rax
cmpq %rax, %rbx
jl 0x5b40
movq (%r8), %rax
movslq (%rax,%rbp,4), %rax
incq 0x28(%rsp)
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
jl 0x5a34
jmp 0x5c71
movq $0x0, 0x38(%rsp)
movl $0x0, 0x14(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x40(%rsp)
movq (%r8), %rax
cmpl $0x0, (%rax,%rbp,4)
jle 0x5d9f
xorl %edx, %edx
movq $0x0, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x50(%rsp)
movq 0xe2eb(%rip), %rax      # 0x13f90
movq (%rax), %rax
movq (%rax,%rbp,8), %rax
movslq (%rax,%rdx,8), %rbx
movq (%r8), %rcx
cmpl $0x0, (%rcx,%rbx,4)
movq %rdx, 0x90(%rsp)
jle 0x5d82
movslq 0x4(%rax,%rdx,8), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movq 0xe2b7(%rip), %rax      # 0x13f90
movq (%rax), %rax
movq (%rax,%rbx,8), %rax
movl (%rax,%r13,8), %r15d
cmpq %r15, %rbp
je 0x5d6f
movslq 0x4(%rax,%r13,8), %r14
movl %ebp, %edi
movl %r15d, %esi
movq 0xe2aa(%rip), %rax      # 0x13fa8
callq *(%rax)
testb %al, %al
je 0x5d0d
movq 0xe2bd(%rip), %r8       # 0x13fc8
jmp 0x5d6f
movq 0xe234(%rip), %rax      # 0x13f48
movq (%rax), %rax
movq (%rax,%rbp,8), %rax
incq 0x8(%rax)
movq 0xe2a2(%rip), %r8       # 0x13fc8
movq (%r8), %rax
movl (%rax,%rbx,4), %ecx
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl (%rsi,%rdx,4), %edx
notl %edx
addl %edx, %ecx
decl %ecx
movslq %ecx, %rcx
addq %rcx, 0x50(%rsp)
movslq %r15d, %rcx
movslq (%rsi,%r14,4), %rdx
addq %rdx, %r12
notl %edx
addl (%rax,%rcx,4), %edx
movslq %edx, %rax
addq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rax
movl (%rax,%rcx,4), %eax
decl %eax
cltq
addq %rax, 0x28(%rsp)
incq %r13
movq (%r8), %rax
movslq (%rax,%rbx,4), %rax
cmpq %rax, %r13
jl 0x5cd2
movq 0x90(%rsp), %rdx
incq %rdx
movq (%r8), %rax
movslq (%rax,%rbp,4), %rax
cmpq %rax, %rdx
jl 0x5c9e
jmp 0x5dbd
movq $0x0, 0x50(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x88(%rsp), %rdi
leaq (%rdi,%rdi), %rax
leaq (%rax,%rax,2), %rsi
movq 0x38(%rsp), %r10
movq %r10, %rax
subq %rsi, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
addq %rax, %rdx
movq 0xe15f(%rip), %rax      # 0x13f48
movq (%rax), %rax
movq (%rax,%rbp,8), %rcx
movq %rdi, 0x70(%rcx)
sarq %rdx
movq %rdx, 0x68(%rcx)
leaq (%rdi,%rdi,2), %rax
movq 0x60(%rsp), %r9
movq %r9, %rdx
subq %rax, %rdx
movq %rdx, 0x60(%rcx)
movq %rsi, %rax
subq %r10, %rax
movq 0x68(%rsp), %r11
addq %r11, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
addq %rax, %rdx
sarq %rdx
movq %rdx, 0x58(%rcx)
movq 0x58(%rsp), %rax
addq %rsi, %rax
subq %r10, %rax
movq %rax, 0x50(%rcx)
movq %rsi, %rdx
subq %r9, %rdx
subq %r9, %rdx
movq %r12, %rbx
leaq (%rdx,%r12), %rax
movq %rax, %rdi
shrq $0x3f, %rdi
addq %rax, %rdi
sarq %rdi
movq %rdi, 0x48(%rcx)
movq 0x28(%rsp), %r12
addq %r12, %rdx
movq %rdx, %rdi
shrq $0x3f, %rdi
addq %rdx, %rdi
addq %rsi, %r11
subq %r11, %r10
sarq %rdi
addq 0x70(%rsp), %r10
movq %r10, %rax
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
imulq %rdx
movq %rdi, 0x40(%rcx)
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %rax, 0x38(%rcx)
movq 0x50(%rsp), %rax
leaq (%rax,%r9,2), %rax
addq %rsi, %rbx
subq %rbx, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
addq %rax, %rdx
sarq %rdx
movq %rdx, 0x30(%rcx)
addq %rsi, %r12
movq 0x40(%rsp), %rax
leaq (%rax,%r9,2), %rax
subq %r12, %rax
movq %rax, 0x28(%rcx)
movq 0x18(%rsp), %rax
leaq (%rax,%r9,2), %rax
subq %r12, %rax
movq %rax, 0x20(%rcx)
incq %rbp
movq 0xe0b4(%rip), %rax      # 0x13fa0
movslq (%rax), %rax
cmpq %rax, %rbp
movq 0x80(%rsp), %rbx
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %r12
jl 0x5998
callq 0x5120
movq 0x30(%rsp), %rdi
callq 0x5240
movq 0x78(%rsp), %rdi
callq 0x5240
movq 0x48(%rsp), %rdi
callq 0x5240
movq %r12, %rdi
callq 0x5240
movq %rbx, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5240