LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/./import/read_gif.h
// Function: render_frame_rect(gd_GIF*, unsigned char*)
static void
render_frame_rect(gd_GIF *gif, uint8_t *buffer)
{
    int i, j, k;
    uint8_t index, *color;
    i = gif->fy * gif->width + gif->fx;
    for (j = 0; j < gif->fh; j++) {
        for (k = 0; k < gif->fw; k++) {
            index = gif->frame[(gif->fy + j) * gif->width + gif->fx + k];
            color = &gif->palette->colors[index*3];
            if (!gif->gce.transparency || index != gif->gce.tindex) {
                memcpy(&buffer[(i+k)*4], color, 3);
                buffer[(i+k)*4+3] = 255; // opaque
            }
        }
        i += gif->width;
    }
}

// Assembly:
movzwl 0x652(%rdi), %eax
movzwl 0x10(%rdi), %ecx
imull %eax, %ecx
movzwl 0x650(%rdi), %eax
addl %ecx, %eax
xorl %ecx, %ecx
movzwl 0x656(%rdi), %edx
cmpl %edx, %ecx
jae 0x17b61
movl %eax, %edx
leaq (%rsi,%rdx,4), %rdx
xorl %r8d, %r8d
movzwl 0x654(%rdi), %r9d
cmpq %r9, %r8
jae 0x17b53
movzwl 0x652(%rdi), %r9d
movzwl 0x10(%rdi), %r10d
movzwl 0x650(%rdi), %r11d
addq %rcx, %r9
imulq %r10, %r9
addq %r11, %r9
addq 0x668(%rdi), %r9
movzbl (%r8,%r9), %r9d
movq 0x28(%rdi), %r10
cmpl $0x0, 0x20(%rdi)
je 0x17b2b
cmpb 0x1a(%rdi), %r9b
je 0x17b4e
leaq (%r9,%r9,2), %r9
addq %r10, %r9
addq $0x4, %r9
movb 0x2(%r9), %r10b
movb %r10b, 0x2(%rdx,%r8,4)
movzwl (%r9), %r9d
movw %r9w, (%rdx,%r8,4)
movb $-0x1, 0x3(%rdx,%r8,4)
incq %r8
jmp 0x17ae3
movzwl 0x10(%rdi), %edx
addl %edx, %eax
incq %rcx
jmp 0x17acb
retq
// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/./import/read_pam.h
// Function: read_pnm_int(_IO_FILE*, char*, char**)
unsigned int read_pnm_int(FILE *fp, char* buf, char** t) {
    long result = strtol(*t,t,10);
    if (result == 0) {
        // no valid int found here, try next line
        do {
          *t = fgets(buf, PPMREADBUFLEN, fp);
          if ( *t == NULL ) {return false;}
        } while ( strncmp(buf, "#", 1) == 0 || strncmp(buf, "\n", 1) == 0);
        result = strtol(*t,t,10);
        if (result == 0) { e_printf("Invalid PNM file.\n"); fclose(fp); }
    }
    return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdx), %rdi
pushq $0xa
popq %rdx
movq %r14, %rsi
callq 0x3420
testq %rax, %rax
je 0x18811
movq %rax, %r12
jmp 0x1882c
movzbl (%r15), %ecx
cmpl $0xa, %ecx
je 0x18811
cmpl $0x23, %ecx
jne 0x1883b
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0x3510
movq %rax, (%r14)
testq %rax, %rax
jne 0x18803
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
pushq $0xa
popq %rdx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3420
testq %rax, %rax
jne 0x187fe
leaq 0x694b(%rip), %rdi      # 0x1f1a0
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x16b80
movq %rbx, %rdi
callq 0x32c0
jmp 0x1882c
// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/fuif.cpp
// Function: file_exists(char const*)
bool file_exists(const char * filename){
        FILE * file = fopen(filename, "rb");
        if (!file) return false;
        fclose(file);
        return true;
}

// Assembly:
pushq %rbx
leaq 0x46dd(%rip), %rsi      # 0x1ea1f
callq 0x33a0
movq %rax, %rbx
testq %rax, %rax
je 0x1a357
movq %rbx, %rdi
callq 0x32c0
testq %rbx, %rbx
setne %al
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/./import/read_gif.h
// Function: get_key(gd_GIF*, int, unsigned char*, unsigned char*, unsigned char*)
static uint16_t
get_key(gd_GIF *gif, int key_size, uint8_t *sub_len, uint8_t *shift, uint8_t *byte)
{
    int bits_read;
    int rpad;
    int frag_size;
    uint16_t key;

    key = 0;
    for (bits_read = 0; bits_read < key_size; bits_read += frag_size) {
        rpad = (*shift + bits_read) % 8;
        if (rpad == 0) {
            /* Update byte. */
            if (*sub_len == 0)
                read(gif->fd, sub_len, 1); /* Must be nonzero! */
            read(gif->fd, byte, 1);
            (*sub_len)--;
        }
        frag_size = MIN(key_size - bits_read, 8 - rpad);
        key |= ((uint16_t) ((*byte) >> rpad)) << bits_read;
    }
    /* Clear extra bits to the left. */
    key &= (1 << key_size) - 1;
    *shift = (*shift + key_size) % 8;
    return key;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r9
movq %rcx, %r12
movq %rdx, %r15
movq %rdi, 0x8(%rsp)
xorl %r13d, %r13d
pushq $0x8
popq %rdi
xorl %ebp, %ebp
movq %r8, 0x10(%rsp)
movl %esi, 0x4(%rsp)
movl %esi, %r14d
subl %r13d, %r14d
jle 0x1c5a6
movzbl (%r12), %eax
addl %r13d, %eax
cltd
idivl %edi
movl %edx, %ebx
testl %edx, %edx
jne 0x1c587
cmpb $0x0, (%r15)
jne 0x1c566
movq 0x8(%rsp), %rax
movl (%rax), %edi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x3450
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %rax
movl (%rax), %edi
movq %r9, %rsi
pushq $0x1
popq %rdx
callq 0x3450
movq 0x10(%rsp), %r9
decb (%r15)
movl 0x4(%rsp), %esi
pushq $0x8
popq %rdi
movl %edi, %eax
subl %ebx, %eax
cmpl %eax, %r14d
cmovll %r14d, %eax
movzbl (%r9), %edx
movl %ebx, %ecx
shrl %cl, %edx
movl %r13d, %ecx
shll %cl, %edx
orl %edx, %ebp
addl %eax, %r13d
jmp 0x1c530
pushq $-0x1
popq %rax
movl %esi, %ecx
shll %cl, %eax
notl %eax
andl %eax, %ebp
movzbl (%r12), %eax
addl %esi, %eax
cltd
idivl %edi
movb %dl, (%r12)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/t0mm4rx[P]piscine_cpp/day01/ex07/main.cpp
// Function: main
int main(int argc, char **argv)
{
	if (argc != 4)
	{
		std::cout << "Error ! Usage: ./replace <file> <find> <replace>" << std::endl;
		return (2);
	}
	if (!strlen(argv[2]) || !strlen(argv[3]))
	{
		std::cout << "Error: strings shouldn't be empty" << std::endl;
		return (2);
	}
	return (find_and_replace(argv[1], std::string(argv[1]) + std::string(".replace"), argv[2], argv[3]));
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
cmpl $0x4, %edi
jne 0x259a
movq %rsi, %rbx
movq 0x10(%rsi), %rax
cmpb $0x0, (%rax)
je 0x25aa
movq 0x18(%rbx), %rax
cmpb $0x0, (%rax)
je 0x25aa
movq 0x8(%rbx), %rsi
leaq 0xb0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x263a
movq 0x8(%rbx), %rsi
leaq 0x70(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x263a
leaq 0xbb5(%rip), %rsi       # 0x309e
leaq 0x50(%rsp), %rdi
leaq 0xd(%rsp), %rdx
callq 0x263a
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x2675
movq 0x10(%rbx), %rsi
leaq 0x30(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x263a
movq 0x18(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x263a
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x22cc
movl %eax, %ebx
leaq 0x10(%rsp), %rdi
callq 0x2080
leaq 0x30(%rsp), %rdi
callq 0x2080
leaq 0x90(%rsp), %rdi
callq 0x2080
leaq 0x50(%rsp), %rdi
callq 0x2080
leaq 0x70(%rsp), %rdi
callq 0x2080
leaq 0xb0(%rsp), %rdi
callq 0x2080
jmp 0x25c8
movq 0x2a37(%rip), %rdi      # 0x4fd8
leaq 0xaa3(%rip), %rsi       # 0x304b
jmp 0x25b8
movq 0x2a27(%rip), %rdi      # 0x4fd8
leaq 0xac4(%rip), %rsi       # 0x307c
callq 0x20e0
movq %rax, %rdi
callq 0x2090
pushq $0x2
popq %rbx
movl %ebx, %eax
addq $0xd0, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2080
jmp 0x25e5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2080
jmp 0x25f4
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2080
jmp 0x2606
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2080
jmp 0x2615
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2080
leaq 0xb0(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2150
movq %rax, %rbx
jmp 0x261f
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/demo/demo.cpp
// Function: print_verifier_state(APVerifier&)
void print_verifier_state(APVerifier& v)
{
    printf(" Status(%s): %s\n", tag_name(v.getTag()), GetErrorString(v.getError()));
    if (v.getError() != APVerifier::AP_SUCCESS) 
    {
        return;
    }

    print_time_value(" token timestamp ... :", v.getTimestamp());
    /*
    size_t i, nItems = v.getItemCount();
    for (i = 0; i < nItems; i++)
    {
        printf(" %d - [%s]\n", (int)i, v.getItem(i).c_str());
    }
    printf("\n public key (verifier): %s\n", v.getPublicKey().c_str());
    */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x24(%rdi), %edi
callq 0x4044c9
movq %rax, %r14
movl 0x20(%rbx), %edi
callq 0x404448
leaq 0x174c21(%rip), %rdi    # 0x579181
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4d0020
cmpl $0x0, 0x20(%rbx)
je 0x404578
popq %rbx
popq %r14
popq %rbp
retq
movq 0x28(%rbx), %rsi
leaq 0x174c0f(%rip), %rdi    # 0x579192
popq %rbx
popq %r14
popq %rbp
jmp 0x40446f
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/demo/demo.cpp
// Function: main
int main(int argc, char**argv)
{
    if (SelfTest() != 0 ) return 1;

    std::string userid      = "jack";
    std::string password    = "password";
    std::string domain      = "www.example.com";

    demoRegisterNewUser(userid, password, domain);
    demoUserLogin(userid, password, domain);
    demoUserLogin("joe", password, domain);
    demoUserLogin(userid, "WRONG-PASSWORD", domain);
    demoChangeUserPassword(userid, password, "new-password", domain);
    demoUserLogin(userid, "new-password", domain);

    printf("\n-----------------------------------------------------------------\n");
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x88, %rsp
callq 0x404cfb
testl %eax, %eax
je 0x404e8c
pushq $0x1
popq %rax
jmp 0x404fe4
leaq 0x17450d(%rip), %rsi    # 0x5793a0
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x405048
leaq 0x174522(%rip), %rsi    # 0x5793cc
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x405048
leaq 0x1744e7(%rip), %rsi    # 0x5793a5
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x405048
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x40458c
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x404839
leaq 0x1744bb(%rip), %rsi    # 0x5793b5
leaq -0x30(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x405048
leaq -0x30(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x404839
leaq -0x30(%rbp), %rdi
callq 0x477260
leaq 0x174491(%rip), %rsi    # 0x5793b9
leaq -0x30(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x405048
leaq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x404839
leaq -0x30(%rbp), %rdi
callq 0x477260
leaq 0x17446f(%rip), %rsi    # 0x5793c8
leaq -0x30(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x405048
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x404a82
leaq -0x30(%rbp), %rdi
callq 0x477260
leaq 0x17443a(%rip), %rsi    # 0x5793c8
leaq -0x30(%rbp), %rdi
leaq -0x9(%rbp), %rdx
callq 0x405048
leaq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x404839
leaq -0x30(%rbp), %rdi
callq 0x477260
leaq 0x1745fc(%rip), %rdi    # 0x5795bb
callq 0x4d7170
leaq -0x50(%rbp), %rdi
callq 0x477260
leaq -0x70(%rbp), %rdi
callq 0x477260
leaq -0x90(%rbp), %rdi
callq 0x477260
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
jmp 0x404ffa
jmp 0x405014
jmp 0x404ffa
jmp 0x405014
jmp 0x404ffa
jmp 0x405014
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x477260
jmp 0x405017
jmp 0x405014
movq %rax, %rbx
jmp 0x405020
movq %rax, %rbx
jmp 0x405029
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x477260
leaq -0x70(%rbp), %rdi
callq 0x477260
leaq -0x90(%rbp), %rdi
callq 0x477260
movq %rbx, %rdi
callq 0x4a94e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APKeyDerivation.cpp
// Function: APDigest::finish(void*, unsigned long)
size_t APDigest::finish(void* digest, size_t size)
{
    SHA512_Final(m_Digest, &m_Ctx);
    if (size > DIGEST_SIZE) 
        size = DIGEST_SIZE;

    memcpy(digest, &m_Digest[0], size);
    return size;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rsi
leaq 0xd8(%rdi), %r15
movq %r15, %rdi
callq 0x407b44
cmpq $0x40, %rbx
pushq $0x40
popq %r12
cmovbq %rbx, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x401110
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APKeyDerivation.cpp
// Function: APDigest::hmac(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long)
size_t APDigest::hmac(
    const uint8_t* key, size_t key_size, 
    const uint8_t* msg, size_t msg_size,
    uint8_t* mac, size_t mac_size)
{
    uint32_t i;
    uint8_t i_pad[BLOCK_SIZE], o_pad[BLOCK_SIZE];
    if (key_size > BLOCK_SIZE)
    {
        APDigest h((void*)key, key_size);
        for (i = 0; i < DIGEST_SIZE; i++)
        {
            o_pad[i] = h.m_Digest[i] ^ 0x5c;
            i_pad[i] = h.m_Digest[i] ^ 0x36;
        }
    }
    else
    {
        for (i = 0; i < key_size; i++)
        {
            o_pad[i] = key[i] ^ 0x5c;
            i_pad[i] = key[i] ^ 0x36;
        }
    }

    while (i < BLOCK_SIZE)
    {
        o_pad[i] = 0x5c;
        i_pad[i] = 0x36;
        i++;
    }

    APDigest inner_hash;
    inner_hash.update((void*)&i_pad[0], sizeof(i_pad));
    inner_hash.update((void*)msg, msg_size);
    inner_hash.finish();

    APDigest outer_hash;
    outer_hash.update((void*)&o_pad[0], sizeof(o_pad));
    outer_hash.update((void*)&inner_hash.m_Digest[0], sizeof(inner_hash.m_Digest));
    return outer_hash.finish((void*)mac, mac_size);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x330, %rsp            # imm = 0x330
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rdx
movq %rdi, %rsi
cmpq $0x80, %rdx
jbe 0x4057dc
pushq $0x40
popq %r13
leaq 0x100(%rsp), %rdi
callq 0x4056d8
xorl %eax, %eax
cmpq $0x40, %rax
je 0x405811
movb 0x1d8(%rsp,%rax), %cl
movl %ecx, %edx
xorb $0x5c, %dl
movb %dl, (%rsp,%rax)
xorb $0x36, %cl
movb %cl, 0x80(%rsp,%rax)
incq %rax
jmp 0x4057b8
xorl %r13d, %r13d
cmpl %edx, %r13d
jae 0x405811
movb (%rsi,%r13), %al
movl %eax, %ecx
xorb $0x5c, %cl
movb %cl, (%rsp,%r13)
xorb $0x36, %al
movb %al, 0x80(%rsp,%r13)
incq %r13
jmp 0x4057df
movb $0x5c, (%rsp,%r13)
movb $0x36, 0x80(%rsp,%r13)
incq %r13
cmpq $0x7f, %r13
jbe 0x405800
leaq 0x100(%rsp), %r13
movq %r13, %rdi
callq 0x407abc
leaq 0x80(%rsp), %rsi
movl $0x80, %edx
movq %r13, %rdi
callq 0x409252
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x409252
movq %r13, %rdi
callq 0x40576a
leaq 0x218(%rsp), %r15
movq %r15, %rdi
callq 0x407abc
movq %rsp, %rsi
movl $0x80, %edx
movq %r15, %rdi
callq 0x409252
leaq 0x1d8(%rsp), %rsi
pushq $0x40
popq %rdx
movq %r15, %rdi
callq 0x409252
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x405714
addq $0x330, %rsp            # imm = 0x330
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APKeyDerivation.cpp
// Function: APDigest::kdf(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned char*, unsigned long)
void APDigest::kdf(
    const std::string& userid,
    const std::string& password,
    const std::string& domain,
    uint8_t* dk, size_t dkLen)
{
#ifdef USE_PASSWORD_HASH
    // Replace password with its hash to be able to convert hashed
    // passwords automatically

    // Here we are assuming passwords are haded with sha512
    APDigest passwordHash(password.c_str(), password.length());

    // Use combination of userid & domain as salt

    APDigest saltHash;
    saltHash.update(userid.c_str(), userid.length());
    saltHash.update(&kdf_separator, 1);
    saltHash.update(domain.c_str(), domain.length());
    saltHash.finish();

    APDigest::pbkdf2(
        passwordHash.digest(), APDigest::DIGEST_SIZE, 
        saltHash.digest(), APDigest::DIGEST_SIZE,
        APDigest::KDF_ITERATIONS,
        dk, dkLen);
#else
    std::string salt = userid + AP_KDF_SEP + domain;
    APDigest::pbkdf2(
        password.c_str(), password.length(), 
        salt.c_str(), salt.length(),
        APDigest::KDF_ITERATIONS,
        dk, dkLen);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rsi
leaq 0x30(%rsp), %r13
pushq $0x26
popq %rdx
movq %r13, %rdi
callq 0x405aa1
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x405a82
leaq 0x30(%rsp), %rdi
callq 0x477260
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %r14, (%rsp)
pushq $0x64
popq %r8
movq %rbx, %r9
callq 0x405942
leaq 0x10(%rsp), %rdi
callq 0x477260
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x405935
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x477260
movq %rbx, %rdi
callq 0x4a94e0
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APKeyDerivation.cpp
// Function: APDigest::pbkdf2(void const*, unsigned long, void const*, unsigned long, unsigned int, unsigned char*, unsigned long)
void APDigest::pbkdf2(
    const void *password, size_t passwordLen,
    const void *salt,     size_t saltLen,
    uint32_t iterations,
    uint8_t* dk,          size_t dkLen)
{
    uint8_t *saltBlock = new uint8_t[saltLen + 4];
    uint32_t blockNumber = 1;
    memcpy (saltBlock, salt, saltLen);
    while (dkLen >= DIGEST_SIZE)
    {
        PRF((const uint8_t*)password, passwordLen, 
            saltBlock, saltLen,
            iterations, blockNumber++, dk, DIGEST_SIZE);
        dk += DIGEST_SIZE;
        dkLen -= DIGEST_SIZE;
    }

    if (dkLen > 0)
    {
        PRF((const uint8_t*)password, passwordLen, 
            saltBlock, saltLen,
            iterations, blockNumber, dk, dkLen);
    }
    delete [] saltBlock;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movl %r8d, 0xc(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movq 0x50(%rsp), %rbp
leaq 0x4(%rcx), %rdi
callq 0x40b320
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x401110
pushq $0x1
popq %r9
cmpq $0x40, %rbp
jb 0x4059bd
leal 0x1(%r9), %r12d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movl 0xc(%rsp), %r8d
pushq $0x40
pushq %rbx
callq 0x4059f4
popq %rax
popq %rcx
addq $0x40, %rbx
addq $-0x40, %rbp
movl %r12d, %r9d
jmp 0x405989
testq %rbp, %rbp
je 0x4059de
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movl 0xc(%rsp), %r8d
pushq %rbp
pushq %rbx
callq 0x4059f4
popq %rax
popq %rcx
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40a440
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APKeyDerivation.cpp
// Function: PRF(unsigned char const*, unsigned long, unsigned char*, unsigned long, unsigned int, unsigned int, unsigned char*, unsigned long)
static void PRF(
   const uint8_t *password, size_t passwordLen,
   uint8_t *saltBlock, size_t saltLen,
   uint32_t iterations,
   uint32_t blockNumber,
   uint8_t *dk, size_t dkLen)   // dkLen <= APDigest::DIGEST_SIZE
{
    uint8_t mac[APDigest::DIGEST_SIZE];
    /* saltBlock = [ Salt || INT (blockNumber)]. */
    saltBlock[saltLen + 0] = (uint8_t)(blockNumber >> 24);
    saltBlock[saltLen + 1] = (uint8_t)(blockNumber >> 16);
    saltBlock[saltLen + 2] = (uint8_t)(blockNumber >> 8);
    saltBlock[saltLen + 3] = (uint8_t)(blockNumber);

    APDigest::hmac (
        password, passwordLen, 
        saltBlock, saltLen + 4, 
        mac, sizeof(mac));
    memcpy (dk, mac, dkLen);

    while (--iterations > 0)
    {
        APDigest::hmac (
            password, passwordLen, 
            mac, APDigest::DIGEST_SIZE, 
            mac, APDigest::DIGEST_SIZE);
        for (uint32_t i = 0; i < dkLen; i++) dk[i] ^= mac[i];
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebx
movq 0x88(%rsp), %r12
movq 0x80(%rsp), %r13
bswapl %r9d
movl %r9d, (%rdx,%rcx)
addq $0x4, %rcx
movq %rsp, %rbp
pushq $0x40
popq %r9
movq %rdi, %r14
movq %rsi, %r15
movq %rbp, %r8
callq 0x40577a
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x401110
decl %ebx
je 0x405a73
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
pushq $0x40
popq %rcx
movq %rbp, %r8
movq %rcx, %r9
callq 0x40577a
xorl %eax, %eax
movl %eax, %eax
cmpq %r12, %rax
jae 0x405a43
movb (%rsp,%rax), %cl
xorb %cl, (%r13,%rax)
incl %eax
jmp 0x405a60
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APUser.cpp
// Function: APUser::createToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
const std::string APUser::createToken(
    const std::string& tag, 
    const std::string& payload)
{
    std::ostringstream s;
    s << tag << AP_SEP << std::hex << uint64_t(time(0)) << AP_SEP << payload << AP_SEP;

    std::string p = s.str();
    return p + m_private_key.signMessage(p);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x48(%rsp), %r13
movq %r13, %rdi
callq 0x46f580
movq %r13, %rdi
movq %r12, %rsi
callq 0x479c90
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0x467290
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rax
movl 0x18(%r12,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r12,%rax)
xorl %edi, %edi
callq 0x52d320
movq %r12, %rdi
movq %rax, %rsi
callq 0x467730
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0x467290
movq %rax, %rdi
movq %r15, %rsi
callq 0x479c90
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0x467290
leaq 0x50(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x46cf70
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %r14, %rsi
callq 0x406076
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x405fe4
leaq 0x28(%rsp), %rdi
callq 0x477260
leaq 0x8(%rsp), %rdi
callq 0x477260
leaq 0x48(%rsp), %rdi
callq 0x46be80
movq %rbx, %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x477260
jmp 0x405be7
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x477260
jmp 0x405bf8
jmp 0x405bf5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x46be80
movq %rbx, %rdi
callq 0x4a94e0
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APUser.cpp
// Function: APUser::registerNewUser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
const std::string APUser::registerNewUser(
    const std::string& pw_reset_info)
{
    std::ostringstream payload;
    payload << AP_DEFAULT_ALGO << AP_SEP << getPublicKey();
    if (!pw_reset_info.empty())
        payload << AP_SEP << B64Encode(
            pw_reset_info.c_str(), pw_reset_info.length());
    return createToken(AP_TAG_NEW_USER, payload.str());
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x50(%rsp), %r12
movq %r12, %rdi
callq 0x46f580
leaq 0x173af2(%rip), %rsi    # 0x579735
movq %r12, %rdi
callq 0x467360
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0x467290
movq %rax, %r12
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x406060
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x479c90
leaq 0x10(%rsp), %rdi
callq 0x477260
cmpq $0x0, 0x8(%r15)
je 0x405cbc
leaq 0x50(%rsp), %rdi
pushq $0x2e
popq %rsi
callq 0x467290
movq %rax, %r12
movq (%r15), %rsi
movq 0x8(%r15), %rdx
leaq 0x10(%rsp), %rdi
callq 0x40932c
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x479c90
leaq 0x10(%rsp), %rdi
callq 0x477260
leaq 0x19ade4(%rip), %rsi    # 0x5a0aa7
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x405048
leaq 0x58(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x46cf70
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x405ae4
leaq 0x30(%rsp), %rdi
callq 0x477260
leaq 0x10(%rsp), %rdi
callq 0x477260
leaq 0x50(%rsp), %rdi
callq 0x46be80
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x405d3d
jmp 0x405d4e
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x477260
jmp 0x405d40
jmp 0x405d3d
jmp 0x405d4e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x477260
jmp 0x405d51
jmp 0x405d4e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x46be80
movq %rbx, %rdi
callq 0x4a94e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APUser.cpp
// Function: APUser::changePassword[abi:cxx11](APUser const&)
const std::string APUser::changePassword(
    const APUser& new_key)
{
    std::string payload = new_key.getPublicKey();
    std::string token = createToken(AP_TAG_CHANGE_PASSWORD, payload);
    m_private_key = new_key.m_private_key;
    return token;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x30(%rsp), %rdi
movq %rdx, %rsi
callq 0x406060
leaq 0x1738ba(%rip), %rsi    # 0x57973e
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x405048
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x405ae4
leaq 0x10(%rsp), %rdi
callq 0x477260
movq %r15, %rdi
movq %r14, %rsi
callq 0x4060b2
leaq 0x30(%rsp), %rdi
callq 0x477260
movq %rbx, %rax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
movq %rbx, %rdi
jmp 0x405ee4
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x477260
jmp 0x405eee
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x477260
movq %r14, %rdi
callq 0x4a94e0
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/client/APPrivateKey.cpp
// Function: APPrivateKey::signMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string APPrivateKey::signMessage(const std::string& msg)
{
    unsigned char sig[SignatureSize];
    ed25519_SignMessage (sig, m_Key, &edp_signature_blinding,
        (const unsigned char*)msg.c_str(), msg.length());

    return B64Encode(sig, sizeof(sig));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq (%rdx), %rcx
movq 0x8(%rdx), %r8
leaq 0x1e418a(%rip), %rdx    # 0x5ea218
movq %rsp, %r14
movq %r14, %rdi
callq 0x406f9d
pushq $0x40
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40932c
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: hex_string_to_u64(char const*, unsigned long&)
const char* hex_string_to_u64(const char* p, uint64_t& val)
{
    val = 0;
    do
    {
        int d = get_hex_digit(*p);
        if (d < 0) break;

        p++;
        val = (val << 4) + d;
    } while(1);
    return p;
}

// Assembly:
movq %rdi, %rax
xorl %ecx, %ecx
movq %rcx, (%rsi)
movsbl (%rax), %edx
leal -0x30(%rdx), %edi
cmpb $0x9, %dil
ja 0x40619c
addl $-0x30, %edx
jmp 0x4061b6
leal -0x41(%rdx), %edi
cmpb $0x5, %dil
ja 0x4061aa
addl $-0x37, %edx
jmp 0x4061b6
leal -0x61(%rdx), %edi
cmpb $0x5, %dil
ja 0x4061c8
addl $-0x57, %edx
testl %edx, %edx
js 0x4061c8
incq %rax
shlq $0x4, %rcx
movl %edx, %edx
addq %rdx, %rcx
jmp 0x406188
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::SplitToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int APVerifier::SplitToken(const std::string& token)
{
    std::istringstream t(token);
    std::string s;
    m_items.clear();
    while (std::getline(t, s, AP_SEP)) m_items.push_back(s);

    if (m_items.size() < 3 || m_items[0].length() != 2)
        return AP_E_FORMAT;

    const char* p = m_items[0].c_str();
    m_tag = ((unsigned char)p[0] << 8) | (unsigned char)p[1];

    // Next item is timestamp (in hex format)
    p = hex_string_to_u64(m_items[1].c_str(), m_token_timestamp);
    if (*p != '\0') return AP_E_TIMESTAMP;

    // Validate timestamp against verifier time
    // Allow maximum of 30 mins difference
    uint64_t time_now = (uint64_t)time(NULL);

    if (m_token_timestamp > time_now)
    {
        // Token time is in future!!
        // We assume client time is not set accurately
        if (m_token_timestamp > (time_now + APV_MAX_TOKEN_TIME_DIFF))
            return AP_E_TIME;
    }
    else
    {
        if (time_now > (m_token_timestamp + APV_MAX_TOKEN_TIME_DIFF))
            return AP_E_TIME;
    }

    return AP_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, %rbx
leaq 0x20(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x46ec50
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x38(%rbx), %r15
movq %r15, %rdi
callq 0x406544
movq %rsp, %r12
pushq $0x2e
popq %rbp
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x40b7e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x406237
movq %r15, %rdi
movq %r12, %rsi
callq 0x40656e
jmp 0x40620f
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rcx
subq %rax, %rcx
pushq $-0x2
popq %rbp
cmpq $0x41, %rcx
jb 0x406298
cmpq $0x2, 0x8(%rax)
jne 0x406298
movq (%rax), %rcx
movzwl (%rcx), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, 0x24(%rbx)
movq 0x20(%rax), %rdi
addq $0x28, %rbx
movq %rbx, %rsi
callq 0x406183
cmpb $0x0, (%rax)
je 0x40627b
pushq $-0x5
jmp 0x406297
xorl %edi, %edi
callq 0x52d320
movq (%rbx), %rcx
cmpq %rax, %rcx
jbe 0x4062bc
addq $0x708, %rax            # imm = 0x708
cmpq %rax, %rcx
jbe 0x4062c8
pushq $-0xb
popq %rbp
movq %rsp, %rdi
callq 0x477260
leaq 0x20(%rsp), %rdi
callq 0x46c540
movl %ebp, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0x708, %rcx            # imm = 0x708
cmpq %rcx, %rax
ja 0x406295
xorl %ebp, %ebp
jmp 0x406298
movq %rax, %rbx
movq %rsp, %rdi
callq 0x477260
leaq 0x20(%rsp), %rdi
callq 0x46c540
movq %rbx, %rdi
callq 0x4a94e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::ValidateToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long)
int APVerifier::ValidateToken(
    const std::string& token,
    size_t key_index)
{
    unsigned char sig[64];

    do
    {
        m_error = SplitToken(token);
        if (m_error != AP_SUCCESS) break;

        size_t nItems = m_items.size();

        // Last item is the signature in base64 format
        std::string& signature = m_items[nItems-1];
        if (B64Decode(signature, sig, sizeof(sig)) != sizeof(sig))
        {
            m_error = AP_E_B64_ITEM;
            break;
        }

        // If self-sined, key_index points to the public key
        if (key_index > 0)
        {
            if (key_index < 2 || key_index >= (nItems - 1))
            {
                m_error = AP_E_PARAMETER;
                break;
            }
            if (setKey(m_items[key_index]) != AP_SUCCESS) break;
        }

        m_error = m_public_key.verifySignature(
            (const unsigned char*)token.c_str(), 
            token.length() - signature.length(), 
            &sig[0]) ? 
            AP_SUCCESS : AP_E_SIGNATURE;

    } while(0);
    return m_error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
callq 0x4061ca
movl %eax, 0x20(%rbx)
testl %eax, %eax
jne 0x4063a4
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %r13
subq %rax, %r13
sarq $0x5, %r13
decq %r13
movq %r13, %r12
shlq $0x5, %r12
addq %rax, %r12
movq %rsp, %rsi
pushq $0x40
popq %rdx
movq %r12, %rdi
callq 0x40942b
cmpq $0x40, %rax
jne 0x40636c
testq %r15, %r15
je 0x406380
cmpq $0x1, %r15
je 0x406377
cmpq %r15, %r13
jbe 0x406377
shlq $0x5, %r15
addq 0x38(%rbx), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40612a
testl %eax, %eax
je 0x406380
movl 0x20(%rbx), %eax
jmp 0x4063a4
movl $0xfffffff6, 0x20(%rbx) # imm = 0xFFFFFFF6
pushq $-0xa
jmp 0x40637d
orl $-0x1, 0x20(%rbx)
pushq $-0x1
popq %rax
jmp 0x4063a4
movq (%r14), %rsi
movq 0x8(%r14), %rdx
subq 0x8(%r12), %rdx
movq %rsp, %rcx
movq %rbx, %rdi
callq 0x40685a
movzbl %al, %eax
leal -0x8(,%rax,8), %eax
movl %eax, 0x20(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::parseUserRegistrationToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool APVerifier::parseUserRegistrationToken(
    const std::string& token)
{
    m_error = SplitToken(token);
    if (m_error == AP_SUCCESS)
    {
        if (m_items.size() < 4)
            m_error = AP_E_FORMAT;
        else if (m_tag != AP_NEW_USER)
            m_error = AP_E_TOKEN;
        else if (m_items[2] != AP_DEFAULT_ALGO)
            m_error = AP_E_ALGO;
        else
            setKey(m_items[3]);
    }
    m_token_expiration_time = 0;
    return isValid();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x4061ca
movl %eax, 0x20(%rbx)
testl %eax, %eax
jne 0x406456
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rax
subq %rdi, %rax
cmpq $0x7f, %rax
ja 0x406424
movl $0xfffffffe, 0x20(%rbx) # imm = 0xFFFFFFFE
pushq $-0x2
jmp 0x406455
cmpl $0x6e75, 0x24(%rbx)     # imm = 0x6E75
jne 0x40644c
addq $0x40, %rdi
leaq 0x1732fd(%rip), %rsi    # 0x579735
callq 0x40659a
testb %al, %al
je 0x406462
movl $0xfffffffd, 0x20(%rbx) # imm = 0xFFFFFFFD
pushq $-0x3
jmp 0x406455
movl $0xfffffffc, 0x20(%rbx) # imm = 0xFFFFFFFC
pushq $-0x4
popq %rax
andq $0x0, 0x30(%rbx)
testl %eax, %eax
setns %al
popq %rbx
retq
movq 0x38(%rbx), %rsi
addq $0x60, %rsi
movq %rbx, %rdi
callq 0x40612a
movl 0x20(%rbx), %eax
jmp 0x406456
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::parseUserLoginToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool APVerifier::parseUserLoginToken(const std::string& token)
{
    do
    {
        if (ValidateToken(token) != AP_SUCCESS) break;

        if (m_tag != AP_USER_LOGIN)
        {
            m_error = AP_E_TOKEN;
            break;
        }

        // item(2) is token duration (in hex)
        uint64_t duration = 0;
        const char* p = hex_string_to_u64(m_items[2].c_str(), duration);
        if (*p != '\0' || duration > APV_MAX_LOGIN_DURATION)
        {
            m_error = AP_E_TIMESTAMP;
            break;
        }

        m_token_expiration_time = (uint64_t)time(NULL) + duration;

    } while(0);
    return isValid();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %edx, %edx
callq 0x4062ea
testl %eax, %eax
jne 0x4064e4
cmpl $0x6c69, 0x24(%rbx)     # imm = 0x6C69
jne 0x4064cd
movq %rsp, %r14
andq $0x0, (%r14)
movq 0x38(%rbx), %rax
movq 0x40(%rax), %rdi
movq %r14, %rsi
callq 0x406183
cmpb $0x0, (%rax)
setne %al
movq (%r14), %r14
cmpq $0xe11, %r14            # imm = 0xE11
setae %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x4064d6
movl $0xfffffffb, 0x20(%rbx) # imm = 0xFFFFFFFB
jmp 0x4064e4
movl $0xfffffffc, 0x20(%rbx) # imm = 0xFFFFFFFC
jmp 0x4064e4
xorl %edi, %edi
callq 0x52d320
addq %r14, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, 0x20(%rbx)
setns %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::parseChangePasswordToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool APVerifier::parseChangePasswordToken(const std::string& token)
{
    if (ValidateToken(token) == AP_SUCCESS)
    {
        if (m_tag == AP_CHANGE_PASSWORD)
            setKey(getItem(2)); // Change public key
        else
            m_error = AP_E_TOKEN;
    }
    return isValid();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %edx, %edx
callq 0x4062ea
testl %eax, %eax
jne 0x40653b
cmpl $0x6370, 0x24(%rbx)     # imm = 0x6370
jne 0x406534
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rcx
subq %rax, %rcx
addq $0x40, %rax
cmpq $0x41, %rcx
leaq 0x1e629a(%rip), %rsi    # 0x5ec7c0
cmovaeq %rax, %rsi
movq %rbx, %rdi
callq 0x40612a
jmp 0x40653b
movl $0xfffffffc, 0x20(%rbx) # imm = 0xFFFFFFFC
cmpl $0x0, 0x20(%rbx)
setns %al
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_AddBasePoint
void edp_AddBasePoint(Ext_POINT *p)
{
    U_WORD a[K_WORDS], b[K_WORDS], c[K_WORDS], d[K_WORDS], e[K_WORDS];

    ecp_SubReduce(a, p->y, p->x);           /* A = (Y1-X1)*(Y2-X2) */
    ecp_MulReduce(a, a, _w_base_folding8[1].YmX);
    ecp_AddReduce(b, p->y, p->x);           /* B = (Y1+X1)*(Y2+X2) */
    ecp_MulReduce(b, b, _w_base_folding8[1].YpX);
    ecp_MulReduce(c, p->t, _w_base_folding8[1].T2d); /* C = T1*2d*T2 */
    ecp_AddReduce(d, p->z, p->z);           /* D = 2*Z1 */
    ecp_SubReduce(e, b, a);                 /* E = B-A */
    ecp_AddReduce(b, b, a);                 /* H = B+A */
    ecp_SubReduce(a, d, c);                 /* F = D-C */
    ecp_AddReduce(d, d, c);                 /* G = D+C */

    ecp_MulReduce(p->x, e, a);              /* E*F */
    ecp_MulReduce(p->y, b, d);              /* H*G */
    ecp_MulReduce(p->t, e, b);              /* E*H */
    ecp_MulReduce(p->z, d, a);              /* G*F */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r15
leaq 0x20(%rdi), %r14
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, (%rsp)
movq %r15, %rdx
callq 0x4096e8
leaq 0x172f6f(%rip), %rdx    # 0x579820
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x4099e0
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x409628
leaq 0x172f2a(%rip), %rdx    # 0x579800
movq %r12, %rdi
movq %r12, %rsi
callq 0x4099e0
leaq 0x60(%r15), %rsi
movq %rsi, 0x8(%rsp)
leaq 0x172f4f(%rip), %rdx    # 0x579840
leaq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x4099e0
leaq 0x40(%r15), %rbp
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x409628
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4096e8
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x409628
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x4096e8
movq %r13, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x409628
movq %r15, %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4099e0
movq (%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4099e0
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4099e0
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4099e0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_AddAffinePoint
void edp_AddAffinePoint(Ext_POINT *p, const PA_POINT *q)
{
    U_WORD a[K_WORDS], b[K_WORDS], c[K_WORDS], d[K_WORDS], e[K_WORDS];
    ecp_SubReduce(a, p->y, p->x);           /* A = (Y1-X1)*(Y2-X2) */
    ecp_MulReduce(a, a, q->YmX);
    ecp_AddReduce(b, p->y, p->x);           /* B = (Y1+X1)*(Y2+X2) */
    ecp_MulReduce(b, b, q->YpX);
    ecp_MulReduce(c, p->t, q->T2d);         /* C = T1*2d*T2 */
    ecp_AddReduce(d, p->z, p->z);           /* D = Z1*2*Z2 (Z2=1)*/
    ecp_SubReduce(e, b, a);                 /* E = B-A */
    ecp_AddReduce(b, b, a);                 /* H = B+A */
    ecp_SubReduce(a, d, c);                 /* F = D-C */
    ecp_AddReduce(d, d, c);                 /* G = D+C */

    ecp_MulReduce(p->x, e, a);              /* E*F */
    ecp_MulReduce(p->y, b, d);              /* H*G */
    ecp_MulReduce(p->t, e, b);              /* E*H */
    ecp_MulReduce(p->z, d, a);              /* G*F */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r13
movq %rdi, %r15
leaq 0x20(%rdi), %r14
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, (%rsp)
movq %r15, %rdx
callq 0x4096e8
leaq 0x20(%r13), %rdx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x4099e0
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x409628
movq %r12, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4099e0
leaq 0x60(%r15), %rsi
movq %rsi, 0x8(%rsp)
addq $0x40, %r13
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %r13, %rdx
callq 0x4099e0
leaq 0x40(%r15), %rbp
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x409628
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4096e8
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x409628
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x4096e8
movq %r13, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x409628
movq %r15, %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4099e0
movq (%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4099e0
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4099e0
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4099e0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_DoublePoint
void edp_DoublePoint(Ext_POINT *p)
{
    U_WORD a[K_WORDS], b[K_WORDS], c[K_WORDS], d[K_WORDS], e[K_WORDS];

    ecp_SqrReduce(a, p->x);         /* A = X1^2 */
    ecp_SqrReduce(b, p->y);         /* B = Y1^2 */
    ecp_SqrReduce(c, p->z);         /* C = 2*Z1^2 */
    ecp_AddReduce(c, c, c);
    ecp_SubReduce(d, _w_maxP, a);   /* D = -A */

    ecp_SubReduce(a, d, b);         /* H = D-B */
    ecp_AddReduce(d, d, b);         /* G = D+B */
    ecp_SubReduce(b, d, c);         /* F = G-C */
    ecp_AddReduce(e, p->x, p->y);   /* E = (X1+Y1)^2-A-B = (X1+Y1)^2+H */
    ecp_SqrReduce(e, e);
    ecp_AddReduce(e, e, a);

    ecp_MulReduce(p->x, e, b);      /* E*F */
    ecp_MulReduce(p->y, a, d);      /* H*G */
    ecp_MulReduce(p->z, d, b);      /* G*F */
    ecp_MulReduce(p->t, e, a);      /* E*H */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r14
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x409c66
leaq 0x20(%r14), %r12
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x409c66
leaq 0x40(%r14), %rsi
movq %rsi, 0x8(%rsp)
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x409c66
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x409628
movq $0x57fbc0, %rsi         # imm = 0x57FBC0
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0x4096e8
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4096e8
movq %rbp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x409628
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x4096e8
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x409628
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x409c66
movq %rbx, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x409628
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4099e0
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x4099e0
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4099e0
addq $0x60, %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x4099e0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_BasePointMult
void edp_BasePointMult(
    OUT Ext_POINT *S, 
    IN const U_WORD *sk, 
    IN const U_WORD *R)
{
    int i = 1;
    U8 cut[32];
    const PA_POINT *p0;

    ecp_8Folds(cut, sk);

    p0 = &_w_base_folding8[cut[0]];

    ecp_SubReduce(S->x, p0->YpX, p0->YmX);  /* 2x */
    ecp_AddReduce(S->y, p0->YpX, p0->YmX);  /* 2y */
    ecp_MulReduce(S->t, p0->T2d, _w_di);    /* 2xy */

    /* Randomize starting point */

    ecp_AddReduce(S->z, R, R);              /* Z = 2R */
    ecp_MulReduce(S->x, S->x, R);           /* X = 2xR */
    ecp_MulReduce(S->t, S->t, R);           /* T = 2xyR */
    ecp_MulReduce(S->y, S->y, R);           /* Y = 2yR */

    do 
    {
        edp_DoublePoint(S);
        edp_AddAffinePoint(S, &_w_base_folding8[cut[i]]);
    } while (i++ < 31);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x40a3ef
movzbl (%r15), %eax
imulq $0x60, %rax, %r15
leaq 0x172b8e(%rip), %rbp    # 0x5797a0
leaq (%r15,%rbp), %r12
leaq (%r15,%rbp), %r13
addq $0x20, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4096e8
leaq 0x20(%rbx), %rdi
movq %rdi, 0x8(%rsp)
movq %r12, %rsi
movq %r13, %rdx
callq 0x409628
leaq 0x60(%rbx), %r12
leaq (%r15,%rbp), %rsi
addq $0x40, %rsi
leaq 0x172b2d(%rip), %rdx    # 0x579780
movq %r12, %rdi
callq 0x4099e0
leaq 0x40(%rbx), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x409628
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4099e0
movq %r12, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4099e0
movq 0x8(%rsp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x4099e0
pushq $0x1
popq %r14
movq %rbx, %rdi
callq 0x406ac6
movzbl 0x10(%rsp,%r14), %eax
imulq $0x60, %rax, %rsi
addq %rbp, %rsi
movq %rbx, %rdi
callq 0x4069a1
incq %r14
cmpq $0x20, %r14
jne 0x406c9a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_BasePointMultiply
void edp_BasePointMultiply(
    OUT Affine_POINT *R, 
    IN const U_WORD *sk, 
    IN const void *blinding)
{
    Ext_POINT S;
    U_WORD t[K_WORDS];

    if (blinding)
    {
        eco_AddReduce(t, sk, ((EDP_BLINDING_CTX*)blinding)->bl);
        edp_BasePointMult(&S, t, ((EDP_BLINDING_CTX*)blinding)->zr);
        edp_AddPoint(&S, &S, &((EDP_BLINDING_CTX*)blinding)->BP);
    }
    else
    {
        edp_BasePointMult(&S, sk, edp_custom_blinding.zr);
    }

    ecp_Inverse(S.z, S.z);
    ecp_MulMod(R->x, S.x, S.z);
    ecp_MulMod(R->y, S.y, S.z);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
testq %rdx, %rdx
je 0x406d1e
movq %rdx, %r14
leaq 0x80(%rsp), %r15
movq %r15, %rdi
callq 0x40a1dc
leaq 0x20(%r14), %rdx
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x406be2
addq $0x40, %r14
movq %r12, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x407457
jmp 0x406d31
movq $0x5ea2d8, %rdx         # imm = 0x5EA2D8
addq $0x20, %rdx
movq %rsp, %rdi
callq 0x406be2
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
callq 0x409d2b
movq %rsp, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x409d19
addq $0x20, %rbx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x409d19
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_sign.c
// Function: edp_ExtPoint2PE
void edp_ExtPoint2PE(PE_POINT *r, const Ext_POINT *p)
{
    ecp_AddReduce(r->YpX, p->y, p->x);
    ecp_SubReduce(r->YmX, p->y, p->x);
    ecp_MulReduce(r->T2d, p->t, _w_2d);
    ecp_AddReduce(r->Z2, p->z, p->z);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsi), %r15
movq %r15, %rsi
movq %rbx, %rdx
callq 0x409628
leaq 0x20(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4096e8
leaq 0x40(%r14), %rdi
leaq 0x60(%rbx), %rsi
leaq 0x1729b6(%rip), %rdx    # 0x579760
callq 0x4099e0
addq $0x60, %r14
addq $0x40, %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x409628