LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/render.c
// Function: Renderer_Putpixel
void Renderer_Putpixel( SDL_Surface *surface, int x, int y, uint32_t pixel ) {
    if ( x > surface->w || x < 0 || y > surface->h || y < 0 )
        return;
    int bpp = surface->format->BytesPerPixel;
    uint8_t *p = (uint8_t *)surface->pixels + y * surface->pitch + x * bpp;
    switch(bpp) {
    case 1:
        *p = pixel;
        break;
    case 2:
        *(uint16_t *)p = pixel;
        break;
    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
            p[0] = (pixel >> 16) & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = pixel & 0xff;
        } else {
            p[0] = pixel & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = (pixel >> 16) & 0xff;
        }
        break;
    case 4:
        *(uint32_t *)p = pixel;
        break;
    }
}

// Assembly:
testl %esi, %esi
js 0x62ca
cmpl %esi, 0x10(%rdi)
jl 0x62ca
testl %edx, %edx
js 0x62ca
cmpl %edx, 0x14(%rdi)
jl 0x62ca
movq 0x8(%rdi), %rax
movzbl 0x11(%rax), %r9d
leal -0x1(%r9), %r8d
cmpl $0x3, %r8d
ja 0x62ca
movslq 0x18(%rdi), %r10
movslq %edx, %rax
imulq %r10, %rax
addq 0x20(%rdi), %rax
movl %esi, %edx
imulq %r9, %rdx
leaq 0x29d2(%rip), %rsi      # 0x8c90
movslq (%rsi,%r8,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movb %cl, (%rax,%rdx)
retq
movb %cl, (%rax,%rdx)
movb %ch, 0x1(%rax,%rdx)
shrl $0x10, %ecx
movb %cl, 0x2(%rax,%rdx)
retq
movl %ecx, (%rax,%rdx)
retq
movw %cx, (%rax,%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/render.c
// Function: Renderer_DrawWorld
void Renderer_DrawWorld( renderer_t *renderer, SDL_Surface *Surface ) {
	scene_t *scene = renderer->scene;
    SDL_FillRect( Surface, NULL, SDL_MapRGB( Surface->format, 0x00, 0x00, 0x00 ) );
    Renderer_ClearZBuffer( renderer );
    node_t *objList_node = List_Head( Scene_GetObjectList( scene ) );

    while( objList_node != NULL ) {
        Renderer_DrawObject( scene, renderer, List_Data(objList_node), Surface );
        objList_node = objList_node->next;
    }
    renderer->frameCount++;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movq 0x8(%rsi), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10a0
movq %r14, %rdi
xorl %esi, %esi
movl %eax, %edx
callq 0x1060
movq 0x18(%rbx), %rax
movl $0x7f7fffff, (%rax,%r12,4) # imm = 0x7F7FFFFF
incq %r12
cmpq $0xe1000, %r12          # imm = 0xE1000
jne 0x6821
movq %r15, %rdi
callq 0x696e
movq 0x18(%rax), %r12
testq %r12, %r12
je 0x685f
movq (%r12), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x6317
movq 0x8(%r12), %r12
jmp 0x6841
incl 0x24(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/render.c
// Function: Renderer_Destroy
void Renderer_Destroy( renderer_t *renderer ) {
    if( renderer != NULL ) {
        free( renderer->z_Buffer );
        renderer->z_Buffer = NULL;
        printf( "\nRendered frames: %d\n", renderer->frameCount );
        free( renderer );
    }
}

// Assembly:
testq %rdi, %rdi
je 0x68a2
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x1288
movq $0x0, 0x18(%rbx)
movl 0x24(%rbx), %esi
leaq 0x241e(%rip), %rdi      # 0x8cb0
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
popq %rbx
jmp 0x1288
retq
nop
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/scene.c
// Function: Scene_Init
scene_t *Scene_Init( camera_t *camera ) {
    scene_t *scene = (scene_t *)malloc(sizeof(scene_t));
    if(scene == NULL) {
        printf( "Error: Cannot create scene!\n" );
        return NULL;
    }

    scene->objectList = (List *)malloc(sizeof(List));
    List_Init( scene->objectList, &Model_Test, &Model_Free );

    scene->mainCamera   = camera;
    scene->directLight = vec3_create( 0.0f, 5.0f, 5.0f );
	scene->directLightColor = vec3_create( 1.0f, 1.0f, 1.0f );
	scene->ambientLightColor = vec3_create( 1.0f, 1.0f, 1.0f );
    scene->currentState = SCENE_STATE_UPDATABLE;
    return scene;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x40, %edi
callq 0x11a0
testq %rax, %rax
je 0x6945
movq %rax, %rbx
movl $0x28, %edi
callq 0x11a0
movq %rax, 0x30(%rbx)
leaq -0xf82(%rip), %rsi      # 0x5954
leaq -0x1b47(%rip), %rdx     # 0x4d96
movq %rax, %rdi
callq 0x1d00
movq %r14, (%rbx)
movss 0x1738(%rip), %xmm1     # 0x8028
xorps %xmm0, %xmm0
movaps %xmm1, %xmm2
callq 0x2a5a
movlps %xmm0, 0x8(%rbx)
movss %xmm1, 0x10(%rbx)
movss 0x1708(%rip), %xmm0     # 0x8014
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x2a5a
movlps %xmm0, 0x14(%rbx)
movss %xmm1, 0x1c(%rbx)
movss 0x16ec(%rip), %xmm0     # 0x8014
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x2a5a
movlps %xmm0, 0x20(%rbx)
movss %xmm1, 0x28(%rbx)
movl $0x1, 0x38(%rbx)
jmp 0x6953
leaq 0x23af(%rip), %rdi      # 0x8cfb
callq 0x11f0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/scene.c
// Function: Scene_FindObjectByName
obj_model_t *Scene_FindObjectByName( scene_t *scene, char *name ) {
	List        *objList = Scene_GetObjectList( scene );
	node_t      *curr    = List_Head( objList );
	obj_model_t *obj     = NULL;
	
	int isFound = FALSE;
	
	while( curr != NULL ) {
		if( strstr( Model_GetName(List_Data(curr)), name ) ) {
			isFound = TRUE;
			break;
		}
        curr = curr->next;
    }
    if(isFound){
		obj = List_Data(curr);
	} else {
		printf( "SceneWarn: Object \"%s\" not found!\n", name );
	}
	return obj;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq 0x30(%rdi), %rax
movq 0x18(%rax), %r14
testq %r14, %r14
je 0x69cb
movq (%r14), %rdi
callq 0x5950
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1090
testq %rax, %rax
jne 0x69e1
movq 0x8(%r14), %r14
jmp 0x69a8
leaq 0x2306(%rip), %rdi      # 0x8cd8
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1040
jmp 0x69e4
movq (%r14), %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/shader.c
// Function: Shader_Vertex
vec4 Shader_Vertex( shader_t *shader, vertex_t *vert, int index ) {
	//mat4_setColVec2( &shader->var_uv, vert->uv, index );
	//mat4_setColVec4( &shader->var_nrm, vec4_byMat4( vert->normal, shader->m_it ), index );
	//mat4_setColVec4( &shader->var_pos, vec4_byMat4( vert->position, shader->m ), index );
	shader->pos[index]     = vec4_byMat4( vert->position, shader->m );
	shader->normals[index] = vec4_byMat4( vert->normal, shader->m_it );
	shader->uvs[index]     = vert->uv;
	return vec4_byMat4( vert->position, shader->mvp );
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movslq %edx, %r15
movq %r15, %r12
shlq $0x4, %r12
movsd (%rsi), %xmm0
movsd 0x8(%rsi), %xmm1
callq 0x2f94
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0x100(%rbx,%r12)
leaq 0x80(%rbx), %rdi
movsd 0x10(%r14), %xmm0
movsd 0x18(%r14), %xmm1
callq 0x2f94
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0x130(%rbx,%r12)
movq 0x20(%r14), %rax
movq %rax, 0x1cc(%rbx,%r15,8)
addq $0xc0, %rbx
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2f94
// File: /workspace/github_c_makefile_star2_O1/Nealsbo[P]C-Software-Renderer/src/shader.c
// Function: Shader_SetMatrices
void Shader_SetMatrices( shader_t *shader, mat4 model, mat4 view, mat4 mvp ) {
	mat4 tmp;
	mat4_copy( model, shader->m );
	mat4_copy( view, shader->v );
	
	mat4_inv( shader->m, tmp );
	mat4_tsp( tmp, shader->m_it );
	
	mat4_copy( mvp, shader->mvp );
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x3c83
leaq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x3c83
movq %rsp, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x3176
leaq 0x80(%r15), %rsi
movq %r14, %rdi
callq 0x314c
addq $0xc0, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c83
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readInt
int
readInt(FILE *fp)
    {
    int x,result;
    result = fscanf(fp,"%d",&x);
    if (result == EOF)
        {
        return 0;
        }
    if (result == 0)
        {
        fprintf(stderr,"SCAN ERROR: attempt to read an integer failed\n");
        fprintf(stderr,"offending character was <%c>\n",fgetc(fp));
        exit(1);
        }
    return x;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x1663(%rip), %rsi      # 0x369c
xorl %r14d, %r14d
leaq -0x14(%rbp), %rdx
xorl %eax, %eax
callq 0x1040
cmpl $-0x1, %eax
je 0x2054
testl %eax, %eax
je 0x2060
movl -0x14(%rbp), %r14d
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
callq 0x11d0
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readReal
double
readReal(FILE *fp)
    {
    int result;
    double x;
    result = fscanf(fp," %lf",&x);
    if (result == EOF)
        {
        return 0.0;
        }
    if (result == 0)
        {
        fprintf(stderr,"SCAN ERROR: attempt to read a real number failed\n");
        fprintf(stderr,"offending character was <%c>\n",fgetc(fp));
        exit(2);
        }
    return x;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1674(%rip), %rsi      # 0x36ec
leaq -0x10(%rbp), %rdx
xorl %eax, %eax
callq 0x1040
xorps %xmm0, %xmm0
cmpl $-0x1, %eax
je 0x2094
testl %eax, %eax
je 0x209b
movsd -0x10(%rbp), %xmm0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x121c
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readChar
char
readChar(FILE *fp)
    {
    int result;
    char x;
    result = fscanf(fp," %c",&x);
    if (result == EOF)
        {
        return -1;
        }
    if (result == 0)
        {
        fprintf(stderr,"SCAN ERROR: attempt to read a non-whitespace character failed\n");
        fprintf(stderr,"offending character was <%c>\n",fgetc(fp));
        exit(2);
        }
    return x;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1670(%rip), %rsi      # 0x3723
leaq -0x9(%rbp), %rdx
xorl %eax, %eax
callq 0x1040
movl %eax, %ecx
movb $-0x1, %al
cmpl $-0x1, %ecx
je 0x20ce
testl %ecx, %ecx
je 0x20d5
movb -0x9(%rbp), %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x1268
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readRawChar
char
readRawChar(FILE *fp)
    {
    int result;
    char x;
    result = fscanf(fp,"%c",&x);
    if (result == EOF)
        {
        return -1;
        }
    if (result == 0)
        {
        fprintf(stderr,"SCAN ERROR: attempt to read a raw character failed\n");
        fprintf(stderr,"offending character was <%c>\n",fgetc(fp));
        exit(2);
        }
    return x;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1637(%rip), %rsi      # 0x3724
leaq -0x9(%rbp), %rdx
xorl %eax, %eax
callq 0x1040
movl %eax, %ecx
movb $-0x1, %al
cmpl $-0x1, %ecx
je 0x2108
testl %ecx, %ecx
je 0x210f
movb -0x9(%rbp), %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x12b4
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readString
char *
readString(FILE *fp)
    {
    int ch,index;
    char *buffer;
    int size = 512;

    /* advance to the double quote */

    skipWhiteSpace(fp);

    ch = fgetc(fp);
    if (ch == EOF) return 0;

    /* allocate the buffer */

    buffer = allocateMsg(size,"readString");

    if (ch != '\"')
        {
        fprintf(stderr,"SCAN ERROR: attempt to read a string failed\n");
        fprintf(stderr,"first character was <%c>\n",ch);
        exit(4);
        }

    /* toss the double quote, skip to the next character */

    ch = fgetc(fp);

    /* initialize the buffer index */

    index = 0;

    /* collect characters until the closing double quote */

    while (ch != '\"')
        {
        if (ch == EOF)
            {
            fprintf(stderr,"SCAN ERROR: attempt to read a string failed\n");
            fprintf(stderr,"no closing double quote\n");
            exit(6);
            }
        if (index > size - 2) 
            {
            ++size;
            buffer = reallocateMsg(buffer,size,"readString");
            }

        if (ch == '\\')
            {
            ch = fgetc(fp);
            if (ch == EOF)
                {
                fprintf(stderr,"SCAN ERROR: attempt to read a string failed\n");
                fprintf(stderr,"escaped character missing\n");
                exit(6);
                }
            buffer[index] = convertEscapedChar(ch);
            }
        else
            buffer[index] = ch;
        ++index;
        ch = fgetc(fp);
        }

    buffer[index] = '\0';

    return buffer;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x222d
movq %rbx, %rdi
callq 0x10b0
cmpl $-0x1, %eax
je 0x2206
movl %eax, %r15d
leaq 0x1652(%rip), %rsi      # 0x379a
movl $0x200, %edi            # imm = 0x200
callq 0x2268
cmpl $0x22, %r15d
jne 0x2225
movq %rax, %r14
movl $0x200, %r15d           # imm = 0x200
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x10b0
cmpl $0x22, %eax
je 0x21fc
movl %eax, %r12d
cmpl $-0x1, %eax
je 0x221b
leal -0x2(%r15), %eax
cltq
cmpq %rax, %r13
jle 0x21a8
incl %r15d
movslq %r15d, %rsi
movq %r14, %rdi
leaq 0x15fa(%rip), %rdx      # 0x379a
callq 0x228a
movq %rax, %r14
cmpl $0x5c, %r12d
jne 0x21f0
movq %rbx, %rdi
callq 0x10b0
movl %eax, %r12d
cmpl $0x6d, %eax
jg 0x21cf
cmpl $0x22, %r12d
je 0x21e5
cmpl $0x5c, %r12d
jne 0x21ea
movb $0x5c, %r12b
jmp 0x21f0
cmpl $0x6e, %r12d
je 0x21e0
cmpl $0x74, %r12d
jne 0x21f0
movb $0x9, %r12b
jmp 0x21f0
movb $0xa, %r12b
jmp 0x21f0
movb $0x22, %r12b
jmp 0x21f0
cmpl $-0x1, %r12d
je 0x2220
movb %r12b, (%r14,%r13)
incq %r13
jmp 0x2168
movl %r13d, %eax
movb $0x0, (%r14,%rax)
jmp 0x2209
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1340
callq 0x1383
movl %r15d, %edi
callq 0x1300
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: allocateMsg
void *
allocateMsg(size_t size,char *where)
    {
    char *s;
    s = malloc(size);
    if (s == 0)
        {
        fprintf(stderr,"%s: could not allocate string, out of memory\n",
            where);
        exit(3);
        }

    return s;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
callq 0x1120
testq %rax, %rax
je 0x2282
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x13c6
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: reallocateMsg
static void *
reallocateMsg(void *s,size_t size,char *where)
    {
    char *t;
    t = realloc(s,size);
    if (t == 0)
        {
        fprintf(stderr,"%s: could not reallocate string, out of memory\n",
            where);
        exit(3);
        }

    return t;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdx, %rbx
callq 0x1140
testq %rax, %rax
je 0x22a4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x13ed
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readToken
char *
readToken(FILE *fp)
    {
    int ch,index;
    char *buffer;
    int size = 80;

    skipWhiteSpace(fp);

    ch = fgetc(fp);
    if (ch == EOF) return 0;

    buffer = allocateMsg(size,"readToken");

    index = 0;
    while (!isspace(ch))
        {
        if (ch == EOF) break;
        if (index > size - 2)
            {
            ++size;
            buffer = reallocateMsg(buffer,size,"readToken");
            }
        buffer[index] = ch;
        ++index;
        ch = fgetc(fp);
        }

    /* push back the character that got us out of this loop */

    ungetc(ch,fp);

    if (index > 0)              //there is something in the buffer
        clearerr(fp);           //so force the read to be good

    buffer[index] = '\0';

    return buffer;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x222d
movq %rbx, %rdi
callq 0x10b0
xorl %r13d, %r13d
cmpl $-0x1, %eax
je 0x237f
movl %eax, %r15d
leaq 0x1540(%rip), %rsi      # 0x3820
movl $0x50, %edi
callq 0x2268
movq %rax, %r14
callq 0x11b0
movq %rax, %r12
movq (%rax), %rax
movslq %r15d, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x235d
movq %rbx, -0x30(%rbp)
movl $0x50, %ebx
xorl %r13d, %r13d
leal -0x2(%rbx), %eax
cltq
cmpq %rax, %r13
jle 0x232f
incl %ebx
movslq %ebx, %rsi
movq %r14, %rdi
leaq 0x14f9(%rip), %rdx      # 0x3820
callq 0x228a
movq %rax, %r14
movb %r15b, (%r14,%r13)
incq %r13
movq -0x30(%rbp), %rdi
callq 0x10b0
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x2359
movq (%r12), %rax
movslq %r15d, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
je 0x230e
movq -0x30(%rbp), %rbx
movl %r15d, %edi
movq %rbx, %rsi
callq 0x1130
testl %r13d, %r13d
je 0x2375
movq %rbx, %rdi
callq 0x1100
movl %r13d, %eax
movb $0x0, (%r14,%rax)
jmp 0x2382
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/phrases/scanner.c
// Function: readLine
char *
readLine(FILE *fp)
    {
    int ch,index;
    char *buffer;
    int size = 512;
    
    ch = fgetc(fp);
    if (ch == EOF) return 0;

    buffer = allocateMsg(size,"readLine");

    index = 0;
    while (ch != '\n')
        {
        if (ch == EOF) break;
        if (index > size - 2)
            {
            ++size;
            buffer = reallocateMsg(buffer,size,"readLine");
            }
        buffer[index] = ch;
        ++index;
        ch = fgetc(fp);
        }


    if (index > 0)              //there is something in the buffer
        clearerr(fp);           //so force the read to be good

    buffer[index] = '\0';

    return buffer;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x10b0
cmpl $-0x1, %eax
je 0x2429
movl %eax, %r12d
leaq 0x1471(%rip), %rsi      # 0x382a
movl $0x200, %edi            # imm = 0x200
callq 0x2268
movq %rax, %r14
movl $0x200, %r15d           # imm = 0x200
xorl %r13d, %r13d
cmpl $-0x1, %r12d
je 0x2412
cmpl $0xa, %r12d
je 0x2412
leal -0x2(%r15), %eax
cltq
cmpq %rax, %r13
jle 0x23fe
incl %r15d
movslq %r15d, %rsi
movq %r14, %rdi
leaq 0x1434(%rip), %rdx      # 0x382a
callq 0x228a
movq %rax, %r14
movb %r12b, (%r14,%r13)
incq %r13
movq %rbx, %rdi
callq 0x10b0
movl %eax, %r12d
jmp 0x23cf
testq %r13, %r13
je 0x241f
movq %rbx, %rdi
callq 0x1100
movl %r13d, %eax
movb $0x0, (%r14,%rax)
jmp 0x242c
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_wipe
int JFDB_wipe(const char *path) {
  // remove keys & vals, flag if either one fails
  int failed = 0;
  char fp[JFDB_MAX_PATH + 6];
  snprintf(fp, sizeof(fp), "%s.keys", path);
  remove(fp);
  switch (errno) {
    case 0:
    case ENOENT:
      break;
    default:
      failed |= JFDB_KEYS;
      break;
  }
  snprintf(fp, sizeof(fp), "%s.vals", path);
  remove(fp);
  switch (errno) {
    case 0:
    case ENOENT:
      break;
    default:
      failed |= JFDB_VALS;
      break;
  }
  return failed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %rbx
leaq 0x548e(%rip), %rdx      # 0x70bd
movq %rsp, %r14
movl $0x406, %esi            # imm = 0x406
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
callq 0x1060
callq 0x1040
movq %rax, %r15
xorl %ebp, %ebp
testl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
setne %bpl
leaq 0x545e(%rip), %rdx      # 0x70c5
movl $0x406, %esi            # imm = 0x406
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
callq 0x1060
testl $0xfffffffd, (%r15)     # imm = 0xFFFFFFFD
je 0x1c8d
orl $0x2, %ebp
movl %ebp, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.h
// Function: JFDB_set_error
static inline JFDB *JFDB_set_error(JFDB *db, int code, const char *fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  db->error = code;
  vsnprintf(db->errstr, JFDB_MAX_ERRSTR, fmt, ap);
  va_end(ap);
  return db;
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x1f07
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
movl %esi, 0x88(%rbx)
leaq 0x8(%rbx), %rdi
movl $0x80, %esi
callq 0x1070
movq %rbx, %rax
addq $0xd0, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_file_open
static int JFDB_file_open(JFDB *db, const char *path) {
  // get the fd for keys & vals, and sanity check that they look like valid files
  // vals has a different header, but the magic / version are the same
  int fd;
  if ((fd = open(path, O_RDWR, 0644)) < 0) {
    if (errno == ENOENT) {
      if ((fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0644)) < 0) {
        JFDB_set_error(db, JFDB_EFILE, "could not create ('%.32s')", path);
      } else {
        // new file: write the header
        db->tip.magic = JFDB_MAGIC;
        db->tip.version = JFDB_VERSION;
        if (write(fd, &db->tip, sizeof(db->tip)) < sizeof(db->tip))
          JFDB_set_error(db, JFDB_EFILE, "failed to write ('%.32s')", path);
      }
    } else {
      JFDB_set_error(db, JFDB_EFILE, "cannot open file ('%.32s')", path);
    }
  } else {
    // existing file: read the header
    if (read(fd, &db->tip, sizeof(db->tip)) < sizeof(db->tip))
      JFDB_set_error(db, JFDB_EFILE, "failed to read ('%.32s')", path);
    else if (db->tip.magic != JFDB_MAGIC && db->tip.version != JFDB_VERSION)
      JFDB_set_error(db, JFDB_EFILE, "invalid file ('%.32s')", path);
  }
  return fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
movl $0x2, %esi
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x1190
movl %eax, %ebp
testl %eax, %eax
js 0x1f93
leaq 0xc0(%r14), %r15
movl $0x70, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x1110
cmpq $0x70, %rax
jae 0x1fe4
leaq 0x5382(%rip), %rdx      # 0x7313
jmp 0x2010
callq 0x1040
cmpl $0x2, (%rax)
jne 0x2000
movq %rbx, %rdi
movl $0xc2, %esi
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x1190
movl %eax, %ebp
testl %eax, %eax
js 0x2009
leaq 0xc0(%r14), %rsi
movq $0x7fdb, 0xc0(%r14) # imm = 0x7FDB
movl $0x70, %edx
movl %ebp, %edi
callq 0x1080
cmpq $0x70, %rax
jae 0x2022
leaq 0x52fc(%rip), %rdx      # 0x72de
jmp 0x2010
cmpl $0x7fdb, (%r15)         # imm = 0x7FDB
je 0x2022
cmpl $0x0, 0xc4(%r14)
je 0x2022
leaq 0x532e(%rip), %rdx      # 0x732c
jmp 0x2010
leaq 0x52f1(%rip), %rdx      # 0x72f8
jmp 0x2010
leaq 0x52b3(%rip), %rdx      # 0x72c3
movq %r14, %rdi
movl $0x4, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1eb0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_mmap_file
static int JFDB_mmap_file(JFDB *db, int kv, size_t cover, int factor) {
  // if the mmap already includes cover, do nothing
  // otherwise increase the mapping by a size of factor
  JFDB_MMap *m = kv == JFDB_KEYS ? &db->kmap : &db->vmap;
  if (m->size >= cover)
    return 0;

  // we need to remap the memory, there are some open questions and TODOs:
  //  - if we munmap before mmapping again:
  //     we temporarily release the references to the underlying memory
  //     potentially allowing us to re-use the address range
  //     potentially avoiding TLB misses if the OS hasn't released the memory
  //     there's a lot of potential but it could just as easily work against us
  //  - if we mmap again before munmapping:
  //     we ensure that we always retain a reference to the memory
  //     however we are guaranteed to get a different address range
  //  - XXX: we should be taking advantage of mremap when it's available
  //  - alternatively, we could impose an upper bound on the file size and map it once
  //    but its not polite (at best) for a library to hog the address space like that
  //  - we map nearest multiple of PAGESIZE, for which we will anyway incur the cost
  int prot = kv == JFDB_KEYS ? PROT_READ | PROT_WRITE : PROT_READ;
  if (m->size)
    munmap(m->map, m->size);
  m->size = RTM(cover * factor, sysconf(_SC_PAGESIZE));
  m->map = mmap(NULL, m->size, prot, MAP_SHARED, m->fd, 0);
  if (m->map == MAP_FAILED)
    JFDB_set_error(db, JFDB_EMMAP, "cannot mmap %s", kv == JFDB_KEYS ? "keys" : "vals");
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
cmpl $0x1, %esi
movl $0x90, %eax
movl $0xa8, %r13d
cmoveq %rax, %r13
movq 0x10(%rdi,%r13), %rsi
cmpq %rdx, %rsi
jae 0x20eb
movl %ecx, %r12d
movq %rdx, %r15
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x1, %ebp
sete %al
leal 0x1(,%rax,2), %r14d
testq %rsi, %rsi
je 0x2084
movq 0x8(%rbx,%r13), %rdi
callq 0x1170
movl %r12d, %r12d
imulq %r15, %r12
movl $0x1e, %edi
callq 0x11a0
leaq (%r12,%rax), %r15
decq %r15
movl $0x1e, %edi
callq 0x11a0
movq %rax, %rcx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r15
movl $0x1e, %edi
callq 0x11a0
imulq %rax, %r15
movq %r15, 0x10(%rbx,%r13)
movl (%rbx,%r13), %r8d
xorl %edi, %edi
movq %r15, %rsi
movl %r14d, %edx
movl $0x1, %ecx
xorl %r9d, %r9d
callq 0x10b0
movq %rax, 0x8(%rbx,%r13)
cmpq $-0x1, %rax
je 0x20fa
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %ebp
leaq 0x50cf(%rip), %rax      # 0x71d3
leaq 0x50b3(%rip), %rcx      # 0x71be
cmoveq %rax, %rcx
leaq 0x522d(%rip), %rdx      # 0x7343
movq %rbx, %rdi
movl $0x5, %esi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1eb0
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_close
JFDB *JFDB_close(JFDB *db) {
  // NB: after calling close, it is not safe to call any other db operations
  //     however, if close fails, it is safe to try and call close again
  // if for some strange reason we can't flush, don't free our resources yet
  if (db->isModified)
    if (JFDB_has_error(JFDB_flush(db)))
      return db;

  // release the mmaps and buffers
  JFDB_mmap_release(db, JFDB_KEYS);
  JFDB_mmap_release(db, JFDB_VALS);
  JFDB_mbuf_release(db, 0);
  JFDB_mbuf_release(db, 1);

  // possibly wipe the files, not normally failable as we just had the path open
  if (db->flags & JFDB_TEMPORARY)
    if (JFDB_wipe(db->path))
      return JFDB_set_error(db, JFDB_EFILE, "failed to wipe files");

  // completely free
  free(db->path);
  free(db);
  return NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x980(%rdi)
je 0x2857
movq %rbx, %rdi
callq 0x28e5
testq %rbx, %rbx
je 0x28e0
cmpl $0x0, 0x88(%rbx)
jne 0x28e0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2cd0
movq %rbx, %rdi
movl $0x2, %esi
callq 0x2cd0
movq 0x988(%rbx), %rdi
testq %rdi, %rdi
je 0x2889
callq 0x5aa1
movq %rax, 0x988(%rbx)
movq 0x990(%rbx), %rdi
testq %rdi, %rdi
je 0x28a1
callq 0x5aa1
movq %rax, 0x990(%rbx)
testb $0x1, 0x8c(%rbx)
je 0x28ce
movq (%rbx), %rdi
callq 0x1c18
testl %eax, %eax
je 0x28ce
leaq 0x484a(%rip), %rdx      # 0x7107
movq %rbx, %rdi
movl $0x4, %esi
xorl %eax, %eax
callq 0x1eb0
jmp 0x28e0
movq (%rbx), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_mmap_release
static void JFDB_mmap_release(JFDB *db, int kv) {
  JFDB_MMap *m = kv == JFDB_KEYS ? &db->kmap : &db->vmap;
  if (m->map != MAP_FAILED)
    munmap(m->map, m->size);
  if (m->fd >= 0)
    close(m->fd);
  m->size = 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x1, %esi
movl $0x90, %eax
movl $0xa8, %r14d
cmoveq %rax, %r14
movq 0x8(%rdi,%r14), %rdi
cmpq $-0x1, %rdi
je 0x2cfe
movq 0x10(%rbx,%r14), %rsi
callq 0x1170
movl (%rbx,%r14), %edi
testl %edi, %edi
js 0x2d0b
callq 0x1100
movq $0x0, 0x10(%rbx,%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_annul
JFDB *JFDB_annul(JFDB *db, const JFT_Stem *primary, int flags) {
  JFT_Leaf leaf = (JFT_Leaf) {};
  JFT *tx = JFT_atom(primary, &leaf, NULL, 0, db->scratch[0], db->scratch[1]);
  if (!tx)
    return JFDB_set_error(db, JFDB_ETRIE, "failed to create atom");
  return JFDB_write(db, tx, flags);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %rax
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq 0x988(%rdi), %r8
movq 0x990(%rdi), %r9
movq %rax, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4fc6
testq %rax, %rax
je 0x331f
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x2d1c
jmp 0x3335
leaq 0x3e5c(%rip), %rdx      # 0x7182
movq %rbx, %rdi
movl $0x6, %esi
xorl %eax, %eax
callq 0x1eb0
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_store
JFDB *JFDB_store(JFDB *db,
                 const JFT_Stem *restrict primary,
                 const JFT_Stem *restrict value,
                 const JFT_Stem *restrict indices,
                 JFT_Count numIndices,
                 int flags) {
  JFDB_Region region = JFDB_valloc(db, value->size);
  if (JFDB_has_error(db))
    return db;
  if (pwrite(db->vmap.fd, value->data, value->size, JFDB_voffset(region)) < value->size)
    return JFDB_set_error(db, JFDB_EFILE, "failed to write value");

  JFT_Leaf leaf = (JFT_Leaf) {.size = 1, .data = (JFT_Word *)&region};
  JFT *tx = JFT_atom(primary, &leaf, indices, numIndices, db->scratch[0], db->scratch[1]);
  if (!tx)
    return JFDB_set_error(db, JFDB_ETRIE, "failed to create atom");
  return JFDB_write(db, tx, flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, 0x8(%rsp)
movl %r8d, 0xc(%rsp)
movq %rcx, %r15
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %rbx
movzwl 0x8(%rdx), %r13d
leaq 0xff(%r13), %rax
movl %eax, %ecx
shrl $0x8, %ecx
andl $0x1ff00, %eax          # imm = 0x1FF00
xorl %edx, %edx
xorl %esi, %esi
movl 0xd4(%rbx,%rdx,8), %edi
cmpl %edi, %eax
ja 0x33aa
movl 0xd0(%rbx,%rdx,8), %r14d
leal (%r14,%rcx), %r8d
movl %r8d, 0xd0(%rbx,%rdx,8)
movl %edi, %r8d
subl %eax, %r8d
movl %r8d, 0xd4(%rbx,%rdx,8)
cmpl %edi, %eax
jbe 0x33c3
cmpq $0x7, %rdx
leaq 0x1(%rdx), %rdi
setae %sil
movq %rdi, %rdx
cmpq $0x8, %rdi
jne 0x337d
testb $0x1, %sil
je 0x342a
movl $0xff, %esi
addq 0x118(%rbx), %rsi
movq %rsi, %r14
shrq $0x8, %r14
andl $0xffffff00, %esi       # imm = 0xFFFFFF00
addq %r13, %rsi
movq %rsi, 0x118(%rbx)
movl 0xa8(%rbx), %edi
callq 0x10e0
testl %eax, %eax
je 0x3411
leaq 0x3f50(%rip), %rdx      # 0x7352
movq %rbx, %rdi
movl $0x4, %esi
xorl %eax, %eax
callq 0x1eb0
movq 0x118(%rbx), %rdx
movq %rbx, %rdi
movl $0x2, %esi
movl $0x2, %ecx
callq 0x202f
movq %r13, %rax
shlq $0x20, %rax
movl %r14d, %ecx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
testq %rbx, %rbx
je 0x34da
cmpl $0x0, 0x88(%rbx)
jne 0x34da
movl 0xa8(%rbx), %edi
movq 0x10(%rbp), %rsi
shll $0x8, %ecx
movq %r13, %rdx
callq 0x1180
cmpq %r13, %rax
jge 0x347d
leaq 0x3d25(%rip), %rdx      # 0x7198
movq %rbx, %rdi
movl $0x4, %esi
jmp 0x34d3
leaq 0x18(%rsp), %rsi
movl $0x1, (%rsi)
leaq 0x10(%rsp), %rax
movq %rax, 0x8(%rsi)
movq 0x988(%rbx), %r8
movq 0x990(%rbx), %r9
movq %r12, %rdi
movq %r15, %rdx
movl 0xc(%rsp), %ecx
callq 0x4fc6
testq %rax, %rax
je 0x34c4
movq %rbx, %rdi
movq %rax, %rsi
movl 0x8(%rsp), %edx
callq 0x2d1c
jmp 0x34da
leaq 0x3cb7(%rip), %rdx      # 0x7182
movq %rbx, %rdi
movl $0x6, %esi
xorl %eax, %eax
callq 0x1eb0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_get_value
JFT_Stem *JFDB_get_value(JFDB *db, JFT *node, JFT_Stem *value) {
  JFT_Leaf leaf = JFT_leaf(node);
  if (leaf.size == 0)
    return NULL;
  JFDB_Region region = *(JFDB_Region *)leaf.data;
  value->size = region.size;
  value->data = db->vmap.map + JFDB_voffset(region);
  return value;
}

// Assembly:
movq %rdx, %rax
movq (%rsi), %rdx
movq %rdx, %rcx
shrq $0x28, %rcx
movl $0xff, %r8d
andl %r8d, %ecx
shrq $0x30, %rdx
andl $0xfff, %edx            # imm = 0xFFF
addq %rsi, %rdx
addq $0x8, %rdx
cmpl %r8d, %ecx
jne 0x353b
movl (%rdx), %ecx
addq $0x4, %rdx
testl %ecx, %ecx
je 0x3558
movzwl 0x4(%rdx), %ecx
movl (%rdx), %edx
movw %cx, 0x8(%rax)
shll $0x8, %edx
addq 0xb0(%rdi), %rdx
movq %rdx, 0x10(%rax)
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_find
JFT_Cursor *JFDB_find(JFDB *db, JFT_Cursor *cursor, const JFT_Stem *key) {
  JFT *trie;
  for (JFT_Offset pos = db->tip.cp.offset; pos; pos = JFT_parent_offset(trie)) {
    trie = JFDB_get_trie(db, pos);
    JFT_cursor_init(cursor, In, trie);
    if (JFT_cursor_find(cursor, key) != JFT_SYMBOL_NIL)
      return cursor;
  }
  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x128(%rdi), %r12
testq %r12, %r12
je 0x35b4
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movabsq $0xffffffffff, %r13     # imm = 0xFFFFFFFFFF
addq 0x98(%r15), %r12
movq %rbx, %rdi
movl $0x1, %esi
movq %r12, %rdx
callq 0x39a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f07
cmpq $-0x2, %rax
jne 0x35b6
movq (%r12), %r12
andq %r13, %r12
jne 0x3583
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_fold
JFT_Status JFDB_fold(JFDB *db,
                     JFT_Stem *stem,
                     JFT_Symbol *stop,
                     JFDB_FoldFun fun,
                     void *restrict acc,
                     int flags) {
  // fold all active tries in the DB simultaneously, in order
  // as usual, stem serves as both input and output
  JFT_Amount N = db->tip.level, i = 0;
  JFT_Cursor cursors[N];
  JFT *trie;
  for (JFT_Offset pos = db->tip.cp.offset; pos; pos = JFT_parent_offset(trie)) {
    // we want all the cursors to be at the same position, so only add them if they have the prefix
    trie = JFDB_get_trie(db, pos);
    cursors[i] = JFT_cursor(trie);
    if (JFT_cursor_find(&cursors[i], stem) < JFT_SYMBOL_NIL)
      i++;
  }
  JFDB_Slice slice = (JFDB_Slice) {
    .db = db,
    .stem = stem,
    .stop = stop,
    .zero = stem->size,
    .fun = fun,
    .acc = acc
  };
  if (i)
    return JFT_cursor_merge(cursors, i, &splice_fold, &slice, flags);
  return Ok;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, -0x2c(%rbp)
movq %r8, -0x88(%rbp)
movq %rcx, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, %r15
movzbl 0xc8(%rdi), %eax
movq %rsp, %r12
imull $0x38, %eax, %eax
addl $0xf, %eax
andl $-0x10, %eax
subq %rax, %r12
movq %r12, %rsp
movq 0x128(%rdi), %r13
xorl %ebx, %ebx
testq %r13, %r13
je 0x36c8
movq %r15, -0x98(%rbp)
movq %rdi, -0x90(%rbp)
movq 0x98(%rdi), %r14
leaq (%r14,%r13), %rdx
imulq $0x38, %rbx, %r15
leaq (%r12,%r15), %rax
movq %rax, -0xa0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x40(%rbp)
movq %rdx, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x39a0
movaps -0x70(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movaps -0x50(%rbp), %xmm2
movups %xmm0, (%r12,%r15)
movups %xmm1, 0x10(%r12,%r15)
movups %xmm2, 0x20(%r12,%r15)
movq -0x40(%rbp), %rax
movq %rax, 0x30(%r12,%r15)
movq -0x98(%rbp), %r15
movq -0xa0(%rbp), %rdi
movq %r15, %rsi
callq 0x3f07
movq -0x90(%rbp), %rdi
cmpq $-0x2, %rax
adcq $0x0, %rbx
movq (%r14,%r13), %r13
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
andq %rax, %r13
jne 0x3623
movq %rdi, -0x70(%rbp)
movq %r15, -0x68(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x60(%rbp)
movzwl 0x8(%r15), %eax
movw %ax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
testq %rbx, %rbx
movl $0x0, %eax
je 0x3718
leaq 0x22(%rip), %rdx        # 0x3727
leaq -0x70(%rbp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl -0x2c(%rbp), %r8d
callq 0x4229
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: splice_fold
static JFT_Status splice_fold(JFT_Cursor *cursors, JFT_MergeContext *ctx, JFT_Phase phase) {
  JFT_MergeFrame *frame = ctx->frame;
  JFDB_Slice *slice = (JFDB_Slice *)ctx->acc;
  JFT_Cursor *cursor = cursors + ffsll(frame->active) - 1;
  JFT_KeySize depth = frame - ctx->stack;

  if (phase == Out)
    return Ok;

  if ((slice->stem->size = slice->zero + depth))
    JFT_set_symbol_at_point(slice->stem, slice->stem->size - 1, cursor->symbol);

  if (JFT_cursor_at_terminal(cursor)) {
    return slice->fun(cursor, slice, True);
  } else if (slice->stop && cursor->symbol == *slice->stop && depth) {
    return slice->fun(cursor, slice, False);
  }
  return Step;
}

// Assembly:
movq %rsi, %rax
movq 0x8(%rsi), %r8
movq 0x8(%r8), %rcx
bsfq %rcx, %rsi
movq $-0x1, %rcx
cmovneq %rsi, %rcx
cmpl $-0x1, %edx
je 0x378c
movq 0x20(%rax), %rsi
imulq $0x38, %rcx, %rcx
leaq (%rcx,%rdi), %r9
addq $0x38, %r9
subq (%rax), %r8
movl %r8d, %edx
shrl $0x5, %edx
movq 0x8(%rsi), %rax
addw 0x18(%rsi), %dx
movw %dx, 0x8(%rax)
je 0x37a6
movzwl %dx, %r10d
movq -0x8(%r9), %rdx
decq %r10
je 0x378f
cmpq $0x1, (%rax)
movq 0x10(%rax), %rax
adcq $-0x1, %rax
movb %dl, (%rax,%r10)
jmp 0x37a6
xorl %eax, %eax
retq
xorl %r10d, %r10d
cmpq $0x100, %rdx            # imm = 0x100
cmovaeq %rdx, %r10
movq %r10, (%rax)
movq 0x10(%rax), %rax
movb %dl, (%rax)
movq -0x30(%r9), %rax
movq (%rax), %rax
shrq $0x3e, %rax
cmpl $0x3, %eax
jb 0x37c9
movzwl -0x20(%r9), %eax
decq %rax
movl $0x1, %edx
cmpq %rax, -0x10(%r9)
je 0x37eb
movq 0x10(%rsi), %rdx
movl $0x1, %eax
testq %rdx, %rdx
je 0x37f7
testl $0x1fffe0, %r8d         # imm = 0x1FFFE0
je 0x37f7
movq (%rdx), %r8
xorl %edx, %edx
cmpq %r8, -0x8(%r9)
jne 0x37f7
addq %rdi, %rcx
movq 0x20(%rsi), %rax
movq %rcx, %rdi
jmpq *%rax
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/db.c
// Function: JFDB_vfree
static void JFDB_vfree(JFDB *db, JFDB_Region region) {
  if (db->freeList.size < JFDB_MAX_FREE - 1)
    JFDB_add_to_free_list(db, region);
  if (db->freeList.size >= JFDB_MAX_FREE)
    db->oughtFlush = True;
}

// Assembly:
movq 0x138(%rdi), %rax
cmpq $0xfe, %rax
ja 0x3987
movq %rsi, %rcx
shrq $0x20, %rcx
leal 0xff(%rcx), %edx
shrl $0x8, %edx
addl %esi, %edx
cmpl %esi, 0x130(%rdi)
jbe 0x3960
movl %esi, 0x130(%rdi)
cmpl 0x134(%rdi), %edx
jbe 0x396e
movl %edx, 0x134(%rdi)
leaq 0x1(%rax), %rdx
movq %rdx, 0x138(%rdi)
movl %esi, 0x140(%rdi,%rax,8)
movl %ecx, 0x144(%rdi,%rax,8)
cmpq $0x100, 0x138(%rdi) # imm = 0x100
jb 0x399e
movl $0x1, 0x984(%rdi)
retq
nop
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/trie.c
// Function: JFT_cursor_init
JFT_Symbol JFT_cursor_init(JFT_Cursor *cursor, JFT_Phase phase, JFT *node) {
  // initialize the cursor at node, if it exists, and return the symbol
  // we assume non-root branches always have children
  // it is impossible to construct such a node without children
  // we assume non-root nodes cannot have an empty stem
  // although technically it is possible to construct such a node, it would be invalid
  if (node == NULL)
    return cursor->symbol = JFT_SYMBOL_NIL;
  switch (JFT_node_type(node)) {
    case Root:
      cursor->node = node;
      cursor->stem = (JFT_Stem) {0};
      cursor->point = 0;
      cursor->symbol = JFT_SYMBOL_TOP;
      break;
    default:
      cursor->node = node;
      cursor->stem = JFT_stem(node);
      cursor->point = phase == In ? 0 : cursor->stem.size - 1;
      cursor->symbol = JFT_cursor_symbol_at_point(cursor);
      break;
  }
  return cursor->symbol;
}

// Assembly:
testq %rdx, %rdx
je 0x39cd
movq (%rdx), %rcx
movq %rcx, %rax
shrq $0x3e, %rax
movq %rdx, 0x8(%rdi)
jne 0x39dd
leaq 0x10(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq $-0x3, 0x30(%rdi)
jmp 0x3a45
movq $-0x2, 0x30(%rdi)
movq $-0x2, %rax
retq
btq $0x3d, %rcx
jb 0x39ec
addq $0x8, %rdx
xorl %eax, %eax
jmp 0x39fa
movzbl 0x8(%rdx), %eax
orq $-0x100, %rax
addq $0x9, %rdx
shrq $0x30, %rcx
andl $0xfff, %ecx            # imm = 0xFFF
movq %rax, 0x10(%rdi)
movw %cx, 0x18(%rdi)
movq %rdx, 0x20(%rdi)
cmpl $0x1, %esi
jne 0x3a19
xorl %ecx, %ecx
jmp 0x3a20
movzwl 0x18(%rdi), %ecx
decq %rcx
movq %rcx, 0x28(%rdi)
testq %rax, %rax
je 0x3a3a
testq %rcx, %rcx
je 0x3a41
movq 0x20(%rdi), %rax
addq %rax, %rcx
decq %rcx
jmp 0x3a3e
addq 0x20(%rdi), %rcx
movzbl (%rcx), %eax
movq %rax, 0x30(%rdi)
movq 0x30(%rdi), %rax
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/trie.c
// Function: JFT_cursor_step
JFT_Symbol JFT_cursor_step(JFT_Cursor *cursor, JFT_Direction direction) {
  if (cursor->symbol == JFT_SYMBOL_NIL)
    return cursor->symbol;
  if (++cursor->point >= cursor->stem.size)
    switch (JFT_node_type(cursor->node)) {
      case Leaf:
        return cursor->symbol = JFT_SYMBOL_ANY;
      default:
        return JFT_cursor_init(cursor, In, JFT_child(cursor->node, JFT_SYMBOL_NIL, direction));
    }
  return cursor->symbol = JFT_cursor_symbol_at_point(cursor);
}

// Assembly:
pushq %rbx
movq $-0x2, %rax
cmpq $-0x2, 0x30(%rdi)
je 0x3b31
movq %rdi, %rbx
movq 0x28(%rdi), %rcx
incq %rcx
movq %rcx, 0x28(%rdi)
movzwl 0x18(%rdi), %eax
cmpq %rax, %rcx
jge 0x3ae6
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x3b26
testq %rcx, %rcx
je 0x3b2d
movq 0x20(%rbx), %rax
addq %rax, %rcx
decq %rcx
jmp 0x3b2a
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
shrq $0x3e, %rax
cmpl $0x3, %eax
jb 0x3b07
movq $-0x1, 0x30(%rbx)
movq $-0x1, %rax
jmp 0x3b31
movl %esi, %edx
movq $-0x2, %rsi
callq 0x3b33
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %rdx
popq %rbx
jmp 0x39a0
addq 0x20(%rbx), %rcx
movzbl (%rcx), %eax
movq %rax, 0x30(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/trie.c
// Function: JFT_cursor_next
JFT_Symbol JFT_cursor_next(JFT_Cursor *cursor, JFT_Direction direction) {
  if (cursor->symbol == JFT_SYMBOL_ANY)
    return cursor->symbol;
  if (cursor->point == 0)
    return JFT_cursor_init(cursor, In, JFT_child(JFT_parent(cursor->node), cursor->symbol, direction));
  if (cursor->symbol == JFT_SYMBOL_NIL && cursor->point < cursor->stem.size)
    return cursor->symbol = JFT_cursor_symbol_at_point(cursor);
  return cursor->symbol = JFT_SYMBOL_NIL;
}

// Assembly:
pushq %rbx
movl %esi, %edx
movq 0x30(%rdi), %rsi
cmpq $-0x1, %rsi
je 0x3ec3
movq %rdi, %rbx
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x3edd
cmpq $-0x2, %rsi
jne 0x3ecc
movzwl 0x18(%rbx), %ecx
cmpq %rcx, %rax
jge 0x3ecc
addq 0x20(%rbx), %rax
cmpq $0x1, 0x10(%rbx)
adcq $-0x1, %rax
movzbl (%rax), %eax
movq %rax, 0x30(%rbx)
jmp 0x3edb
movq $-0x1, %rax
jmp 0x3edb
movq $-0x2, 0x30(%rbx)
movq $-0x2, %rax
popq %rbx
retq
movq 0x8(%rbx), %rdi
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
andq (%rdi), %rax
subq %rax, %rdi
callq 0x3b33
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %rdx
popq %rbx
jmp 0x39a0
// File: /workspace/github_c_makefile_star2_O1/jflatow[P]jfdb/src/trie.c
// Function: move_into_frame
static JFT_MergeFrame *move_into_frame(JFT_Cursor *cursors,
                                       JFT_CursorFun advance,
                                       JFT_Mask relevant,
                                       JFT_MergeFrame *frame,
                                       JFT_Direction direction) {
  // compute the new active set and bound from the relevant cursors
  // advance the active cursors (assumed to be a subset of relevant)
  JFT_Symbol bound = JFT_SYMBOL_NIL, symbol;
  JFT_Mask definite = 0, possible = 0, preclude = 0;
  for (JFT_Amount b = ffsll(relevant); b; b = ffsll(relevant &= relevant - 1)) {
    JFT_Amount i = b - 1;
    JFT_Mask m = 1LLU << i;
    if (frame->active & m)
      advance(&cursors[i], direction);
    symbol = cursors[i].symbol;
    if (symbol == JFT_SYMBOL_NIL) {
      // the symbol is NIL: not active and has no more siblings
      preclude |= m;
    } else if (symbol == JFT_SYMBOL_ANY) {
      // the symbol is ANY: definitely active, but does not tighten the bound
      definite |= m;
    } else if (symbol == bound) {
      // the symbol matches the bound: potentially include it in active set
      possible |= m;
    } else if ((direction == Forward && symbol < bound) ||
               (direction == Reverse && symbol > bound) ||
               (bound == JFT_SYMBOL_NIL)) {
      // the symbol beats the bound: replace the potential active set
      bound = symbol;
      possible = m;
    }
  }
  frame->bound = bound;
  frame->active = possible | definite;
  frame->done = preclude;
  return frame;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbx
movq %rsi, 0x20(%rsp)
testq %rdx, %rdx
je 0x4597
movl %r8d, %ebp
movq %rdx, %r14
movq %rdi, %r12
bsfq %rdx, %r13
incq %r13
movq $-0x2, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x10(%rsp)
decq %r13
movl $0x1, %r15d
movl %r13d, %ecx
shlq %cl, %r15
movq 0x8(%rbx), %rax
btq %r13, %rax
jae 0x44fa
imulq $0x38, %r13, %rdi
addq %r12, %rdi
movl %ebp, %esi
callq *0x20(%rsp)
imulq $0x38, %r13, %rax
movq 0x30(%r12,%rax), %rax
cmpq $-0x1, %rax
je 0x4516
cmpq $-0x2, %rax
jne 0x451d
orq %r15, 0x18(%rsp)
jmp 0x454b
orq %r15, 0x10(%rsp)
jmp 0x454b
movq 0x8(%rsp), %rdx
cmpq %rdx, %rax
jne 0x452d
orq %r15, (%rsp)
jmp 0x454b
cmpl $0x1, %ebp
jne 0x4537
cmpq %rdx, %rax
jb 0x4542
cmpl $-0x1, %ebp
je 0x456f
cmpq $-0x2, %rdx
jne 0x454b
movq %r15, (%rsp)
movq %rax, 0x8(%rsp)
leaq -0x1(%r14), %rax
andq %rax, %r14
bsfq %r14, %r13
movq $-0x1, %rax
cmoveq %rax, %r13
incq %r13
testq %r14, %r14
jne 0x44d4
jmp 0x4582
cmpq %rdx, %rax
seta %cl
cmpq $-0x2, %rdx
sete %dl
orb %cl, %dl
jne 0x4542
jmp 0x454b
movq (%rsp), %rdx
orq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rcx
jmp 0x45a2
movq $-0x2, %rcx
xorl %eax, %eax
xorl %edx, %edx
movq %rcx, (%rbx)
movq %rdx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq