LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/camera.cpp
// Function: Camera::camera_transform(Vec3<float>)
Vec3f Camera::camera_transform(Vec3f p) {
    Matrix res = ViewPort;
    Matrix ModelView = lookat();

    if (mode == PERSPECTIVE)
    {
        res = res * Projection;
    }

    return m2v(res * ModelView * v2m(p));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xc8, %rsp
movss %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rdi, %rbx
leaq 0x28(%rdi), %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x3d36
movq 0x40(%rbx), %rax
movq %rax, 0x18(%r14)
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x35fa
cmpl $0x1, 0x68(%rbx)
jne 0x38fd
addq $0x48, %rbx
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
movq %rbx, %rdx
callq 0x2736
movq 0x10(%rsp), %rax
leaq 0x40(%rsp), %rbx
movaps (%rbx), %xmm0
movq 0x10(%rbx), %rcx
movq %rcx, 0x10(%rsp)
movaps (%rsp), %xmm1
movaps %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x2f62
movq 0x18(%rbx), %rax
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x2f62
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
leaq 0xa8(%rsp), %rdx
callq 0x2736
leaq 0x60(%rsp), %rdi
movaps 0x20(%rsp), %xmm0
movss 0x30(%rsp), %xmm1
callq 0x3552
leaq 0x88(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x2736
leaq 0x88(%rsp), %rsi
callq 0x33f4
movaps %xmm0, 0x30(%rsp)
movss %xmm1, 0x20(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x2f62
leaq 0x60(%rsp), %rdi
callq 0x2f62
leaq 0x40(%rsp), %rdi
callq 0x2f62
leaq 0xa8(%rsp), %rdi
callq 0x2f62
movq %rsp, %rdi
callq 0x2f62
movaps 0x30(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
addq $0xc8, %rsp
popq %rbx
popq %r14
retq
jmp 0x39d4
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2f62
jmp 0x39b9
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2f62
jmp 0x39c8
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2f62
jmp 0x39d7
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x2f62
movq %rsp, %rdi
callq 0x2f62
movq %rbx, %rdi
callq 0x22d0
movq %rax, %rbx
jmp 0x39e4
nop
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/image.cpp
// Function: Image::exportPPM()
void Image::exportPPM() {
    std::ofstream ofs;
    ofs.open("./out.ppm");
    ofs << "P6" << std::endl << width << " " << height << std::endl << "255" << std::endl;
    for (int i = 0; i < width * height; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            ofs << (char)(255 * std::max(0.f, std::min(1.f , framebuffer[i][j]) ) );
        }
    }
    ofs.close();   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x22a0
leaq 0x32a6(%rip), %rsi      # 0x7168
movq %r14, %rdi
movl $0x10, %edx
callq 0x2050
leaq 0x329c(%rip), %rsi      # 0x7172
leaq 0x8(%rsp), %r14
movl $0x2, %edx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
leaq 0x8(%rsp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl 0x18(%rbx), %esi
movq %rax, %rdi
callq 0x22b0
movq %rax, %r14
leaq 0x3262(%rip), %rsi      # 0x718a
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movl 0x1c(%rbx), %esi
movq %r14, %rdi
callq 0x22b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %r14
leaq 0x3201(%rip), %rsi      # 0x7175
movl $0x3, %edx
movq %rax, %rdi
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl 0x1c(%rbx), %eax
imull 0x18(%rbx), %eax
testl %eax, %eax
jle 0x403f
xorl %r12d, %r12d
leaq 0x8(%rsp), %r14
leaq 0x7(%rsp), %r15
leaq (%r12,%r12,2), %r13
shlq $0x2, %r13
xorl %ebp, %ebp
movq (%rbx), %rax
addq %r13, %rax
xorl %ecx, %ecx
cmpl $0x1, %ebp
setne %cl
testl %ebp, %ebp
leaq 0x4(,%rcx,4), %rcx
movl $0x0, %edx
cmovneq %rcx, %rdx
movss (%rdx,%rax), %xmm0
minss 0x3044(%rip), %xmm0     # 0x7040
maxss 0x3160(%rip), %xmm0     # 0x7164
mulss 0x3154(%rip), %xmm0     # 0x7160
cvttss2si %xmm0, %eax
movb %al, 0x7(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21d0
incl %ebp
cmpl $0x3, %ebp
jne 0x3fce
incq %r12
movslq 0x18(%rbx), %rax
movslq 0x1c(%rbx), %rcx
imulq %rax, %rcx
cmpq %rcx, %r12
jl 0x3fc4
leaq 0x8(%rsp), %rdi
callq 0x2210
movq 0x5f78(%rip), %rax      # 0x9fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x10(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x8(%rsp,%rcx)
callq 0x2170
leaq 0x100(%rsp), %rdi
callq 0x2090
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x408f
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x22d0
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/image.cpp
// Function: Image::setPixel(int, int, Vec3<float>)
void Image::setPixel(const int x, const int y, Vec3f color) {
    for (int i = 0; i < 3; i++)
    {
        if(color[i] > 1.) 
            color[i] = 1.;
        
        if( color[i] < 0. )
            color[i] = 0.;
    }
    

    if( 0 <= x && x < width && 0 <= y && y < height )
        framebuffer[x + y * width] = color;
}

// Assembly:
movlps %xmm0, -0x10(%rsp)
movss %xmm1, -0x8(%rsp)
xorl %eax, %eax
movss 0x2f87(%rip), %xmm0     # 0x7040
xorl %ecx, %ecx
cmpl $0x1, %eax
setne %cl
testl %eax, %eax
leaq 0x4(,%rcx,4), %r8
movl $0x0, %ecx
cmovneq %r8, %rcx
movss -0x10(%rsp,%rcx), %xmm2
ucomiss %xmm0, %xmm2
movaps %xmm0, %xmm1
ja 0x40ea
xorps %xmm1, %xmm1
ucomiss %xmm2, %xmm1
jbe 0x40f0
movss %xmm1, -0x10(%rsp,%rcx)
incl %eax
cmpl $0x3, %eax
jne 0x40b9
testl %esi, %esi
js 0x4128
testl %edx, %edx
js 0x4128
movl 0x18(%rdi), %eax
cmpl %esi, %eax
jle 0x4128
cmpl %edx, 0x1c(%rdi)
jle 0x4128
imull %edx, %eax
addl %esi, %eax
movq (%rdi), %rcx
leaq (%rax,%rax,2), %rax
movl -0x8(%rsp), %edx
movl %edx, 0x8(%rcx,%rax,4)
movq -0x10(%rsp), %rdx
movq %rdx, (%rcx,%rax,4)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/image.cpp
// Function: Image::flip(int)
void Image::flip(const int type) {
   std::vector<Vec3f> framebuffer_tmp(width * height);

    for (int x = 0; x < width; x++)
    {
        for (int y = 0; y < height; y++)
        {
            if ( type ==  HORIZONTAL_FLIP ) {
                framebuffer_tmp[ x + y * width ] = framebuffer[ ( width - 1 - x ) + ( y ) * width ];
            } else {
                framebuffer_tmp[ x + y * width ] = framebuffer[ x + (height - 1 - y ) * width ];
            }
        }
    }
    
    framebuffer = framebuffer_tmp;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movslq 0x18(%rdi), %rax
movslq 0x1c(%rdi), %rsi
imulq %rax, %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x4376
movl 0x18(%rbx), %ecx
testl %ecx, %ecx
jle 0x4248
movl 0x1c(%rbx), %edi
xorl %eax, %eax
testl %edi, %edi
jle 0x423e
movl %eax, %ecx
notl %ecx
xorl %edx, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpl $0x1, %ebp
jne 0x41f1
movl 0x18(%rbx), %edi
leal (%rdi,%rcx), %r8d
imull %edx, %edi
addl %edi, %r8d
movslq %r8d, %r8
movq (%rbx), %r9
leaq (%r8,%r8,2), %r8
addl %eax, %edi
movslq %edi, %rdi
movq 0x10(%rsp), %r10
leaq (%rdi,%rdi,2), %rdi
movl 0x8(%r9,%r8,4), %r11d
movl %r11d, 0x8(%r10,%rdi,4)
movq (%r9,%r8,4), %r8
movq %r8, (%r10,%rdi,4)
jmp 0x422c
addl %esi, %edi
movl 0x18(%rbx), %r8d
imull %r8d, %edi
addl %eax, %edi
movslq %edi, %rdi
movq (%rbx), %r9
leaq (%rdi,%rdi,2), %rdi
imull %edx, %r8d
addl %eax, %r8d
movslq %r8d, %r8
movq 0x10(%rsp), %r10
leaq (%r8,%r8,2), %r8
movl 0x8(%r9,%rdi,4), %r11d
movl %r11d, 0x8(%r10,%r8,4)
movq (%r9,%rdi,4), %rdi
movq %rdi, (%r10,%r8,4)
incl %edx
movl 0x1c(%rbx), %edi
decl %esi
cmpl %edi, %edx
jl 0x41b3
movl 0x18(%rbx), %ecx
incl %eax
cmpl %ecx, %eax
jl 0x41a0
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x43f4
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x426c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x428d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22d0
nop
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/image.cpp
// Function: Image::getPixel(int, int)
Vec3f Image::getPixel(const int x, const int y) {
    if( 0 <= x && x < width && 0 <= y && y < height )
        return framebuffer[x + y * width];
    else 
        return Vec3f(0,0,0);
}

// Assembly:
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
testl %esi, %esi
js 0x42c7
testl %edx, %edx
js 0x42c7
movl 0x18(%rdi), %eax
cmpl %esi, %eax
jle 0x42c7
cmpl %edx, 0x1c(%rdi)
jle 0x42c7
imull %edx, %eax
addl %esi, %eax
movq (%rdi), %rcx
leaq (%rax,%rax,2), %rax
movsd (%rcx,%rax,4), %xmm0
movss 0x8(%rcx,%rax,4), %xmm1
retq
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/image.cpp
// Function: Image::fusionner(Image&)
Image Image::fusionner(Image& i) {
    Image res(width, height);

    for (int j = 0; j < width * height; j++)
    {
        res.setPixel(j % width, j / width , Vec3f( framebuffer[j].x + i.framebuffer[j].x, 
                                                  framebuffer[j].y + i.framebuffer[j].y,                                  
                                                  framebuffer[j].z + i.framebuffer[j].z                                  
                                                ) );
    }
    
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movl 0x18(%rsi), %ebp
movl 0x1c(%rsi), %r12d
movl %r12d, %eax
imull %ebp, %eax
movslq %eax, %rsi
leaq 0x7(%rsp), %rdx
callq 0x4376
movl %ebp, 0x18(%r14)
movl %r12d, 0x1c(%r14)
movl 0x18(%r15), %ecx
movl 0x1c(%r15), %eax
imull %ecx, %eax
testl %eax, %eax
jle 0x4363
movl $0x8, %r13d
xorl %r12d, %r12d
movl %r12d, %eax
cltd
idivl %ecx
movq (%r15), %rcx
movq (%rbx), %rsi
movsd -0x8(%rcx,%r13), %xmm1
movsd -0x8(%rsi,%r13), %xmm0
addps %xmm1, %xmm0
movss (%rcx,%r13), %xmm1
addss (%rsi,%r13), %xmm1
movq %r14, %rdi
movl %edx, %esi
movl %eax, %edx
callq 0x40a4
incq %r12
movslq 0x18(%r15), %rcx
movslq 0x1c(%r15), %rax
imulq %rcx, %rax
addq $0xc, %r13
cmpq %rax, %r12
jl 0x4316
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/./triangle.hpp
// Function: barycentric(Vec3<float>, Vec3<float>, Vec3<float>, Vec3<float>)
Vec3f barycentric(Vec3f A, Vec3f B, Vec3f C, Vec3f P) {
    Vec3f s[2];
    for (int i=2; i--; ) {
        s[i][0] = C[i]-A[i];
        s[i][1] = B[i]-A[i];
        s[i][2] = A[i]-P[i];
    }
    Vec3f u = s[0] ^ s[1];
    if (std::abs(u[2])>1e-2) 
        return Vec3f(1.f-(u.x+u.y)/u.z, u.y/u.z, u.x/u.z);
    return Vec3f(-1,1,1);
}

// Assembly:
movlps %xmm0, -0x10(%rsp)
movss %xmm1, -0x8(%rsp)
movlps %xmm2, -0x20(%rsp)
movss %xmm3, -0x18(%rsp)
movlps %xmm4, -0x30(%rsp)
movss %xmm5, -0x28(%rsp)
movlps %xmm6, -0x40(%rsp)
movss %xmm7, -0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x58(%rsp)
movq $0x0, -0x48(%rsp)
movl $0xc, %eax
xorl %ecx, %ecx
cmpq $0xc, %rax
setne %cl
testq %rax, %rax
leaq 0x4(,%rcx,4), %rcx
cmoveq %rax, %rcx
movss -0x10(%rsp,%rcx), %xmm0
movss -0x20(%rsp,%rcx), %xmm1
movss -0x30(%rsp,%rcx), %xmm2
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movaps %xmm0, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
subps %xmm1, %xmm2
subss -0x40(%rsp,%rcx), %xmm0
movlps %xmm2, -0x58(%rsp,%rax)
movss %xmm0, -0x50(%rsp,%rax)
addq $-0xc, %rax
cmpq $-0xc, %rax
jne 0x5bea
movss -0x58(%rsp), %xmm4
movss -0x54(%rsp), %xmm1
movss -0x48(%rsp), %xmm0
movss -0x4c(%rsp), %xmm3
movaps %xmm3, %xmm5
mulss %xmm1, %xmm5
movaps %xmm4, %xmm2
mulss %xmm0, %xmm2
subss %xmm5, %xmm2
movaps 0x1564(%rip), %xmm5     # 0x71d0
andps %xmm2, %xmm5
cvtss2sd %xmm5, %xmm5
ucomisd 0x15a5(%rip), %xmm5     # 0x7220
jbe 0x5cc8
movss -0x50(%rsp), %xmm5
movss -0x44(%rsp), %xmm6
unpcklps %xmm6, %xmm0            # xmm0 = xmm0[0],xmm6[0],xmm0[1],xmm6[1]
unpcklps %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1]
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
mulps %xmm5, %xmm0
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
mulps %xmm6, %xmm1
subps %xmm0, %xmm1
movaps %xmm1, %xmm3
shufps $0x55, %xmm1, %xmm3     # xmm3 = xmm3[1,1],xmm1[1,1]
movaps %xmm1, %xmm4
addss %xmm3, %xmm4
divss %xmm2, %xmm4
movss 0x1388(%rip), %xmm0     # 0x7040
subss %xmm4, %xmm0
divss %xmm2, %xmm3
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
divss %xmm2, %xmm1
retq
movss 0x1370(%rip), %xmm1     # 0x7040
movsd 0x1508(%rip), %xmm0     # 0x71e0
retq
// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/obj_render.cpp
// Function: main
int main(int argc, char const ** argv)
{
    std::string file_obj = "./model/head.obj";
    
    bool _3Dmode = true;

    if(argc >= 2) {
        for (int i = 1; i <= 2 && i < argc; i++)
        {
            if ( std::string(argv[i]) == "--no-3d" ){
                _3Dmode = false;
                std::cout << "*** Disabled 3D ***"  << std::endl;

            } else {
                file_obj = std::string(argv[i]) ;
            }
        }
    }
    
    std::cout << "Loading model " << file_obj << std::endl;
    Model* model = new Model(file_obj.c_str());
    
    render(model, _3Dmode);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xcbf(%rip), %rsi       # 0x7264
leaq 0xcc8(%rip), %rdx       # 0x7274
leaq 0x8(%rsp), %rdi
callq 0x564e
movb $0x1, %al
movl %eax, (%rsp)
cmpl $0x2, %ebp
jl 0x66bb
sete %al
movzbl %al, %r13d
xorq $0x3, %r13
movb $0x1, %al
movl %eax, (%rsp)
movl $0x1, %r12d
leaq 0x28(%rsp), %r14
leaq 0x7(%rsp), %r15
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x5510
movq %r14, %rdi
leaq 0xc78(%rip), %rsi       # 0x7275
callq 0x2080
movl %eax, %ebp
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6620
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21b0
testl %ebp, %ebp
je 0x665e
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x5510
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21e0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x66af
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x66af
movl $0x13, %edx
movq 0x396e(%rip), %rdi      # 0x9fd8
leaq 0xc0c(%rip), %rsi       # 0x727d
callq 0x21d0
movq 0x395b(%rip), %rcx      # 0x9fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x393d(%rip), %rdi      # 0x9fd8
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x0, (%rsp)
incq %r12
cmpq %r12, %r13
jne 0x65e4
movq 0x3916(%rip), %rdi      # 0x9fd8
leaq 0xbc8(%rip), %rsi       # 0x7291
movl $0xe, %edx
callq 0x21d0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x38f4(%rip), %rdi      # 0x9fd8
callq 0x21d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x30, %edi
callq 0x21a0
movq %rax, %r14
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4524
movzbl (%rsp), %esi
andl $0x1, %esi
movq %r14, %rdi
callq 0x5faf
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6758
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x30, %esi
movq %r14, %rdi
callq 0x21b0
jmp 0x6786
jmp 0x6783
jmp 0x6783
jmp 0x6783
jmp 0x6783
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x67a2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/main.cpp
// Function: ExtractInstruction[abi:cxx11](std::basic_ifstream<char, std::char_traits<char>>&)
vector<string> ExtractInstruction(ifstream& is)
{
   vector<string> instruction;
   char ch;
   int n=0;

   while(is.good()&&!is.eof())
   {
      n=0;
      string s="";

      ch=is.get();

      if(ch==EOF)
            continue;
      else if(ch=='/') // se è un commento ignoriamo tutto
      {
            is.ignore(100, '\n');
            continue;
      }
      else
      {
            // raccolgo i caratteri della riga finchè non incontro un \n o raggiungo la massima lunghezza della istruzione permessa
            do
            {
                  n++;
                  s+=ch;
                  ch=is.get();
            }while(ch != '\n' && n < INSTR_LENGTH);

            // se raggiungo la massima lunghezza della istruzione inserisco un \n come carattere finale
            if(n >= INSTR_LENGTH)
            {
                  s+=ch;
                  s+='\n';
            }
            
            // carico nel vettore la stringa così costruita
            instruction.push_back(s);
      }
   }
   
   return instruction;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, -0x30(%rbp)
movq $0x0, 0x10(%rdi)
movq (%rsi), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%rsi,%rax)
jne 0x4b5d
movq %rsi, %r14
leaq -0x40(%rbp), %r13
leaq 0x25d4(%rip), %r15      # 0x7076
leaq -0x50(%rbp), %r12
movq %r13, -0x50(%rbp)
movq %r12, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x514e
movq %r14, %rdi
callq 0x32b0
cmpb $0x2f, %al
je 0x4b23
movzbl %al, %ecx
cmpl $0xff, %ecx
je 0x4b35
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movsbl %al, %esi
movq %r12, %rdi
callq 0x31f0
movq %r14, %rdi
callq 0x32b0
incl %ebx
cmpb $0xa, %al
je 0x4af5
cmpl $0xf9, %ebx
jb 0x4ad4
cmpl $0xf9, %ebx
jb 0x4b15
movsbl %al, %esi
movq %r12, %rdi
callq 0x31f0
movq %r12, %rdi
movl $0xa, %esi
callq 0x31f0
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x5064
jmp 0x4b35
movl $0x64, %esi
movq %r14, %rdi
movl $0xa, %edx
callq 0x3160
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x4b4a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq (%r14), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%r14,%rax)
je 0x4aa6
movq -0x30(%rbp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x4b8f
jmp 0x4b77
movq %rax, %r14
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x4b8f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0x30(%rbp), %rdi
callq 0x4f54
movq %r14, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/main.cpp
// Function: isBitStreamInstruction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool isBitStreamInstruction(string instr)
{
      string s = instr.substr(0, 100);

      istringstream iss(s);
      string tmp;
      long int n;

      iss >> tmp;

      if(tmp != "SDR")
            return false;

      iss >> n;

      if(n < 1000)
            return false;
      
      return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, %rsi
leaq -0x58(%rbp), %rbx
movl $0x64, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3270
leaq -0x1d8(%rbp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x33a0
leaq -0x28(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq -0x1d8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x32e0
leaq 0x29e4(%rip), %rsi      # 0x75e7
leaq -0x38(%rbp), %rdi
callq 0x3080
testl %eax, %eax
je 0x4c14
xorl %ebx, %ebx
jmp 0x4c2f
leaq -0x1d8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3260
cmpq $0x3e8, -0x18(%rbp)     # imm = 0x3E8
setge %bl
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
je 0x4c44
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x5375(%rip), %rsi      # 0x9fc0
leaq -0x1d8(%rbp), %rdi
callq 0x3310
leaq -0x160(%rbp), %rdi
callq 0x30a0
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4c7c
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
movl %ebx, %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
jmp 0x4cc6
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
je 0x4ca7
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x5312(%rip), %rsi      # 0x9fc0
leaq -0x1d8(%rbp), %rdi
callq 0x3310
leaq -0x160(%rbp), %rdi
callq 0x30a0
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cdf
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
movq %rbx, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/main.cpp
// Function: ExtractAnswer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string ExtractAnswer(string line)
{
      istringstream iss(line);
      string str;
      iss >> str;
      iss >> str;
      iss >> str;

      return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %rbx
leaq -0x198(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33a0
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32e0
leaq -0x198(%rbp), %rdi
movq %rbx, %rsi
callq 0x32e0
leaq -0x198(%rbp), %rdi
movq %rbx, %rsi
callq 0x32e0
movq 0x50ee(%rip), %rsi      # 0x9fc0
leaq -0x198(%rbp), %rdi
callq 0x3310
leaq -0x120(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x4f11
movq (%r15), %rsi
incq %rsi
callq 0x3250
movq 0x50a8(%rip), %rsi      # 0x9fc0
leaq -0x198(%rbp), %rdi
callq 0x3310
leaq -0x120(%rbp), %rdi
callq 0x30a0
movq %r14, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::WriteString(char const*)
void Serial::WriteString(const char *String)
{
   int length=strlen(String);
   if (write(fd,String,length)!=length)
   {
      throw ErrorWriteException();
   }
   return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x30e0
movl (%r14), %edi
movslq %eax, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x30b0
cmpq %r14, %rax
jne 0x5762
popq %rbx
popq %r14
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x4595(%rip), %rcx      # 0x9d08
movq %rcx, (%rax)
leaq 0x44e3(%rip), %rsi      # 0x9c60
movq 0x485c(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33c0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadChar(char*, unsigned int)
unsigned Serial::ReadChar(char *pByte, unsigned TimeOut_ms)
{
   // Timer per la gestione del timeout
   TimeOut Timer;
   Timer.InitTimer();
   while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0)
   {
      switch (read(fd,pByte,1))
      {
         case -1: throw ErrorReadException();
         case 1 : return 1;
      }
   }
   throw TimeoutException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x38(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3380
movl %ebx, %r13d
movq %r12, %rdi
callq 0x5892
testl %ebx, %ebx
je 0x580f
cmpq %r13, %rax
jae 0x585c
movl (%r15), %edi
movl $0x1, %edx
movq %r14, %rsi
callq 0x3320
cmpq $0x1, %rax
je 0x5848
cmpq $-0x1, %rax
jne 0x57fe
movl $0x8, %edi
callq 0x3110
leaq 0x44f4(%rip), %rcx      # 0x9d30
movq %rcx, (%rax)
leaq 0x4432(%rip), %rsi      # 0x9c78
jmp 0x5877
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x44eb(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x43a1(%rip), %rsi      # 0x9c18
movq 0x4762(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33c0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadStringNoTimeOut(char*, char, unsigned int)
unsigned Serial::ReadStringNoTimeOut(char *String, char FinalChar, unsigned MaxNbBytes)
{
   unsigned NbBytes=0;
   unsigned ret;
   while (NbBytes<MaxNbBytes)
   {
      ret=ReadChar(&String[NbBytes]);
      if (ret==1)
      {
         if (String[NbBytes]==FinalChar)
         {
            String[NbBytes]='\0';
            return NbBytes;
         }
         NbBytes++;
      }
      else
      {
         // Ramo superfluo in quanto l'eccezione verrebbe lanciata da ReadChar(...)
         // lasciato per facilitare un eventuale debug
         throw ErrorReadException();
      }
   }
   throw ErrorBufferFullException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %ecx, %ecx
je 0x5935
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r15
movl %ecx, %r13d
xorl %r12d, %r12d
leaq (%rbx,%r12), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x57d4
cmpb %r14b, (%rbx,%r12)
je 0x595f
incq %r12
cmpq %r12, %r13
jne 0x5919
movl $0x8, %edi
callq 0x3110
leaq 0x443a(%rip), %rcx      # 0x9d80
movq %rcx, (%rax)
leaq 0x4340(%rip), %rsi      # 0x9c90
movq 0x4689(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33c0
movb $0x0, (%rbx,%r12)
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadString(char*, char, unsigned int, unsigned int)
unsigned Serial::ReadString(char *String,char FinalChar,unsigned MaxNbBytes,unsigned TimeOut_ms)
{
   // Se non è specificato un timeout, usa il metodo senza timeout
   if (TimeOut_ms==0)
      return ReadStringNoTimeOut(String,FinalChar,MaxNbBytes);
   unsigned NbBytes=0;
   unsigned ret;

   // Timer la gestione del timeout
   TimeOut Timer;
   long int TimeOutParam;

   // Inizializza il timer
   Timer.InitTimer();

   while (NbBytes<MaxNbBytes)
   {
      // Tempo trascorso
      TimeOutParam=TimeOut_ms-Timer.ElapsedTime_ms();
      if (TimeOutParam>0)
      {
         ret=ReadChar(&String[NbBytes],TimeOutParam);
         if (ret==1)
         {
            if (String[NbBytes]==FinalChar)
            {
               String[NbBytes]='\0';
               return NbBytes;
            }
            NbBytes++;
         }
         else
          throw ErrorReadException();
      }
      if (Timer.ElapsedTime_ms()>TimeOut_ms)
      {
         String[NbBytes]='\0';
         throw TimeoutException();
      }
   }
   throw ErrorBufferFullException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r15d
movl %edx, -0x2c(%rbp)
testl %r8d, %r8d
je 0x5a4d
movl %r8d, %ebx
movq %rdi, -0x40(%rbp)
movq %rsi, -0x38(%rbp)
xorl %r14d, %r14d
leaq -0x58(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3380
movl %ebx, %ebx
cmpl %r15d, %r14d
jae 0x5a67
movq %r12, %rdi
callq 0x5892
movq %rbx, %rdx
subq %rax, %rdx
jle 0x5a01
movq %r12, %r13
movl %r14d, %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rcx
leaq (%rcx,%rax), %r12
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x57d4
movl -0x2c(%rbp), %eax
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rdx
cmpb %al, (%rdx,%rcx)
je 0x5a36
incl %r14d
movq %r13, %r12
movq %r12, %rdi
callq 0x5892
cmpq %rbx, %rax
jbe 0x59b4
movl %r14d, %eax
movq -0x38(%rbp), %rcx
movb $0x0, (%rcx,%rax)
movl $0x8, %edi
callq 0x3110
leaq 0x432e(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x41e4(%rip), %rsi      # 0x9c18
jmp 0x5a82
movb $0x0, (%r12)
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl -0x2c(%rbp), %edx
movl %r15d, %ecx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x58f8
movl $0x8, %edi
callq 0x3110
leaq 0x4308(%rip), %rcx      # 0x9d80
movq %rcx, (%rax)
leaq 0x420e(%rip), %rsi      # 0x9c90
movq 0x4557(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::Read(void*, unsigned int, unsigned int)
unsigned Serial::Read (void *Buffer,unsigned MaxNbBytes,unsigned TimeOut_ms)
{
   // Timer per gestire il timeout
   TimeOut Timer;

   // Inizializza il timer
   Timer.InitTimer();
   unsigned NbByteRead=0;
   while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0)
   {
      unsigned char* Ptr=(unsigned char*)Buffer+NbByteRead;
      int Ret=read(fd,(void*)Ptr,MaxNbBytes-NbByteRead);
      if (Ret==-1)
         throw ErrorReadException();
      if (Ret>0)
      {
         NbByteRead+=Ret;
         if (NbByteRead>=MaxNbBytes)
            return NbByteRead;
      }
   }
   throw TimeoutException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
xorl %r13d, %r13d
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x3380
movl %ebx, %eax
movq %rax, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5892
testl %ebx, %ebx
je 0x5ad5
cmpq -0x30(%rbp), %rax
jae 0x5b35
movl %r13d, %esi
addq %r15, %rsi
movl (%r12), %edi
movl %r14d, %edx
subl %r13d, %edx
callq 0x3320
movq %rax, %rcx
cmpl $-0x1, %ecx
je 0x5b18
leal (%rcx,%r13), %eax
cmpl %r14d, %eax
setb %dl
testl %ecx, %ecx
setle %cl
cmovgl %eax, %r13d
orb %dl, %cl
jne 0x5ac2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x4207(%rip), %rcx      # 0x9d30
movq %rcx, (%rax)
leaq 0x4145(%rip), %rsi      # 0x9c78
jmp 0x5b50
movl $0x8, %edi
callq 0x3110
leaq 0x4212(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x40c8(%rip), %rsi      # 0x9c18
movq 0x4489(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateSTATEOutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateSTATEOutput (string line)
{
		istringstream iss(line);
		string sub;

		// Scarta nome comando
		iss >> sub;
		// Prende nome stato
		iss >> sub;
		if (sub == "RESET;")
		{
			return "!!!!!*";
		}
		else if (sub == "IDLE;") 
		{
			return "*";
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
leaq -0x1b8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33a0
leaq -0x28(%rbp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq -0x38(%rbp), %rsi
movq %r14, %rdi
callq 0x32e0
leaq -0x1b8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x32e0
leaq 0x1300(%rip), %rsi      # 0x779d
leaq -0x38(%rbp), %rdi
callq 0x3080
testl %eax, %eax
je 0x64d9
leaq 0x12fa(%rip), %rsi      # 0x77ab
leaq -0x38(%rbp), %rdi
callq 0x3080
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x12e1(%rip), %rsi      # 0x77a9
leaq 0x12db(%rip), %rdx      # 0x77aa
movq %rbx, %rdi
callq 0x514e
jmp 0x64f6
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x12bd(%rip), %rsi      # 0x77a4
leaq 0x12bc(%rip), %rdx      # 0x77aa
movq %rbx, %rdi
callq 0x514e
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x650b
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3aae(%rip), %rsi      # 0x9fc0
leaq -0x1b8(%rbp), %rdi
callq 0x3310
leaq -0x140(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x653f
jmp 0x653f
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x6557
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3a62(%rip), %rsi      # 0x9fc0
leaq -0x1b8(%rbp), %rdi
callq 0x3310
leaq -0x140(%rbp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateRUNTESTOutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateRUNTESTOutput (string line)
{
		istringstream iss(line);
		string sub, str;
		long int n;
		int i;

		// Scarta nome comando
		iss >> sub;
		iss >> n;

		// Impostiamo come massimo il numero di caratteri che possiamo inviare sulla seriale
		if(n > 1000)
			n = 1000;

		// Assumendo che i cicli di clock indicati siano divisibili per 4
		for (i=0; i < n/4; i++)
		{
			// Tanti '0' quanti sono i cicli di clock richiesti divisi per 4
			str += '0';
		}

		return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, %rbx
leaq -0x1c8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33a0
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x10(%rbx), %r12
movq %r12, (%rbx)
movq %rax, 0x8(%rbx)
movb %al, 0x10(%rbx)
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x32e0
leaq -0x1c8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3260
movq -0x28(%rbp), %rax
cmpq $0x3e9, %rax            # imm = 0x3E9
jl 0x65f8
movq $0x3e8, -0x28(%rbp)     # imm = 0x3E8
jmp 0x65fe
cmpq $0x4, %rax
jl 0x6629
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x30, %esi
callq 0x31f0
incq %r14
movq -0x28(%rbp), %rax
leaq 0x3(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jg 0x6601
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x663e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x397b(%rip), %rsi      # 0x9fc0
leaq -0x1c8(%rbp), %rdi
callq 0x3310
leaq -0x150(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6672
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x6689
movq (%r12), %rsi
incq %rsi
callq 0x3250
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x669e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x391b(%rip), %rsi      # 0x9fc0
leaq -0x1c8(%rbp), %rdi
callq 0x3310
leaq -0x150(%rbp), %rdi
callq 0x30a0
movq %r14, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: hexCharToBin[abi:cxx11](char)
string hexCharToBin(char c)	// Funzione di conversione valore esadecimale in valore binario
{
    switch(toupper(c))
    {
        case '0': return "0000";
        case '1': return "0001";
        case '2': return "0010";
        case '3': return "0011";
        case '4': return "0100";
        case '5': return "0101";
        case '6': return "0110";
        case '7': return "0111";
        case '8': return "1000";
        case '9': return "1001";
        case 'A': return "1010";
        case 'B': return "1011";
        case 'C': return "1100";
        case 'D': return "1101";
        case 'E': return "1110";
        case 'F': return "1111";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, %edi
callq 0x3400
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
addl $-0x30, %eax
leaq 0x1042(%rip), %rcx      # 0x7728
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10bb(%rip), %rsi      # 0x77b1
leaq 0x10b8(%rip), %rdx      # 0x77b5
jmp 0x6802
leaq 0x10df(%rip), %rsi      # 0x77e8
leaq 0x10dc(%rip), %rdx      # 0x77ec
jmp 0x6802
leaq 0x10d1(%rip), %rsi      # 0x77ed
leaq 0x10ce(%rip), %rdx      # 0x77f1
jmp 0x6802
leaq 0x1096(%rip), %rsi      # 0x77c5
leaq 0x1093(%rip), %rdx      # 0x77c9
jmp 0x6802
leaq 0x109c(%rip), %rsi      # 0x77de
leaq 0x1099(%rip), %rdx      # 0x77e2
jmp 0x6802
leaq 0x10a7(%rip), %rsi      # 0x77fc
leaq 0x10a4(%rip), %rdx      # 0x7800
jmp 0x6802
leaq 0x1053(%rip), %rsi      # 0x77bb
leaq 0x1050(%rip), %rdx      # 0x77bf
jmp 0x6802
leaq 0x1045(%rip), %rsi      # 0x77c0
leaq 0x1042(%rip), %rdx      # 0x77c4
jmp 0x6802
leaq 0x1067(%rip), %rsi      # 0x77f2
leaq 0x1064(%rip), %rdx      # 0x77f6
jmp 0x6802
leaq 0x1039(%rip), %rsi      # 0x77d4
leaq 0x1036(%rip), %rdx      # 0x77d8
jmp 0x6802
leaq 0x1038(%rip), %rsi      # 0x77e3
leaq 0x1035(%rip), %rdx      # 0x77e7
jmp 0x6802
leaq 0xffb(%rip), %rsi       # 0x77b6
leaq 0xff8(%rip), %rdx       # 0x77ba
jmp 0x6802
leaq 0xfff(%rip), %rsi       # 0x77ca
leaq 0xffc(%rip), %rdx       # 0x77ce
jmp 0x6802
leaq 0xff4(%rip), %rsi       # 0x77cf
leaq 0xff1(%rip), %rdx       # 0x77d3
jmp 0x6802
leaq 0xfee(%rip), %rsi       # 0x77d9
leaq 0xfeb(%rip), %rdx       # 0x77dd
jmp 0x6802
leaq 0xffc(%rip), %rsi       # 0x77f7
leaq 0xff9(%rip), %rdx       # 0x77fb
movq %rbx, %rdi
callq 0x514e
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: hexstrToBinstr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string hexstrToBinstr(string hex)	// Funzione di conversione stringa esadecimale in stringa binaria
{
		string bin;

		for(unsigned k = 0; k != hex.length(); ++k)
		{
			bin += hexCharToBin(hex[k]);
		}

		return bin;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, -0x30(%rbp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
cmpq $0x0, 0x8(%rsi)
je 0x6899
movq %rsi, %r14
movl $0x1, %r12d
leaq -0x40(%rbp), %r13
xorl %eax, %eax
leaq -0x50(%rbp), %r15
movq (%r14), %rcx
movsbl (%rcx,%rax), %esi
movq %r15, %rdi
callq 0x66c5
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %rbx, %rdi
callq 0x3090
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x688d
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movl %r12d, %eax
incl %r12d
cmpq %rax, 0x8(%r14)
jne 0x6859
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x68c8
movq %rax, %r14
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x68c8
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq (%rbx), %rdi
cmpq -0x30(%rbp), %rdi
je 0x68e0
movq -0x30(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3250
movq %r14, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::~timer_qheap()
timer_qheap::~timer_qheap() {
    if (this->tfd != -1) {
        ::close(this->tfd);
        this->tfd = -1;
    }
    for (const auto &v : this->qheap)
        delete v;
    this->qheap.clear();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8181(%rip), %rax      # 0xefb8
addq $0x10, %rax
movq %rax, (%rdi)
movl 0x30(%rdi), %edi
cmpl $-0x1, %edi
je 0x6e52
callq 0x6820
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq 0x40(%rbx), %r14
movq 0x48(%rbx), %r15
cmpq %r15, %r14
je 0x6e7e
movq (%r14), %rdi
callq 0x6470
addq $0x8, %r14
cmpq %r15, %r14
jne 0x6e5f
movq 0x40(%rbx), %r14
cmpq %r14, 0x48(%rbx)
je 0x6e7e
movq %r14, 0x48(%rbx)
testq %r14, %r14
je 0x6e90
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6470
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0x745b
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::open()
int timer_qheap::open() {
    int fd = ::timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK|TFD_CLOEXEC);
    if (fd == -1) {
        fprintf(stderr, "reactor: timerfd_create fail! %s\n", strerror(errno));
        return -1;
    }
    this->tfd = fd;
    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x7, %edi
movl $0x80800, %esi          # imm = 0x80800
callq 0x6750
cmpl $-0x1, %eax
je 0x6ecf
movl %eax, 0x30(%rbx)
xorl %eax, %eax
popq %rbx
retq
callq 0x6860
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6ecd
nop
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::adjust_timerfd(long)
void timer_qheap::adjust_timerfd(int64_t delay /*millisecond*/) {
    struct timespec ts;
    ts.tv_sec = delay / 1000;
    ts.tv_nsec = delay % 1000 * 1000 * 1000;
    if (delay < 1)
        ts.tv_nsec = 1;
    struct itimerspec its;
    ::memset(&its, 0, sizeof(its));
    its.it_value = ts;
    ::timerfd_settime(this->tfd, 0 /*Relative time*/, &its, nullptr);
}

// Assembly:
subq $0x28, %rsp
movq %rsi, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
mulq %rcx
shrq $0x4, %rdx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
movq %rsi, %rdx
subq %rax, %rdx
imulq $0xf4240, %rdx, %rax    # imm = 0xF4240
testq %rsi, %rsi
movl $0x1, %r8d
cmovgq %rax, %r8
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, (%rax)
movq %rdx, 0x10(%rax)
movq %r8, 0x18(%rax)
movl 0x30(%rdi), %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x6370
addq $0x28, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::schedule(ev_handler*, int, int)
int timer_qheap::schedule(ev_handler *eh, const int delay, const int interval) {
    if (eh == nullptr)
        return -1;

    struct timeval tv;
    ::gettimeofday(&tv, nullptr);
    int64_t now = int64_t(tv.tv_sec) * 1000 + tv.tv_usec / 1000; // millisecond
    auto item = new timer_item();
    item->eh = eh;
    item->expire_at = now + delay;
    item->interval = interval;
    eh->set_timer(item);
    this->insert(item);

    auto min = this->qheap[0];
    if (min->expire_at != this->timerfd_settime) {
        this->adjust_timerfd(min->expire_at - now);
        this->timerfd_settime = min->expire_at;
    }
    return 0;
}

// Assembly:
testq %rsi, %rsi
je 0x6ff1
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x66b0
movabsq $0x20c49ba5e353f7cf, %rax # imm = 0x20C49BA5E353F7CF
imulq 0x8(%r14)
movq %rdx, %r15
imulq $0x3e8, (%r14), %rax    # imm = 0x3E8
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x7, %r15
addq %rcx, %r15
addq %rax, %r15
movl $0x18, %edi
callq 0x6490
movq $0x0, (%rax)
movq %r12, 0x10(%rax)
movslq %r13d, %rcx
addq %r15, %rcx
movq %rcx, 0x8(%rax)
movl %ebp, (%rax)
movq %rax, 0x28(%r12)
movq %rax, (%rsp)
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x6ff7
movq %rax, (%rsi)
movq 0x48(%rbx), %rsi
addq $0x8, %rsi
movq %rsi, 0x48(%rbx)
jmp 0x7007
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
leaq 0x40(%rbx), %rdi
movq %rsp, %rdx
callq 0x66e0
movq 0x48(%rbx), %rsi
subq 0x40(%rbx), %rsi
shrq $0x3, %rsi
decl %esi
movq %rbx, %rdi
callq 0x6520
movq 0x40(%rbx), %rax
movq (%rax), %r14
movq 0x8(%r14), %rcx
cmpq 0x38(%rbx), %rcx
je 0x70a1
subq %r15, %rcx
movq %rcx, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdi # imm = 0x20C49BA5E353F7CF
mulq %rdi
shrq $0x4, %rdx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
movq %rcx, %rdx
subq %rax, %rdx
imulq $0xf4240, %rdx, %rax    # imm = 0xF4240
testq %rcx, %rcx
movl $0x1, %esi
cmovgq %rax, %rsi
movq %rcx, %rax
imulq %rdi
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, (%rax)
movq %rdx, 0x10(%rax)
movq %rsi, 0x18(%rax)
movl 0x30(%rbx), %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x6370
movq 0x8(%r14), %rax
movq %rax, 0x38(%rbx)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::shift_up(int)
void timer_qheap::shift_up(int idx) {
    auto item = this->qheap[idx];
    while (idx > 0
        && item->expire_at < this->qheap[get_parent_index(idx)]->expire_at) {
        this->qheap[idx] = this->qheap[get_parent_index(idx)];
        idx = get_parent_index(idx);
    }
    this->qheap[idx] = item;
}

// Assembly:
movslq %esi, %rdx
movq 0x40(%rdi), %rcx
movq (%rcx,%rdx,8), %rax
testl %edx, %edx
jle 0x7111
movq 0x8(%rax), %r8
leal -0x1(%rsi), %r9d
movl %r9d, %edx
shrl $0x2, %edx
movq 0x40(%rdi), %rcx
movq (%rcx,%rdx,8), %r10
cmpq 0x8(%r10), %r8
jge 0x710d
movl %esi, %esi
movq %r10, (%rcx,%rsi,8)
movl %edx, %esi
cmpl $0x3, %r9d
ja 0x70e1
movq 0x40(%rdi), %rcx
jmp 0x710f
movl %esi, %edx
movl %edx, %edx
movq %rax, (%rcx,%rdx,8)
retq
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::shift_down(int)
void timer_qheap::shift_down(int idx) {
    int min_child = 0;
    auto item = this->qheap[idx];
    while (true) {
        min_child = get_child_index(idx, 0);
        if (min_child >= static_cast<int>(this->qheap.size()))
            break;

        for (int i = 1; i < 4; ++i) {
            int child_idx = get_child_index(idx, i);
            if (child_idx < static_cast<int>(this->qheap.size())
                && this->qheap[child_idx]->expire_at < this->qheap[min_child]->expire_at)
                min_child = child_idx;
        }

        if (this->qheap[min_child]->expire_at >= item->expire_at)
            break;

        this->qheap[idx] = this->qheap[min_child];
        idx = min_child;
    }
    this->qheap[idx] = item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq %esi, %r9
movq 0x40(%rdi), %rcx
movq 0x48(%rdi), %r11
movq (%rcx,%r9,8), %rax
leal 0x1(,%rsi,4), %r10d
subq %rcx, %r11
shrq $0x3, %r11
cmpl %r11d, %r10d
jge 0x71ca
leal (,%rsi,4), %ebx
movq 0x8(%rax), %rdx
movslq %ebx, %r9
movslq %r11d, %r11
addq $0x2, %r9
movl $0x3, %ebx
movl %r10d, %r8d
cmpq %r11, %r9
jge 0x7182
movq (%rcx,%r9,8), %r10
movq 0x8(%r10), %r14
movslq %r8d, %r10
movq (%rcx,%r10,8), %r15
movl %r9d, %r10d
cmpq 0x8(%r15), %r14
jl 0x717f
movl %r8d, %r10d
movl %r10d, %r8d
incq %r9
decq %rbx
jne 0x715f
movslq %r8d, %r9
movq (%rcx,%r9,8), %r10
movslq %esi, %rsi
cmpq %rdx, 0x8(%r10)
jge 0x71c7
movq %r10, (%rcx,%rsi,8)
leal (,%r8,4), %ebx
leal 0x1(,%r8,4), %r10d
movq 0x40(%rdi), %rcx
movq 0x48(%rdi), %r11
subq %rcx, %r11
shrq $0x3, %r11
movl %r8d, %esi
cmpl %r11d, %r10d
jl 0x714d
jmp 0x71ca
movq %rsi, %r9
movq %rax, (%rcx,%r9,8)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/shaovie[P]reactor/src/poller.cpp
// Function: poller::destroy()
void poller::destroy() {
    if (this->efd == -1) {
        ::close(this->efd);
        this->efd = -1;
    }
    if (this->poll_descs != nullptr) {
        delete this->poll_descs;
        this->poll_descs = nullptr;
    }
    if (this->ready_events != nullptr) {
        delete[] this->ready_events;
        this->ready_events = nullptr;
    }
    if (this->io_buf != nullptr) {
        delete[] this->io_buf;
        this->io_buf = nullptr;
    }
    if (this->timer != nullptr) {
        delete this->timer;
        this->timer = nullptr;
    }
    if (this->async_sendq != nullptr) {
        delete this->async_sendq;
        this->async_sendq = nullptr;
    }
    if (this->poll_sync_opterate != nullptr) {
        delete this->poll_sync_opterate;
        this->poll_sync_opterate = nullptr;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $-0x1, 0x4(%rdi)
jne 0x7842
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x6820
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x7863
movq %r14, %rdi
callq 0x64d0
movq %r14, %rdi
callq 0x6470
movq $0x0, 0x30(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x7879
callq 0x6570
movq $0x0, 0x18(%rbx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x788f
callq 0x6570
movq $0x0, 0x10(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x78a6
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x20(%rbx)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x78bd
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x28(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x78d4
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq