LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/command.cpp
// Function: forcearg(tagval&, int)
static inline void forcearg(tagval &v, int type)
{
    switch(type)
    {
        case RET_STR: if(v.type != VAL_STR) forcestr(v); break;
        case RET_INT: if(v.type != VAL_INT) forceint(v); break;
        case RET_FLOAT: if(v.type != VAL_FLOAT) forcefloat(v); break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x40, %esi
je 0x10f2e
cmpl $0x80, %esi
je 0x10f1c
cmpl $0xc0, %esi
jne 0x10f94
cmpl $0x3, 0x8(%rbx)
je 0x10f94
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x8cd4
cmpl $0x2, 0x8(%rbx)
je 0x10f94
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x11016
movl 0x8(%rbx), %eax
xorl %r14d, %r14d
decl %eax
cmpl $0x5, %eax
ja 0x10f61
leaq 0x5a56(%rip), %rcx      # 0x16998
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2050
movq %rax, %r14
jmp 0x10f61
cvttss2si (%rbx), %r14d
movl 0x8(%rbx), %eax
cmpl $0x5, %eax
je 0x10f78
cmpl $0x3, %eax
jne 0x10f8a
movq (%rbx), %rdi
testq %rdi, %rdi
jne 0x10f85
jmp 0x10f8a
movq (%rbx), %rdi
cmpl $0x0, -0x4(%rdi)
jne 0x10f8a
addq $-0x4, %rdi
callq 0x152d7
movl $0x1, 0x8(%rbx)
movl %r14d, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/command.cpp
// Function: forceint(tagval&)
static inline int forceint(tagval &v)
{
    int i = 0;
    switch(v.type)
    {
        case VAL_FLOAT: i = v.f; break;
        case VAL_STR: i = parseint(v.s); break;
        case VAL_MACRO: i = parseint(v.s); break;
        case VAL_INT: return v.i;
    }
    freearg(v);
    v.setint(i);
    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %eax
xorl %r14d, %r14d
decl %eax
cmpl $0x5, %eax
ja 0x10fdb
leaq 0x59f9(%rip), %rcx      # 0x169b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2050
movq %rax, %r14
jmp 0x10fdb
movl (%rbx), %r14d
jmp 0x1100e
cvttss2si (%rbx), %r14d
movl 0x8(%rbx), %eax
cmpl $0x5, %eax
je 0x10ff2
cmpl $0x3, %eax
jne 0x11004
movq (%rbx), %rdi
testq %rdi, %rdi
jne 0x10fff
jmp 0x11004
movq (%rbx), %rdi
cmpl $0x0, -0x4(%rdi)
jne 0x11004
addq $-0x4, %rdi
callq 0x152d7
movl $0x1, 0x8(%rbx)
movl %r14d, (%rbx)
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/command.cpp
// Function: forcefloat(tagval&)
static inline float forcefloat(tagval &v)
{
    float f = 0.0f;
    switch(v.type)
    {
        case VAL_INT: f = v.i; break;
        case VAL_STR: f = parsefloat(v.s); break;
        case VAL_MACRO: f = parsefloat(v.s); break;
        case VAL_FLOAT: return v.f;
    }
    freearg(v);
    v.setfloat(f);
    return f;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %eax
xorpd %xmm0, %xmm0
decl %eax
cmpl $0x5, %eax
ja 0x11099
leaq 0x598f(%rip), %rcx      # 0x169c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %r14
leaq -0x18(%rbp), %rsi
movq %r14, %rdi
callq 0x2120
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1105d
jnp 0x11072
cvtsd2ss %xmm0, %xmm0
jmp 0x11099
xorps %xmm0, %xmm0
cvtsi2ssl (%rbx), %xmm0
jmp 0x11099
movss (%rbx), %xmm0
jmp 0x110d7
movq -0x18(%rbp), %rax
cmpq %r14, %rax
je 0x1105d
movzbl (%rax), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x1105d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2050
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movl 0x8(%rbx), %eax
cmpl $0x5, %eax
je 0x110b0
cmpl $0x3, %eax
jne 0x110cc
movq (%rbx), %rdi
testq %rdi, %rdi
jne 0x110bd
jmp 0x110cc
movq (%rbx), %rdi
cmpl $0x0, -0x4(%rdi)
jne 0x110cc
addq $-0x4, %rdi
movss %xmm0, -0x1c(%rbp)
callq 0x152d7
movss -0x1c(%rbp), %xmm0
movl $0x2, 0x8(%rbx)
movss %xmm0, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/command.cpp
// Function: conc(vector<char>&, tagval*, int, bool, char const*, int)
static char *conc(vector<char> &buf, tagval *v, int n, bool space, const char *prefix = NULL, int prefixlen = 0)
{
    if(prefix)
    {
        buf.put(prefix, prefixlen);
        if(space && n) buf.add(' ');
    }
    loopi(n)
    {
        const char *s = "";
        int len = 0;
        switch(v[i].type)
        {
            case VAL_INT: s = intstr(v[i].i); break;
            case VAL_FLOAT: s = floatstr(v[i].f); break;
            case VAL_STR: s = v[i].s; break;
            case VAL_MACRO: s = v[i].s; len = v[i].code[-1]>>8; goto haslen;
        }
        len = int(strlen(s));
    haslen:
        buf.put(s, len);
        if(i == n-1) break;
        if(space) buf.add(' ');
    }
    buf.add('\0');
    return buf.getbuf();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testl %edx, %edx
jle 0x11e5a
movl %edx, %r14d
movq %rsi, %r15
decl %r14d
shlq $0x4, %r14
xorl %r12d, %r12d
movl 0x8(%r15,%r12), %eax
decl %eax
leaq 0x5384(%rip), %r13      # 0x1710f
cmpl $0x5, %eax
ja 0x11e19
leaq 0x4cf5(%rip), %rcx      # 0x16a90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x5366(%rip), %r13      # 0x1710f
jmpq *%rax
movl (%r15,%r12), %edx
movl 0xc9df(%rip), %eax      # 0x1e794
incl %eax
andl $0x3, %eax
movl %eax, 0xc9d4(%rip)      # 0x1e794
movl %eax, %ecx
shll $0x8, %ecx
leal (%rcx,%rax,4), %eax
leaq 0xc9d1(%rip), %rcx      # 0x1e7a0
addq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq 0x4f60(%rip), %rsi      # 0x16d41
xorl %eax, %eax
callq 0x128d0
movl 0xc9a6(%rip), %eax      # 0x1e794
movq %rax, %rcx
shlq $0x8, %rcx
leaq (%rcx,%rax,4), %r13
leaq 0xc9a0(%rip), %rax      # 0x1e7a0
addq %rax, %r13
jmp 0x11e19
movq (%r15,%r12), %r13
jmp 0x11e19
movss (%r15,%r12), %xmm0
callq 0x4d63
movq %rax, %r13
movq %r13, %rdi
callq 0x2080
movq %rax, %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1279e
cmpq %r12, %r14
je 0x11e5a
movb $0x20, -0x29(%rbp)
movq %rbx, %rdi
leaq -0x29(%rbp), %rsi
callq 0x12760
addq $0x10, %r12
jmp 0x11d7d
movq (%r15,%r12), %r13
movl -0x4(%r13), %edx
shrl $0x8, %edx
jmp 0x11e24
leaq -0x2a(%rbp), %rsi
movb $0x0, (%rsi)
movq %rbx, %rdi
callq 0x12760
movq (%rbx), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/./tools.h
// Function: vector<unsigned char>::growbuf(int)
void growbuf(int sz)
    {
        int olen = alen;
        if(!alen) alen = max(MINSIZE, sz);
        else while(alen < sz) alen *= 2;
        if(alen <= olen) return;
        uchar *newbuf = new uchar[alen*sizeof(T)];
        if(olen > 0)
        {
            memcpy(newbuf, (void *)buf, olen*sizeof(T));
            delete[] (uchar *)buf;
        }
        buf = (T *)newbuf;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %r14d
testq %r14, %r14
je 0x15c76
movl 0x8(%rbx), %eax
cmpl %esi, %eax
jge 0x15c84
addl %eax, %eax
cmpl %esi, %eax
jl 0x15c6e
jmp 0x15c81
cmpl $0x9, %esi
movl $0x8, %eax
cmovgel %esi, %eax
movl %eax, 0x8(%rbx)
movslq 0x8(%rbx), %rdi
cmpl %r14d, %edi
jle 0x15cc0
callq 0x2260
testq %rax, %rax
je 0x15cc9
movq %rax, %r15
testl %r14d, %r14d
jle 0x15cbd
movq (%rbx), %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2130
testq %r12, %r12
je 0x15cbd
movq %r12, %rdi
callq 0x2210
movq %r15, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x20c0
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/./tools.h
// Function: hashset<ident>::insert(unsigned int)
chain *insert(uint h)
    {
        if(!unused)
        {
            chainchunk *chunk = new chainchunk;
            chunk->next = chunks;
            chunks = chunk;
            loopi(CHUNKSIZE-1) chunk->chains[i].next = &chunk->chains[i+1];
            chunk->chains[CHUNKSIZE-1].next = unused;
            unused = chunk->chains;
        }
        chain *c = unused;
        unused = unused->next;
        c->next = chains[h];
        chains[h] = c;
        numelems++;
        return c;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq 0x18(%rdi), %r15
testq %r15, %r15
jne 0x12b8a
movl $0x1208, %edi           # imm = 0x1208
callq 0x1529c
movq 0x10(%rbx), %rcx
movq %rcx, 0x1200(%rax)
movq %rax, 0x10(%rbx)
movq %rax, %rcx
addq $0x48, %rcx
movl $0x3f, %edx
movq %rcx, -0x8(%rcx)
addq $0x48, %rcx
decq %rdx
jne 0x12b72
movq %r15, 0x11f8(%rax)
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rax
movq 0x40(%rax), %rdx
movq %rdx, 0x18(%rbx)
movl %r14d, %edx
movq (%rcx,%rdx,8), %rsi
movq %rsi, 0x40(%rax)
movq %rax, (%rcx,%rdx,8)
incl 0x4(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/./command.h
// Function: ident::getval(tagval&) const
inline void ident::getval(tagval &v) const
{
    switch(valtype)
    {
        case VAL_STR: case VAL_MACRO: v.setstr(newstring(val.s)); break;
        case VAL_INT: v.setint(val.i); break;
        case VAL_FLOAT: v.setfloat(val.f); break;
        default: v.setnull(); break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl 0x10(%rdi), %eax
decl %eax
cmpl $0x5, %eax
ja 0x12e77
leaq 0x3d75(%rip), %rcx      # 0x16b90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x20(%rdi), %r14
movq %r14, %rdi
callq 0x2080
leaq 0x1(%rax), %r15
movq %r15, %rdi
callq 0x152b1
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2130
movl $0x3, 0x8(%rbx)
movq %r12, (%rbx)
jmp 0x12e7e
movss 0x20(%rdi), %xmm0
movl $0x2, 0x8(%rbx)
movss %xmm0, (%rbx)
jmp 0x12e7e
movl 0x20(%rdi), %eax
movl $0x1, 0x8(%rbx)
jmp 0x12e7c
xorl %eax, %eax
movl %eax, 0x8(%rbx)
movl %eax, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/command.cpp
// Function: sortfun::operator()(sortitem const&, sortitem const&)
bool operator()(const sortitem &xval, const sortitem &yval)
    {
        if(x->valtype != VAL_MACRO) x->valtype = VAL_MACRO;
        cleancode(*x);
        x->val.code = (const uint *)xval.str;
        if(y->valtype != VAL_MACRO) y->valtype = VAL_MACRO;
        cleancode(*y);
        y->val.code = (const uint *)yval.str;
        return executebool(body);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rax
cmpl $0x6, 0x10(%rax)
je 0x1301e
movl $0x6, 0x10(%rax)
movq (%rbx), %r12
movq 0x18(%r12), %rax
testq %rax, %rax
je 0x1304c
addl $0xffffff00, (%rax)     # imm = 0xFFFFFF00
movq 0x18(%r12), %rdi
cmpl $0xff, (%rdi)
jg 0x13043
callq 0x152d7
movq $0x0, 0x18(%r12)
movq (%r15), %rax
movq (%rbx), %rcx
movq %rax, 0x20(%rcx)
movq 0x8(%rbx), %rax
cmpl $0x6, 0x10(%rax)
je 0x13067
movl $0x6, 0x10(%rax)
movq 0x8(%rbx), %r15
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x13093
addl $0xffffff00, (%rax)     # imm = 0xFFFFFF00
movq 0x18(%r15), %rdi
cmpl $0xff, (%rdi)
jg 0x1308b
callq 0x152d7
movq $0x0, 0x18(%r15)
movq (%r14), %rax
movq 0x8(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq 0x10(%rbx), %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8f8b
nop
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: path(char*)
char *path(char *s)
{
    for(char *curpart = s;;)
    {
        char *endpart = strchr(curpart, '&');
        if(endpart) *endpart = '\0';
        if(curpart[0]=='<')
        {
            char *file = strrchr(curpart, '>');
            if(!file) return s;
            curpart = file+1;
        }
        for(char *t = curpart; (t = strpbrk(t, "/\\")); *t++ = PATHDIV);
        for(char *prevdir = NULL, *curdir = curpart;;)
        {
            prevdir = curdir[0]==PATHDIV ? curdir+1 : curdir;
            curdir = strchr(prevdir, PATHDIV);
            if(!curdir) break;
            if(prevdir+1==curdir && prevdir[0]=='.')
            {
                memmove(prevdir, curdir+1, strlen(curdir+1)+1);
                curdir = prevdir;
            }
            else if(curdir[1]=='.' && curdir[2]=='.' && curdir[3]==PATHDIV)
            {
                if(prevdir+2==curdir && prevdir[0]=='.' && prevdir[1]=='.') continue;
                memmove(prevdir, curdir+4, strlen(curdir+4)+1);
                curdir = prevdir;
            }
        }
        if(endpart)
        {
            *endpart = '&';
            curpart = endpart+1;
        }
        else break;
    }
    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x440b(%rip), %r14      # 0x17bae
movq %rdi, -0x30(%rbp)
movq %rbx, %rdi
movl $0x26, %esi
callq 0x2060
movq %rax, %r12
testq %rax, %rax
je 0x137c1
movb $0x0, (%r12)
cmpb $0x3c, (%rbx)
jne 0x137f4
movq %rbx, %rdi
movl $0x3e, %esi
callq 0x21c0
leaq 0x1(%rax), %r15
testq %rax, %rax
cmoveq %rbx, %r15
movq -0x38(%rbp), %rax
cmoveq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
jne 0x137f7
xorl %ecx, %ecx
jmp 0x138bc
movq %rbx, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2380
testq %rax, %rax
je 0x13812
movb $0x2f, (%rax)
incq %rax
movq %rax, %rdi
jmp 0x137fa
xorl %ebx, %ebx
cmpb $0x2f, (%r15)
sete %bl
addq %r15, %rbx
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x2060
movq %rax, %r13
testq %rax, %rax
je 0x138a2
leaq 0x1(%rbx), %rax
cmpq %r13, %rax
jne 0x13846
movl $0x1, %ecx
cmpb $0x2e, (%rbx)
je 0x13878
cmpb $0x2e, 0x1(%r13)
jne 0x13873
cmpb $0x2e, 0x2(%r13)
jne 0x13873
cmpb $0x2f, 0x3(%r13)
jne 0x13873
leaq 0x2(%rbx), %rdx
movl $0x4, %ecx
cmpq %r13, %rdx
jne 0x13878
cmpb $0x2e, (%rbx)
jne 0x13878
cmpb $0x2e, (%rax)
jne 0x13878
movq %r13, %rbx
jmp 0x13892
addq %rcx, %r13
movq %r13, %rdi
callq 0x2080
leaq 0x1(%rax), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2340
xorl %eax, %eax
cmpb $0x2f, (%rbx)
sete %al
addq %rax, %rbx
jmp 0x1381e
testq %r12, %r12
je 0x138b6
movb $0x26, (%r12)
incq %r12
movb $0x1, %cl
movq %r12, %r15
jmp 0x138b8
xorl %ecx, %ecx
movq -0x30(%rbp), %rax
movq %r15, %rbx
testb %cl, %cl
jne 0x137a7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: path(char const*, bool)
char *path(const char *s, bool copy)
{
    static string tmp;
    copystring(tmp, s);
    path(tmp);
    return tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2080
movq %rax, %r14
incq %r14
movl $0x104, %eax            # imm = 0x104
cmpq %rax, %r14
cmovaeq %rax, %r14
leaq 0xba6f(%rip), %r15      # 0x1f370
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movb $0x0, -0x1(%r14,%r15)
movq %r15, %rdi
callq 0x13788
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: parentdir(char const*)
const char *parentdir(const char *directory)
{
    const char *p = directory + strlen(directory);
    while(p > directory && *p != '/' && *p != '\\') p--;
    static string parent;
    size_t len = p-directory+1;
    copystring(parent, directory, len);
    return parent;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2080
movq %rax, %r14
addq %rbx, %rax
testq %r14, %r14
jle 0x1395d
movzbl (%rax), %ecx
cmpl $0x2f, %ecx
je 0x1395d
cmpl $0x5c, %ecx
je 0x1395d
decq %rax
cmpq %rbx, %rax
ja 0x13948
subq %rbx, %rax
incq %rax
incq %r14
cmpq %rax, %r14
cmovaeq %rax, %r14
leaq 0xbb0c(%rip), %r15      # 0x1f480
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movb $0x0, -0x1(%r14,%r15)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: createdir(char const*)
bool createdir(const char *path)
{
    size_t len = strlen(path);
    if(path[len-1]==PATHDIV)
    {
        static string strip;
        path = copystring(strip, path, len);
    }
#ifdef WIN32
    return CreateDirectory(path, NULL)!=0;
#else
    return mkdir(path, 0777)==0;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2080
cmpb $0x2f, -0x1(%rbx,%rax)
jne 0x13a3c
movq %rax, %r14
incq %rax
cmpq %r14, %rax
cmovbq %rax, %r14
leaq 0xbb6b(%rip), %r15      # 0x1f590
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movb $0x0, -0x1(%r14,%r15)
movq %r15, %rbx
movq %rbx, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x2090
testl %eax, %eax
sete %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: fixpackagedir(char*)
size_t fixpackagedir(char *dir)
{
    path(dir);
    size_t len = strlen(dir);
    if(len > 0 && dir[len-1] != PATHDIV)
    {
        dir[len] = PATHDIV;
        dir[len+1] = '\0';
    }
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x13788
movq %rbx, %rdi
callq 0x2080
testq %rax, %rax
je 0x13a81
cmpb $0x2f, -0x1(%rbx,%rax)
je 0x13a81
movw $0x2f, (%rbx,%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: subhomedir(char*, int, char const*)
bool subhomedir(char *dst, int len, const char *src)
{
    const char *sub = strstr(src, "$HOME");
    if(!sub) sub = strchr(src, '~');
    if(sub && sub-src < len)
    {
#ifdef WIN32
        char home[MAX_PATH+1];
        home[0] = '\0';
        if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, home) != S_OK || !home[0]) return false;
#else
        const char *home = getenv("HOME");
        if(!home || !home[0]) return false;
#endif
        dst[sub-src] = '\0';
        concatstring(dst, home);
        concatstring(dst, sub+(*sub == '~' ? 1 : strlen("$HOME")));
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r13
movl %esi, %r12d
movq %rdi, %r15
leaq 0x410a(%rip), %rsi      # 0x17bb3
movq %rdx, %rdi
callq 0x2040
movq %rax, %rbx
testq %rax, %rax
jne 0x13ac9
movq %r13, %rdi
movl $0x7e, %esi
callq 0x2060
movq %rax, %rbx
movb $0x1, %r14b
testq %rbx, %rbx
je 0x13bc6
movq %r15, -0x38(%rbp)
movq %rbx, %r15
subq %r13, %r15
movslq %r12d, %rax
cmpq %rax, %r15
jge 0x13bc6
leaq 0x40c2(%rip), %rdi      # 0x17bb4
callq 0x2230
testq %rax, %rax
je 0x13bc3
movq %rax, %r12
cmpb $0x0, (%rax)
je 0x13bc3
movq -0x38(%rbp), %rax
movb $0x0, (%rax,%r15)
movq %rax, %r15
movq %rax, %rdi
callq 0x2080
cmpq $0x103, %rax            # imm = 0x103
ja 0x13b6b
leaq (%r15,%rax), %rcx
movq %rcx, -0x30(%rbp)
movl $0x104, %r15d           # imm = 0x104
subq %rax, %r15
movq %r12, %rdi
callq 0x2080
movq %rax, %r13
incq %r13
cmpq %r15, %r13
cmovaeq %r15, %r13
movq -0x38(%rbp), %r15
movq -0x30(%rbp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2130
movq -0x30(%rbp), %rax
movb $0x0, -0x1(%r13,%rax)
movq %r15, %rdi
callq 0x2080
cmpq $0x103, %rax            # imm = 0x103
ja 0x13bc6
xorl %ecx, %ecx
cmpb $0x7e, (%rbx)
setne %cl
movq %r15, %r13
leaq (%rbx,%rcx,4), %r15
incq %r15
addq %rax, %r13
movl $0x104, %ebx            # imm = 0x104
subq %rax, %rbx
movq %r15, %rdi
callq 0x2080
movq %rax, %r12
incq %r12
cmpq %rbx, %r12
cmovaeq %rbx, %r12
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2130
movb $0x0, -0x1(%r12,%r13)
jmp 0x13bc6
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: sethomedir(char const*)
const char *sethomedir(const char *dir)
{
    string pdir;
    copystring(pdir, dir);
    if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL;
    copystring(homedir, pdir);
    return homedir;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
callq 0x2080
movq %rax, %r14
incq %r14
movl $0x104, %eax            # imm = 0x104
cmpq %rax, %r14
cmovaeq %rax, %r14
leaq -0x120(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movb $0x0, -0x121(%rbp,%r14)
movq %r15, %rdi
movl $0x104, %esi            # imm = 0x104
movq %rbx, %rdx
callq 0x13a88
testb %al, %al
je 0x13c83
leaq -0x120(%rbp), %rdi
callq 0x13a59
testq %rax, %rax
je 0x13c83
leaq -0x120(%rbp), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
incq %r15
movl $0x104, %eax            # imm = 0x104
cmpq %rax, %r15
cmovaeq %rax, %r15
leaq 0xb4d3(%rip), %rbx      # 0x1f140
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2130
movb $0x0, -0x1(%r15,%rbx)
jmp 0x13c85
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: addpackagedir(char const*)
const char *addpackagedir(const char *dir)
{
    string pdir;
    copystring(pdir, dir);
    if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL;
    char *filter = pdir;
    for(;;)
    {
        static int len = strlen("packages");
        filter = strstr(filter, "packages");
        if(!filter) break;
        if(filter > pdir && filter[-1] == PATHDIV && filter[len] == PATHDIV) break;
        filter += len;
    }    
    packagedir &pf = packagedirs.add();
    pf.dir = filter ? newstring(pdir, filter-pdir) : newstring(pdir);
    pf.dirlen = filter ? filter-pdir : strlen(pdir);
    pf.filter = filter ? newstring(filter) : NULL;
    pf.filterlen = filter ? strlen(filter) : 0;
    return pf.dir;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
callq 0x2080
movq %rax, %r14
incq %r14
movl $0x104, %eax            # imm = 0x104
cmpq %rax, %r14
cmovaeq %rax, %r14
leaq -0x140(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movb $0x0, -0x141(%rbp,%r14)
movq %r15, %rdi
movl $0x104, %esi            # imm = 0x104
movq %rbx, %rdx
callq 0x13a88
testb %al, %al
je 0x13dac
leaq -0x140(%rbp), %rdi
callq 0x13a59
testq %rax, %rax
je 0x13dac
leaq 0x3ea3(%rip), %rsi      # 0x17bb9
leaq -0x140(%rbp), %r14
movq %r14, %rdi
callq 0x2040
movq %rax, %rbx
testq %rax, %rax
sete %r12b
je 0x13d64
leaq 0x3e81(%rip), %r15      # 0x17bb9
cmpq %r14, %rbx
jbe 0x13d49
cmpb $0x2f, -0x1(%rbx)
jne 0x13d49
cmpb $0x2f, 0x8(%rbx)
je 0x13d64
addq $0x8, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2040
movq %rax, %rbx
testq %rax, %rax
sete %r12b
jne 0x13d38
leaq 0xb4dd(%rip), %rdi      # 0x1f248
callq 0x148da
movq %rax, -0x38(%rbp)
testb $0x1, %r12b
je 0x13db3
leaq -0x140(%rbp), %rdi
callq 0x2080
leaq 0x1(%rax), %r13
movq %r13, %rdi
callq 0x152b1
movq %rax, %r15
movq %rax, %rdi
leaq -0x140(%rbp), %rsi
movq %r13, %rdx
callq 0x2130
movq %r15, %rax
jmp 0x13df8
xorl %eax, %eax
jmp 0x13e69
movq %rbx, %r13
subq %r14, %r13
incq %r13
movq %r13, %rdi
callq 0x152b1
movq %rax, -0x30(%rbp)
movq %r14, %rdi
callq 0x2080
movq %rax, %r15
incq %r15
cmpq %r13, %r15
cmovaeq %r13, %r15
movq -0x30(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2130
movq %r13, %rax
movb $0x0, -0x1(%r13,%r15)
movq -0x38(%rbp), %r13
movq %rax, (%r13)
testb $0x1, %r12b
je 0x13e14
leaq -0x140(%rbp), %rdi
callq 0x2080
jmp 0x13e1a
movq %rbx, %rax
subq %r14, %rax
movq %rax, 0x10(%r13)
testb $0x1, %r12b
je 0x13e30
movq $0x0, 0x8(%r13)
xorl %eax, %eax
jmp 0x13e61
movq %rbx, %rdi
callq 0x2080
leaq 0x1(%rax), %r14
movq %r14, %rdi
callq 0x152b1
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2130
movq %r15, 0x8(%r13)
movq %rbx, %rdi
callq 0x2080
movq %rax, 0x18(%r13)
movq (%r13), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: listfiles(char const*, char const*, vector<char*>&)
int listfiles(const char *dir, const char *ext, vector<char *> &files)
{
    string dirname;
    copystring(dirname, dir);
    path(dirname);
    size_t dirlen = strlen(dirname);
    while(dirlen > 1 && dirname[dirlen-1] == PATHDIV) dirname[--dirlen] = '\0';
    int dirs = 0;
    if(listdir(dirname, true, ext, files)) dirs++;
    string s;
    if(homedir[0])
    {
        formatstring(s)("%s%s", homedir, dirname);
        if(listdir(s, false, ext, files)) dirs++;
    }
    loopv(packagedirs)
    {
        packagedir &pf = packagedirs[i];
        if(pf.filter && strncmp(dirname, pf.filter, dirlen == pf.filterlen-1 ? dirlen : pf.filterlen))
            continue;
        formatstring(s)("%s%s", pf.dir, dirname);
        if(listdir(s, false, ext, files)) dirs++;
    }

    return dirs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
callq 0x2080
movq %rax, %r15
incq %r15
movl $0x104, %eax            # imm = 0x104
cmpq %rax, %r15
cmovaeq %rax, %r15
leaq -0x150(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2130
movb $0x0, -0x151(%rbp,%r15)
movq %r12, %rdi
callq 0x13788
movq %r12, %rdi
callq 0x2080
movq %rax, %r15
cmpq $0x2, %rax
jb 0x142ac
cmpb $0x2f, -0x151(%rbp,%r15)
jne 0x142ac
movb $0x0, -0x151(%rbp,%r15)
decq %r15
cmpq $0x1, %r15
ja 0x14289
movl $0x1, %r15d
leaq -0x150(%rbp), %rdi
movl $0x1, %esi
movq %r13, %rdx
movq %r14, %rcx
callq 0x14095
movzbl %al, %r12d
cmpb $0x0, 0xae72(%rip)      # 0x1f140
je 0x14318
leaq -0x260(%rbp), %rbx
leaq -0x30(%rbp), %rdi
movq %rbx, (%rdi)
leaq 0x38dd(%rip), %rsi      # 0x17bc2
leaq 0xae54(%rip), %rdx      # 0x1f140
leaq -0x150(%rbp), %rcx
xorl %eax, %eax
callq 0x128d0
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r14, %rcx
callq 0x14095
leal 0x1(%r12), %ecx
testb %al, %al
cmovel %r12d, %ecx
movl %ecx, %r12d
cmpl $0x0, 0xaf35(%rip)      # 0x1f254
jle 0x143c9
movq %r13, -0x40(%rbp)
movq %r14, -0x48(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %r15, -0x38(%rbp)
movq 0xaf0a(%rip), %rbx      # 0x1f248
movq 0x8(%rbx,%r14), %rsi
testq %rsi, %rsi
je 0x14368
movq 0x18(%rbx,%r14), %rdx
leaq -0x1(%rdx), %rax
cmpq %rax, %r15
cmoveq %r15, %rdx
leaq -0x150(%rbp), %rdi
callq 0x20a0
testl %eax, %eax
jne 0x143b2
movq %r12, %r15
leaq -0x260(%rbp), %r12
movq %r12, -0x30(%rbp)
movq (%rbx,%r14), %rdx
leaq -0x30(%rbp), %rdi
leaq 0x383d(%rip), %rsi      # 0x17bc2
leaq -0x150(%rbp), %rcx
xorl %eax, %eax
callq 0x128d0
movq %r12, %rdi
movq %r15, %r12
movq -0x38(%rbp), %r15
xorl %esi, %esi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x14095
movzbl %al, %eax
addl %eax, %r12d
incq %r13
movslq 0xae98(%rip), %rax      # 0x1f254
addq $0x20, %r14
cmpq %rax, %r13
jl 0x14337
movl %r12d, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: stream::size()
stream::offset stream::size()
{
    offset pos = tell(), endpos;
    if(pos < 0 || !seek(0, SEEK_END)) return -1;
    endpos = tell();
    return pos == endpos || seek(pos, SEEK_SET) ? endpos : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x20(%rax)
movq $-0x1, %rbx
testq %rax, %rax
js 0x1443b
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq *0x30(%rax)
testb %al, %al
je 0x1443b
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq %rax, %r12
cmpq %rax, %r15
je 0x14438
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq *0x30(%rax)
testb %al, %al
je 0x1443b
movq %r12, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: stream::getline(char*, unsigned long)
bool stream::getline(char *str, size_t len)
{
    loopi(len-1)
    {
        if(read(&str[i], 1) != 1) { str[i] = '\0'; return i > 0; }
        else if(str[i] == '\n') { str[i+1] = '\0'; return true; }
    }
    if(len > 0) str[len-1] = '\0';
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x30(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x1(%rdx), %rbx
testl %ebx, %ebx
setg %r14b
movq %rbx, -0x38(%rbp)
jle 0x144b1
movq %rdi, %r15
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r13d, %r13d
movq -0x30(%rbp), %rax
leaq (%rax,%r13), %r12
movq (%r15), %rax
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rsi
callq *0x48(%rax)
cmpq $0x1, %rax
jne 0x144b3
cmpb $0xa, (%r12)
je 0x144c4
incq %r13
cmpq %rbx, %r13
setb %r14b
jne 0x1447d
jmp 0x144d0
jmp 0x144d0
movq -0x30(%rbp), %rax
movb $0x0, (%rax,%r13)
testq %r13, %r13
setne %al
jmp 0x144d0
movq -0x30(%rbp), %rax
movb $0x0, 0x1(%rax,%r13)
movb $0x1, %al
testb $0x1, %r14b
jne 0x144eb
movb $0x1, %al
cmpq $0x0, -0x40(%rbp)
je 0x144eb
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
movb $0x0, (%rcx,%rdx)
andb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: stream::printf(char const*, ...)
size_t stream::printf(const char *fmt, ...)
{
    char buf[512];
    char *str = buf;
    va_list args;
#if defined(WIN32) && !defined(__GNUC__)
    va_start(args, fmt);
    int len = _vscprintf(fmt, args);
    if(len <= 0) { va_end(args); return 0; }
    if(len >= (int)sizeof(buf)) str = new char[len+1];
    _vsnprintf(str, len+1, fmt, args);
    va_end(args);
#else
    va_start(args, fmt);
    int len = vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);
    if(len <= 0) return 0;
    if(len >= (int)sizeof(buf))
    {
        str = new char[len+1];
        va_start(args, fmt);
        vsnprintf(str, len+1, fmt, args);
        va_end(args);
    }
#endif
    size_t n = write(str, len);
    if(str != buf) delete[] str;
    return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x100(%rbp), %r14
movq %rdx, 0x10(%r14)
movq %rcx, 0x18(%r14)
movq %r8, 0x20(%r14)
movq %r9, 0x28(%r14)
testb %al, %al
je 0x14560
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
leaq -0x50(%rbp), %rcx
movq %r14, 0x10(%rcx)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rcx)
leaq -0x300(%rbp), %r12
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
movq %r15, %rdx
callq 0x20e0
testl %eax, %eax
jle 0x14606
movl %eax, %r13d
cmpl $0x200, %eax            # imm = 0x200
jl 0x145de
leal 0x1(%r13), %edi
movq %rdi, -0x30(%rbp)
callq 0x152b1
movq %rax, %r12
leaq -0x50(%rbp), %rcx
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rcx)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%rcx)
movq %r14, 0x10(%rcx)
movq %r12, %rdi
movq -0x30(%rbp), %rsi
movq %r15, %rdx
callq 0x20e0
movl %r13d, %edx
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x50(%rax)
movq %rax, %rbx
leaq -0x300(%rbp), %rax
cmpq %rax, %r12
je 0x14608
movq %r12, %rdi
callq 0x152d7
jmp 0x14608
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: openrawfile(char const*, char const*)
stream *openrawfile(const char *filename, const char *mode)
{
    const char *found = findfile(filename, mode);
    if(!found) return NULL;
    filestream *file = new filestream;
    if(!file->open(found, mode)) { delete file; return NULL; }
    return file;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
callq 0x13e7b
testq %rax, %rax
je 0x14673
movq %rax, %r15
movl $0x10, %edi
callq 0x1529c
movq %rax, %rbx
leaq 0x9605(%rip), %rax      # 0x1dc50
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x21e0
movq %rax, 0x8(%rbx)
testq %rax, %rax
jne 0x14675
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: opentempfile(char const*, char const*)
stream *opentempfile(const char *name, const char *mode)
{
    const char *found = findfile(name, mode);
    filestream *file = new filestream;
    if(!file->opentemp(found ? found : name, mode)) { delete file; return NULL; }
    return file;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
callq 0x13e7b
movl $0x10, %edi
callq 0x1529c
movq %rax, %rbx
leaq 0x95a4(%rip), %rax      # 0x1dc50
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
callq 0x2390
movq %rax, 0x8(%rbx)
testq %rax, %rax
jne 0x146d0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: openutf8file(char const*, char const*, stream*)
stream *openutf8file(const char *filename, const char *mode, stream *file)
{
    stream *source = file ? file : openfile(filename, mode);
    if(!source) return NULL;
    utf8stream *utf8 = new utf8stream;
    if(!utf8->open(source, mode, !file)) { if(!file) delete source; return NULL; }
    return utf8;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdx, %rbx
testq %rdx, %rdx
jne 0x14701
movq %r14, %rsi
callq 0x1461d
movq %rax, %rbx
testq %rbx, %rbx
je 0x14769
xorl %r12d, %r12d
testq %r15, %r15
setne %r13b
sete %r12b
movl $0x1038, %edi           # imm = 0x1038
callq 0x1529c
movq %rax, %r15
leaq 0x95e8(%rip), %rax      # 0x1dd10
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movups %xmm0, 0x18(%r15)
movups %xmm0, 0x23(%r15)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl %r12d, %ecx
callq 0x1490e
movl %eax, %ecx
orb %al, %r13b
xorl %eax, %eax
testb %cl, %cl
cmovneq %r15, %rax
testb %r13b, %r13b
jne 0x1476b
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: loadfile(char const*, unsigned long*, bool)
char *loadfile(const char *fn, size_t *size, bool utf8)
{
    stream *f = openfile(fn, "rb");
    if(!f) return NULL;
    size_t len = f->size();
    if(len <= 0) { delete f; return NULL; }
    char *buf = new char[len+1];
    if(!buf) { delete f; return NULL; }
    size_t offset = 0;
    if(utf8 && len >= 3)
    {
        if(f->read(buf, 3) != 3) { delete f; delete[] buf; return NULL; }
        if(((uchar *)buf)[0] == 0xEF && ((uchar *)buf)[1] == 0xBB && ((uchar *)buf)[2] == 0xBF) len -= 3;
        else offset += 3;
    } 
    size_t rlen = f->read(&buf[offset], len-offset);
    delete f;
    if(rlen != len-offset) { delete[] buf; return NULL; }
    if(utf8) len = decodeutf8((uchar *)buf, len, (uchar *)buf, len);
    buf[len] = '\0';
    if(size!=NULL) *size = len;
    return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movq %rsi, %r15
leaq 0x3434(%rip), %rsi      # 0x17bcc
callq 0x1461d
testq %rax, %rax
je 0x148a3
movq %rax, %r13
movq (%rax), %rax
movq %r13, %rdi
callq *0x38(%rax)
testq %rax, %rax
je 0x14823
movq %rax, %r14
leaq 0x1(%rax), %rdi
callq 0x152b1
movq %rax, %rbx
cmpq $0x3, %r14
setb %al
movl %r12d, -0x34(%rbp)
movl %r12d, %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x1482f
movq (%r13), %rax
movl $0x3, %r12d
movl $0x3, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq *0x48(%rax)
cmpq $0x3, %rax
jne 0x14891
cmpb $-0x11, (%rbx)
movq %r15, -0x30(%rbp)
jne 0x14836
cmpb $-0x45, 0x1(%rbx)
jne 0x14836
leaq -0x3(%r14), %rax
xorl %ecx, %ecx
cmpb $-0x41, 0x2(%rbx)
setne %cl
cmoveq %rax, %r14
leaq (%rcx,%rcx,2), %r12
jmp 0x14836
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
jmp 0x148a3
movq %r15, -0x30(%rbp)
xorl %r12d, %r12d
movq %rbx, %rsi
addq %r12, %rsi
movq %r14, %r15
subq %r12, %r15
movq (%r13), %rax
movq %r13, %rdi
movq %r15, %rdx
callq *0x48(%rax)
movq %rax, %r12
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
cmpq %r15, %r12
jne 0x1489b
cmpb $0x0, -0x34(%rbp)
je 0x1487e
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x130b0
movq %rax, %r14
movq -0x30(%rbp), %rax
movb $0x0, (%rbx,%r14)
testq %rax, %rax
je 0x148a5
movq %r14, (%rax)
jmp 0x148a5
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x152d7
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: utf8stream::open(stream*, char const*, bool)
bool open(stream *f, const char *mode, bool needclose)
    {
        if(file) return false;
        for(; *mode; mode++)
        {
            if(*mode=='r') { reading = true; break; }
            else if(*mode=='w') { writing = true; break; }
        }
        if(!reading && !writing) return false;
       
        autoclose = needclose;
        file = f;
       
        if(reading) checkheader();
 
        return true;
    }

// Assembly:
cmpq $0x0, 0x8(%rdi)
je 0x14918
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
movzbl (%rdx), %eax
testl %eax, %eax
je 0x1493c
cmpl $0x77, %eax
je 0x14938
cmpl $0x72, %eax
je 0x14932
incq %rdx
jmp 0x1491c
movb $0x1, 0x30(%rdi)
jmp 0x1493c
movb $0x1, 0x31(%rdi)
movb 0x30(%rdi), %dl
testb %dl, %dl
je 0x14953
movb %cl, 0x32(%rdi)
movq %rsi, 0x8(%rdi)
callq 0x150d2
movb $0x1, %al
jmp 0x1496a
cmpb $0x1, 0x31(%rdi)
jne 0x14968
movb %cl, 0x32(%rdi)
movq %rsi, 0x8(%rdi)
movb $0x1, %al
testb %dl, %dl
jne 0x1494a
jmp 0x1496a
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: filestream::printf(char const*, ...)
size_t printf(const char *fmt, ...)
    {
        va_list v;
        va_start(v, fmt);
        int result = vfprintf(file, fmt, v);
        va_end(v);
        return max(result, 0);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
leaq -0xd0(%rbp), %r10
movq %rdx, 0x10(%r10)
movq %rcx, 0x18(%r10)
movq %r8, 0x20(%r10)
movq %r9, 0x28(%r10)
testb %al, %al
je 0x14c46
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x90(%rbp)
movaps %xmm2, -0x80(%rbp)
movaps %xmm3, -0x70(%rbp)
movaps %xmm4, -0x60(%rbp)
movaps %xmm5, -0x50(%rbp)
movaps %xmm6, -0x40(%rbp)
movaps %xmm7, -0x30(%rbp)
leaq -0x20(%rbp), %rdx
movq %r10, 0x10(%rdx)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movq 0x8(%rdi), %rdi
callq 0x2270
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
addq $0xd0, %rsp
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: utf8stream::seek(long, int)
bool seek(offset off, int whence)
    {
        if(writing || !reading) return false;

        if(whence == SEEK_END)
        {
            uchar skip[512];
            while(read(skip, sizeof(skip)) == sizeof(skip));
            return !off;
        }
        else if(whence == SEEK_CUR) off += pos;
       
        if(off >= pos) off -= pos;
        else if(off < 0 || !file->seek(0, SEEK_SET)) return false;
        else
        {
            bufread = bufcarry = buflen = 0;
            pos = 0;
            checkheader(); 
        }

        uchar skip[512];
        while(off > 0)
        {
            size_t skipped = (size_t)min(off, (offset)sizeof(skip));
            if(read(skip, skipped) != skipped) { stopreading(); return false; }
            off -= skipped;
        }
        
        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
cmpb $0x0, 0x31(%rdi)
jne 0x14e4a
movq %rdi, %rbx
cmpb $0x1, 0x30(%rdi)
jne 0x14e4a
movq %rsi, %r14
cmpl $0x1, %edx
je 0x14dbe
cmpl $0x2, %edx
jne 0x14dc2
leaq -0x230(%rbp), %r15
movq (%rbx), %rax
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
movq %r15, %rsi
callq *0x48(%rax)
cmpq $0x200, %rax            # imm = 0x200
je 0x14d99
testq %r14, %r14
sete %r15b
jmp 0x14e4d
addq 0x10(%rbx), %r14
movq %r14, %r13
subq 0x10(%rbx), %r13
jge 0x14dfe
testq %r14, %r14
js 0x14e4a
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
xorl %r15d, %r15d
xorl %esi, %esi
xorl %edx, %edx
callq *0x30(%rax)
testb %al, %al
je 0x14e4d
leaq 0x10(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rbx, %rdi
callq 0x150d2
movq %r14, %r13
leaq -0x230(%rbp), %r14
testq %r13, %r13
setle %r15b
jle 0x14e4d
movl $0x200, %eax            # imm = 0x200
cmpq %rax, %r13
movl $0x200, %r12d           # imm = 0x200
cmovlq %r13, %r12
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq *0x48(%rax)
cmpq %r12, %rax
jne 0x14e39
subq %r12, %r13
jmp 0x14e43
cmpb $0x1, 0x30(%rbx)
jne 0x14e43
movb $0x0, 0x30(%rbx)
cmpq %r12, %rax
je 0x14e05
jmp 0x14e4d
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: utf8stream::read(void*, unsigned long)
size_t read(void *dst, size_t len)
    {
        if(!reading || !dst || !len) return 0;
        size_t next = 0;
        while(next < len)
        {
            if(bufread >= bufcarry) { if(readbuf(BUFSIZE)) continue; stopreading(); break; }
            size_t n = min(len - next, bufcarry - bufread);
            memcpy(&((uchar *)dst)[next], &buf[bufread], n);
            next += n;
            bufread += n;
        }
        pos += next;
        return next;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rdx, %rdx
je 0x14ef0
movq %rsi, %r12
testq %rsi, %rsi
je 0x14ef0
movq %rdi, %r14
cmpb $0x0, 0x30(%rdi)
je 0x14ef0
movq %rdx, %r15
leaq 0x33(%r14), %rax
movq %rax, -0x30(%rbp)
xorl %ebx, %ebx
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rax
subq %rsi, %rax
ja 0x14eb5
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
callq 0x15122
testb %al, %al
jne 0x14e95
jmp 0x14ee0
movq %r15, %r13
subq %rbx, %r13
cmpq %rax, %r13
cmovaeq %rax, %r13
leaq (%r12,%rbx), %rdi
addq -0x30(%rbp), %rsi
movq %r13, %rdx
callq 0x2130
addq %r13, %rbx
addq %r13, 0x18(%r14)
cmpq %r15, %rbx
jb 0x14e95
jmp 0x14eec
cmpb $0x1, 0x30(%r14)
jne 0x14eec
movb $0x0, 0x30(%r14)
addq %rbx, 0x10(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: utf8stream::write(void const*, unsigned long)
size_t write(const void *src, size_t len)
    {
        if(!writing || !src || !len) return 0;
        uchar dst[512];
        size_t next = 0;
        while(next < len)
        {
            size_t carry = 0, n = encodeutf8(dst, sizeof(dst), &((uchar *)src)[next], len - next, &carry);
            if(n > 0 && file->write(dst, n) != n) { stopwriting(); break; }
            next += carry;
        }
        pos += next;
        return next;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
xorl %ebx, %ebx
movq %rdx, -0x38(%rbp)
testq %rdx, %rdx
je 0x14f9f
testq %rsi, %rsi
je 0x14f9f
movq %rdi, %r14
cmpb $0x0, 0x31(%rdi)
je 0x14f9f
xorl %ebx, %ebx
leaq -0x240(%rbp), %r12
movq -0x38(%rbp), %rcx
subq %rbx, %rcx
jbe 0x14f9b
movq $0x0, -0x30(%rbp)
movq %rsi, %r15
leaq (%rsi,%rbx), %rdx
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
leaq -0x30(%rbp), %r8
callq 0x13360
testq %rax, %rax
je 0x14f7e
movq %rax, %r13
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movq %r13, %rdx
callq *0x50(%rax)
cmpq %r13, %rax
jne 0x14f86
addq -0x30(%rbp), %rbx
movb $0x1, %al
jmp 0x14f94
cmpb $0x1, 0x31(%r14)
jne 0x14f92
movb $0x0, 0x31(%r14)
xorl %eax, %eax
movq %r15, %rsi
testb %al, %al
jne 0x14f38
addq %rbx, 0x10(%r14)
movq %rbx, %rax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Fohlen[P]cubescript-standalone/stream.cpp
// Function: utf8stream::getline(char*, unsigned long)
bool getline(char *dst, size_t len)
    {
        if(!reading || !dst || !len) return false;
        --len;
        size_t next = 0;
        while(next < len)
        {
            if(bufread >= bufcarry) { if(readbuf(BUFSIZE)) continue; stopreading(); if(!next) return false; break; }
            size_t n = min(len - next, bufcarry - bufread);
            uchar *endline = (uchar *)memchr(&buf[bufread], '\n', n);
            if(endline) { n = endline+1 - &buf[bufread]; len = next + n; } 
            memcpy(&((uchar *)dst)[next], &buf[bufread], n);
            next += n;
            bufread += n;
        }
        dst[next] = '\0';
        pos += next;
        return true;
    }

// Assembly:
xorl %eax, %eax
testq %rdx, %rdx
je 0x150d1
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r13
testq %rsi, %rsi
je 0x150c3
movq %rdi, %rbx
cmpb $0x0, 0x30(%rdi)
je 0x150c3
movq %rdx, %r15
decq %r15
je 0x150b4
leaq 0x33(%rbx), %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
movq 0x18(%rbx), %r12
movq 0x20(%rbx), %rax
subq %r12, %rax
ja 0x15030
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
callq 0x15122
testb %al, %al
jne 0x15010
jmp 0x150a1
movq %r13, -0x40(%rbp)
movq %r15, %r13
subq %r14, %r13
cmpq %rax, %r13
cmovaeq %rax, %r13
addq -0x38(%rbp), %r12
movq %r12, %rdi
movl $0xa, %esi
movq %r13, %rdx
callq 0x21d0
movq %rax, %rcx
subq %r12, %rcx
testq %rax, %rax
leaq 0x1(%rcx,%r14), %rax
cmovneq %rax, %r15
movq %r14, -0x30(%rbp)
leaq 0x1(%rcx), %r14
cmoveq %r13, %r14
movq -0x40(%rbp), %r13
movq -0x30(%rbp), %rax
leaq (%rax,%r13), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2130
addq %r14, -0x30(%rbp)
addq %r14, 0x18(%rbx)
movq -0x30(%rbp), %r14
cmpq %r15, %r14
jb 0x15010
jmp 0x150b7
cmpb $0x1, 0x30(%rbx)
jne 0x150ab
movb $0x0, 0x30(%rbx)
testq %r14, %r14
jne 0x150b7
xorl %eax, %eax
jmp 0x150c3
xorl %r14d, %r14d
movb $0x0, (%r13,%r14)
addq %r14, 0x10(%rbx)
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq