LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: getFolderNameFromHash
char *getFolderNameFromHash(uint32_t hash, unsigned int flags) {
	char *retstring = malloc(16);
	switch(hash) {
		case 0x7F000010: RETPRINT("sound")
		case 0x7F010000: RETPRINT("nocache")
		case 0x7F000002: RETPRINT("cache")
		case 0x7F000003: RETPRINT("resident")
		case 0x7F000004: RETPRINT(flags & GAME_TTS ? "tts-04" : "delayload")
		case 0x7F000005: RETPRINT(flags & GAME_TTS ? "tts-05" : "delayload_w")
		default: {
			sprintf(retstring, "%08x", hash);
			break;
		}
	}
	return retstring;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
pushq $0x10
popq %rdi
callq 0x5170
movq %rax, %rbx
leal -0x7f000002(%r14), %eax
cmpl $0x3, %eax
ja 0x58e5
leaq 0x27ed(%rip), %rcx      # 0x80b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x65, 0x4(%rbx)
movl $0x68636163, (%rbx)     # imm = 0x68636163
jmp 0x5971
cmpl $0x7f010000, %r14d      # imm = 0x7F010000
je 0x5905
cmpl $0x7f000010, %r14d      # imm = 0x7F000010
jne 0x5928
movw $0x64, 0x4(%rbx)
movl $0x6e756f73, (%rbx)     # imm = 0x6E756F73
jmp 0x5971
movabsq $0x65686361636f6e, %rax # imm = 0x65686361636F6E
movq %rax, (%rbx)
jmp 0x5971
testb $0x10, %bpl
leaq 0x2ca9(%rip), %rax      # 0x85c8
leaq 0x2c9b(%rip), %rsi      # 0x85c1
jmp 0x5950
leaq 0x2c78(%rip), %rsi      # 0x85a7
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x5220
jmp 0x5971
testb $0x10, %bpl
leaq 0x2c90(%rip), %rax      # 0x85d9
leaq 0x2c82(%rip), %rsi      # 0x85d2
cmoveq %rax, %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x5050
movabsq $0x746e656469736572, %rax # imm = 0x746E656469736572
movq %rax, (%rbx)
movb $0x0, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: getFileNameFromHashes
char *getFileNameFromHashes(uint32_t hash, uint32_t extension, unsigned int flags) {
	char *retstring = malloc(64);
	char *extensionstring = NULL;
	unsigned int result = matchhash(hash, extension, stagedic, numstagedic);
	if(result != 0xFFFFFFFF) sprintf(retstring, "%s", stagedic[result].name);
	else {
		result = matchhash(hash, extension, commondic, numcommondic);
		if(result != 0xFFFFFFFF) sprintf(retstring, "%s", commondic[result].name);
		else {
			if(flags & GAME_MGS2) sprintf(retstring, "%08x.%c", hash, extension+0x61 /* 'a' */);
			/* see extlist comment for info on how games are sorted */
			else if(flags & (GAME_MGS3|GAME_MGS4)) sprintf(retstring, "%08x.%s", hash, extList[(flags & GAME_MGS4) ? 1 : 0][extension]);
			else if(flags & GAME_ZOE2) {
				extensionstring = getExtensionFromHash32(extension);
				sprintf(retstring, "%08x.%s", hash, extensionstring);
				free(extensionstring);
			}
		}
	}
	return retstring;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r15d
movl %esi, %r14d
movl %edi, %ebp
pushq $0x40
popq %rdi
callq 0x5170
movq %rax, %rbx
movq 0x68e5(%rip), %r12      # 0xc280
movl 0x68eb(%rip), %ecx      # 0xc28c
movl %ebp, %edi
movl %r14d, %esi
movq %r12, %rdx
callq 0x5801
cmpl $-0x1, %eax
jne 0x59d2
movq 0x68be(%rip), %r12      # 0xc278
movl 0x68c8(%rip), %ecx      # 0xc288
movl %ebp, %edi
movl %r14d, %esi
movq %r12, %rdx
callq 0x5801
cmpl $-0x1, %eax
je 0x59f3
movl %eax, %eax
imulq $0x108, %rax, %rax      # imm = 0x108
leaq (%r12,%rax), %rsi
addq $0x8, %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5050
testb $0x1, %r15b
jne 0x5a2d
testb $0x6, %r15b
je 0x5a53
movl %r14d, %eax
andl $0x4, %r15d
shll $0x9, %r15d
leaq 0x573f(%rip), %rcx      # 0xb150
addq %r15, %rcx
movq (%rcx,%rax,8), %rcx
leaq 0x2bce(%rip), %rsi      # 0x85ed
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x5220
jmp 0x5a47
addl $0x61, %r14d
leaq 0x2bad(%rip), %rsi      # 0x85e5
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x5220
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
testb $0x8, %r15b
je 0x5a47
movl %r14d, %edi
callq 0x582f
movq %rax, %r14
leaq 0x2b82(%rip), %rsi      # 0x85ed
movq %rbx, %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x5220
movq %r14, %rdi
callq 0x5030
jmp 0x5a47
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: decryptHeader
unsigned int decryptHeader(unsigned char *data, unsigned int length, unsigned int flags) {
	uint32_t *values = (uint32_t *)data;
	uint32_t seed, workkey;
	if(flags & IS_BIGENDIAN) workkey = initialkeybig;
	else workkey = initialkey;
	unsigned int i;
	for(i = 0; i < length ;i++) {
		seed = workkey * key1;
		values[i] ^= workkey;
		if(flags & IS_BIGENDIAN) workkey = seed + (initialkeybig ^ 0x0000F0F0);
		else workkey = seed + (initialkey ^ 0x0000F0F0);
	}
	return 1;
}

// Assembly:
testb $0x14, %dl
leaq 0x67e2(%rip), %rcx      # 0xc270
leaq 0x67df(%rip), %rax      # 0xc274
cmoveq %rcx, %rax
movl (%rax), %edx
movl %esi, %ecx
xorl %esi, %esi
movl $0xf0f0, %r8d           # imm = 0xF0F0
cmpq %rsi, %rcx
je 0x5ac5
movl 0x567f(%rip), %r9d      # 0xb130
imull %edx, %r9d
xorl %edx, (%rdi,%rsi,4)
movl (%rax), %edx
xorl %r8d, %edx
addl %r9d, %edx
incq %rsi
jmp 0x5aa5
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: decryptStage
unsigned int decryptStage(unsigned char *data, unsigned int length, char *name, unsigned int flags) {
	uint32_t *values = (uint32_t *)data;
	uint32_t seed, workkey, namehash, workkeyt;
	unsigned int i;
	if(flags & GAME_ZOE2) namehash = StrCode32(name);
	else namehash = StrCode24(name);
	workkeyt = (namehash << 0x07) + namehash + key2;
	if(flags & IS_BIGENDIAN) workkey = (namehash << 0x07) + initialkeybig + namehash + key34;
	else workkey = (namehash << 0x07) + initialkey + namehash + key34;
	for(i = 0; i < length; i++) {
		seed = workkey * key1;
		values[i] ^= workkey;
		workkey = seed + workkeyt;
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movq %rdx, %rdi
testb $0x8, %r14b
jne 0x5ae5
callq 0x535a
jmp 0x5aea
callq 0x5380
imull $0x81, %eax, %ecx
movl 0x563e(%rip), %eax      # 0xb134
addl %ecx, %eax
testb $0x14, %r14b
leaq 0x676d(%rip), %rdx      # 0xc270
leaq 0x676a(%rip), %rsi      # 0xc274
cmoveq %rdx, %rsi
addl (%rsi), %ecx
addl 0x5622(%rip), %ecx      # 0xb138
movl %ebp, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x5b34
movl 0x560b(%rip), %edi      # 0xb130
xorl %ecx, (%rbx,%rsi,4)
imull %ecx, %edi
addl %eax, %edi
incq %rsi
movl %edi, %ecx
jmp 0x5b1a
pushq $0x1
popq %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: decryptContent
unsigned int decryptContent(unsigned char *data, unsigned int length) {
	uint32_t *values = (uint32_t *)data;
	uint32_t seed, workkey, workkeyt, workkeyv;
	unsigned int i;
	workkeyv = key5 ^ key6;
	workkeyt = workkeyv * key7;
	workkey = workkeyv | ((workkeyv ^ key8) << 0x10);
	for(i = 0; i < length; i++) {
		seed = workkey * key1;
		values[i] ^= workkey;
		workkey = seed + workkeyt;
	}
	return 1;
}

// Assembly:
movl 0x55fe(%rip), %edx      # 0xb140
xorl 0x55f4(%rip), %edx      # 0xb13c
movl 0x55f6(%rip), %eax      # 0xb144
imull %edx, %eax
movl 0x55f1(%rip), %ecx      # 0xb148
xorl %edx, %ecx
shll $0x10, %ecx
orl %edx, %ecx
movl %esi, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x5b80
movl 0x55c2(%rip), %r8d      # 0xb130
xorl %ecx, (%rdi,%rsi,4)
imull %ecx, %r8d
addl %eax, %r8d
incq %rsi
movl %r8d, %ecx
jmp 0x5b62
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/lua/src/luac.c
// Function: main
int main(int argc, char* argv[])
{
 lua_State* L;
 struct Smain s;
 int i=doargs(argc,argv);
 argc-=i; argv+=i;
 if (argc<=0) usage("no input files given");
 L=lua_open();
 if (L==NULL) fatal("not enough memory for state");
 s.argc=argc;
 s.argv=argv;
 if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1));
 lua_close(L);
 return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rax
testq %rax, %rax
je 0x239f
cmpb $0x0, (%rax)
je 0x239f
movq %rax, 0x17db1(%rip)     # 0x1a150
xorl %r15d, %r15d
pushq $0x1
popq %rbp
movl 0x17dc5(%rip), %eax     # 0x1a170
leaq 0xec52(%rip), %rcx      # 0x11004
cmpl %ebx, %ebp
jge 0x249c
movslq %ebp, %rdx
movq (%r14,%rdx,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x249c
movzbl 0x1(%rdi), %esi
leal -0x6c(%rsi), %r8d
cmpl $0xa, %r8d
ja 0x2475
movslq (%rcx,%r8,4), %rsi
addq %rcx, %rsi
jmpq *%rsi
cmpb $0x0, 0x2(%rdi)
jne 0x2540
incl %eax
movl %eax, 0x17d79(%rip)     # 0x1a170
jmp 0x246e
cmpb $0x0, 0x2(%rdi)
jne 0x2540
movq 0x8(%r14,%rdx,8), %rdx
movq %rdx, 0x17d49(%rip)     # 0x1a158
testq %rdx, %rdx
je 0x2545
incl %ebp
movzbl (%rdx), %esi
cmpl $0x2d, %esi
je 0x2460
testl %esi, %esi
jne 0x246e
jmp 0x2545
cmpb $0x0, 0x2(%rdi)
jne 0x2540
movb $0x1, 0x17d3c(%rip)     # 0x1a178
jmp 0x246e
cmpb $0x0, 0x2(%rdi)
jne 0x2540
incl %r15d
jmp 0x246e
cmpb $0x0, 0x2(%rdi)
jne 0x2540
movb $0x1, 0x17d16(%rip)     # 0x1a174
jmp 0x246e
cmpb $0x0, 0x1(%rdx)
jne 0x246e
andq $0x0, 0x17cea(%rip)     # 0x1a158
incl %ebp
jmp 0x23b2
testl %esi, %esi
je 0x249c
cmpl $0x2d, %esi
jne 0x2540
cmpb $0x0, 0x2(%rdi)
jne 0x2540
incl %ebp
leal 0x1(%r15), %ecx
testl %r15d, %r15d
cmovel %r15d, %ecx
movl %ecx, %r15d
cmpl %ebx, %ebp
jne 0x24c8
testl %eax, %eax
jne 0x24af
testb $0x1, 0x17cc9(%rip)     # 0x1a174
movl %ebx, %ebp
je 0x24c8
movb $0x1, 0x17cbe(%rip)     # 0x1a174
leal -0x1(%rbx), %ebp
movslq %ebx, %rax
leaq 0x17c9d(%rip), %rcx     # 0x1a160
movq %rcx, -0x8(%r14,%rax,8)
testl %r15d, %r15d
je 0x24f5
leaq 0xeba1(%rip), %rdi      # 0x11075
leaq 0xeba2(%rip), %rsi      # 0x1107d
leaq 0xeba5(%rip), %rdx      # 0x11087
xorl %eax, %eax
callq 0x20f0
leal -0x1(%rbx), %eax
cmpl %eax, %r15d
je 0x257e
subl %ebp, %ebx
jle 0x2551
callq 0xe27a
testq %rax, %rax
je 0x255d
movq %rax, %r15
movslq %ebp, %rax
leaq (%r14,%rax,8), %rax
leaq 0x8(%rsp), %rdx
movl %ebx, (%rdx)
movq %rax, 0x8(%rdx)
leaq 0xe9(%rip), %rsi        # 0x2608
movq %r15, %rdi
callq 0x3ed0
testl %eax, %eax
jne 0x2569
movq %r15, %rdi
callq 0xa290
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2585
leaq 0xeb15(%rip), %rdi      # 0x11061
callq 0x2585
leaq 0xead8(%rip), %rdi      # 0x11030
callq 0x2585
leaq 0xeae1(%rip), %rdi      # 0x11045
callq 0x25dd
pushq $-0x1
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x35c1
movq %rax, %rdi
callq 0x25dd
xorl %edi, %edi
callq 0x2220
// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/lua/src/luac.c
// Function: usage
static void usage(const char* message)
{
 if (*message=='-')
  fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
 else
  fprintf(stderr,"%s: %s\n",progname,message);
 fprintf(stderr,
 "usage: %s [options] [filenames].\n"
 "Available options are:\n"
 "  -        process stdin\n"
 "  -l       list\n"
 "  -o name  output to file " LUA_QL("name") " (default is \"%s\")\n"
 "  -p       parse only\n"
 "  -s       strip debug information\n"
 "  -v       show version information\n"
 "  --       stop handling options\n",
 progname,Output);
 exit(EXIT_FAILURE);
}

// Assembly:
pushq %rbx
movq %rdi, %rcx
cmpb $0x2d, (%rdi)
movq 0x17a65(%rip), %rbx     # 0x19ff8
movq (%rbx), %rdi
movq 0x17bb3(%rip), %rdx     # 0x1a150
leaq 0xeb11(%rip), %rax      # 0x110b5
leaq 0xec75(%rip), %rsi      # 0x11220
cmoveq %rax, %rsi
xorl %eax, %eax
callq 0x2150
movq (%rbx), %rdi
movq 0x17b90(%rip), %rdx     # 0x1a150
leaq 0xeb0c(%rip), %rsi      # 0x110d3
leaq 0x17b92(%rip), %rcx     # 0x1a160
xorl %eax, %eax
callq 0x2150
pushq $0x1
popq %rdi
callq 0x2220
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha256_Init
void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass,
                             int passlen, const uint8_t *salt, int saltlen,
                             uint32_t blocknr) {
  SHA256_CTX ctx;
#if BYTE_ORDER == LITTLE_ENDIAN
  REVERSE32(blocknr, blocknr);
#endif

  hmac_sha256_prepare(pass, passlen, pctx->odig, pctx->idig);
  memzero(pctx->g, sizeof(pctx->g));
  pctx->g[8] = 0x80000000;
  pctx->g[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8;

  memcpy(ctx.state, pctx->idig, sizeof(pctx->idig));
  ctx.bitcount = SHA256_BLOCK_LENGTH * 8;
  sha256_Update(&ctx, salt, saltlen);
  sha256_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr));
  sha256_Final(&ctx, (uint8_t *)pctx->g);
#if BYTE_ORDER == LITTLE_ENDIAN
  for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) {
    REVERSE32(pctx->g[k], pctx->g[k]);
  }
#endif
  sha256_Transform(pctx->odig, pctx->g, pctx->g);
  memcpy(pctx->f, pctx->g, SHA256_DIGEST_LENGTH);
  pctx->first = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, %r13d
movq %rcx, %r12
movq %rdi, %rbx
bswapl %r9d
leaq -0x2c(%rbp), %rax
movl %r9d, (%rax)
leaq 0x20(%rdi), %rcx
movq %rsi, %rdi
movl %edx, %esi
movq %rbx, %rdx
callq 0x9a24
leaq 0x60(%rbx), %r14
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x81bc
movl $0x80000000, 0x80(%rbx) # imm = 0x80000000
movl $0x300, 0x9c(%rbx)      # imm = 0x300
movups 0x20(%rbx), %xmm0
movups 0x30(%rbx), %xmm1
leaq -0xa0(%rbp), %r15
movaps %xmm1, 0x10(%r15)
movaps %xmm0, (%r15)
movq $0x200, 0x20(%r15)      # imm = 0x200
movslq %r13d, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x8f61
pushq $0x4
popq %rdx
movq %r15, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x8f61
movq %r15, %rdi
movq %r14, %rsi
callq 0x908e
pushq $0x18
popq %rax
cmpq $0x20, %rax
je 0x827e
movl (%rbx,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x826b
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x8d31
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movb $0x1, 0xa0(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha256_Update
void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx,
                               uint32_t iterations) {
  for (uint32_t i = pctx->first; i < iterations; i++) {
    sha256_Transform(pctx->idig, pctx->g, pctx->g);
    sha256_Transform(pctx->odig, pctx->g, pctx->g);
    for (uint32_t j = 0; j < SHA256_DIGEST_LENGTH / sizeof(uint32_t); j++) {
      pctx->f[j] ^= pctx->g[j];
    }
  }
  pctx->first = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movsbl 0xa0(%rdi), %r13d
leaq 0x20(%rdi), %r15
leaq 0x60(%rdi), %r12
cmpl %r14d, %r13d
jae 0x8314
movq %r15, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x8d31
movq %rbx, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x8d31
pushq $-0x20
popq %rax
testq %rax, %rax
je 0x830f
movl 0x20(%r12,%rax), %ecx
xorl %ecx, (%r12,%rax)
addq $0x4, %rax
jmp 0x82fb
incl %r13d
jmp 0x82d7
movb $0x0, 0xa0(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha256_Final
void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key) {
#if BYTE_ORDER == LITTLE_ENDIAN
  for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) {
    REVERSE32(pctx->f[k], pctx->f[k]);
  }
#endif
  memcpy(key, pctx->f, SHA256_DIGEST_LENGTH);
  memzero(pctx, sizeof(PBKDF2_HMAC_SHA256_CTX));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x40(%rdi), %rax
movabsq $0x10, %rcx
cmpq $0x18, %rcx
je 0x834f
movl (%rdi,%rcx,4), %edx
bswapl %edx
movl %edx, (%rdi,%rcx,4)
incq %rcx
jmp 0x833c
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movl $0xa4, %esi
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha256
void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt,
                        int saltlen, uint32_t iterations, uint8_t *key,
                        int keylen) {
  uint32_t last_block_size = keylen % SHA256_DIGEST_LENGTH;
  uint32_t blocks_count = keylen / SHA256_DIGEST_LENGTH;
  if (last_block_size) {
    blocks_count++;
  } else {
    last_block_size = SHA256_DIGEST_LENGTH;
  }
  for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) {
    PBKDF2_HMAC_SHA256_CTX pctx;
    pbkdf2_hmac_sha256_Init(&pctx, pass, passlen, salt, saltlen, blocknr);
    pbkdf2_hmac_sha256_Update(&pctx, iterations);
    uint8_t digest[SHA256_DIGEST_LENGTH];
    pbkdf2_hmac_sha256_Final(&pctx, digest);
    uint32_t key_offset = (blocknr - 1) * SHA256_DIGEST_LENGTH;
    if (blocknr < blocks_count) {
      memcpy(key + key_offset, digest, SHA256_DIGEST_LENGTH);
    } else {
      memcpy(key + key_offset, digest, last_block_size);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r9, -0x58(%rbp)
movl %r8d, -0x34(%rbp)
movl %ecx, -0x30(%rbp)
movq %rdx, -0x50(%rbp)
movl %esi, -0x2c(%rbp)
movq %rdi, -0x48(%rbp)
movl 0x10(%rbp), %esi
pushq $0x20
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
movl %eax, %edx
shll $0x5, %edx
xorl %r12d, %r12d
subl %edx, %esi
setne %r12b
cmovel %ecx, %esi
movq %rsi, -0x40(%rbp)
addl %eax, %r12d
pushq $0x1
popq %r14
xorl %r13d, %r13d
leaq -0x124(%rbp), %r15
leaq -0x80(%rbp), %rbx
cmpl %r12d, %r14d
ja 0x842e
movq %r15, %rdi
movq -0x48(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq -0x50(%rbp), %rcx
movl -0x30(%rbp), %r8d
movl %r14d, %r9d
callq 0x81c8
movq %r15, %rdi
movl -0x34(%rbp), %esi
callq 0x82b3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x832a
movl %r13d, %edi
addq -0x58(%rbp), %rdi
cmpl %r12d, %r14d
jae 0x8419
movaps -0x80(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
jmp 0x8425
movq %rbx, %rsi
movq -0x40(%rbp), %rdx
callq 0x8080
incl %r14d
addl $0x20, %r13d
jmp 0x83c3
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha512_Init
void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass,
                             int passlen, const uint8_t *salt, int saltlen,
                             uint32_t blocknr) {
  SHA512_CTX ctx;
#if BYTE_ORDER == LITTLE_ENDIAN
  REVERSE32(blocknr, blocknr);
#endif

  hmac_sha512_prepare(pass, passlen, pctx->odig, pctx->idig);
  memzero(pctx->g, sizeof(pctx->g));
  pctx->g[8] = 0x8000000000000000;
  pctx->g[15] = (SHA512_BLOCK_LENGTH + SHA512_DIGEST_LENGTH) * 8;

  memcpy(ctx.state, pctx->idig, sizeof(pctx->idig));
  ctx.bitcount[0] = SHA512_BLOCK_LENGTH * 8;
  ctx.bitcount[1] = 0;
  sha512_Update(&ctx, salt, saltlen);
  sha512_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr));
  sha512_Final(&ctx, (uint8_t *)pctx->g);
#if BYTE_ORDER == LITTLE_ENDIAN
  for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) {
    REVERSE64(pctx->g[k], pctx->g[k]);
  }
#endif
  sha512_Transform(pctx->odig, pctx->g, pctx->g);
  memcpy(pctx->f, pctx->g, SHA512_DIGEST_LENGTH);
  pctx->first = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r8d, %r13d
movq %rcx, %r12
movq %rdi, %rbx
bswapl %r9d
leaq -0x2c(%rbp), %rax
movl %r9d, (%rax)
leaq 0x40(%rdi), %rcx
movq %rsi, %rdi
movl %edx, %esi
movq %rbx, %rdx
callq 0x9c94
leaq 0xc0(%rbx), %r14
movl $0x80, %esi
movq %r14, %rdi
callq 0x81bc
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, 0x100(%rbx)
movq $0x600, 0x138(%rbx) # imm = 0x600
movups 0x40(%rbx), %xmm0
movups 0x50(%rbx), %xmm1
movups 0x60(%rbx), %xmm2
movups 0x70(%rbx), %xmm3
leaq -0x100(%rbp), %r15
movaps %xmm3, 0x30(%r15)
movaps %xmm2, 0x20(%r15)
movaps %xmm1, 0x10(%r15)
movaps %xmm0, (%r15)
movq $0x400, 0x40(%r15)      # imm = 0x400
andq $0x0, 0x48(%r15)
movslq %r13d, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x9537
pushq $0x4
popq %rdx
movq %r15, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x9537
movq %r15, %rdi
movq %r14, %rsi
callq 0x969b
pushq $0x18
popq %rax
cmpq $0x20, %rax
je 0x8520
movq (%rbx,%rax,8), %rcx
bswapq %rcx
movq %rcx, (%rbx,%rax,8)
incq %rax
jmp 0x850a
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x92ce
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movups %xmm3, 0xb0(%rbx)
movups %xmm2, 0xa0(%rbx)
movups %xmm1, 0x90(%rbx)
movups %xmm0, 0x80(%rbx)
movb $0x1, 0x140(%rbx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha512_Update
void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx,
                               uint32_t iterations) {
  for (uint32_t i = pctx->first; i < iterations; i++) {
    sha512_Transform(pctx->idig, pctx->g, pctx->g);
    sha512_Transform(pctx->odig, pctx->g, pctx->g);
    for (uint32_t j = 0; j < SHA512_DIGEST_LENGTH / sizeof(uint64_t); j++) {
      pctx->f[j] ^= pctx->g[j];
    }
  }
  pctx->first = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movsbl 0x140(%rdi), %r13d
leaq 0x40(%rdi), %r15
leaq 0xc0(%rdi), %r12
cmpl %r14d, %r13d
jae 0x85da
movq %r15, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x92ce
movq %rbx, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x92ce
pushq $-0x40
popq %rax
testq %rax, %rax
je 0x85d5
movq 0x40(%r12,%rax), %rcx
xorq %rcx, (%r12,%rax)
addq $0x8, %rax
jmp 0x85c1
incl %r13d
jmp 0x859d
movb $0x0, 0x140(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha512_Final
void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key) {
#if BYTE_ORDER == LITTLE_ENDIAN
  for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) {
    REVERSE64(pctx->f[k], pctx->f[k]);
  }
#endif
  memcpy(key, pctx->f, SHA512_DIGEST_LENGTH);
  memzero(pctx, sizeof(PBKDF2_HMAC_SHA512_CTX));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x80(%rdi), %rax
movabsq $0x10, %rcx
cmpq $0x18, %rcx
je 0x861b
movq (%rdi,%rcx,8), %rdx
bswapq %rdx
movq %rdx, (%rdi,%rcx,8)
incq %rcx
jmp 0x8605
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movups %xmm3, 0x30(%rsi)
movups %xmm2, 0x20(%rsi)
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movl $0x148, %esi            # imm = 0x148
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/pbkdf2.c
// Function: pbkdf2_hmac_sha512
void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt,
                        int saltlen, uint32_t iterations, uint8_t *key,
                        int keylen) {
  uint32_t last_block_size = keylen % SHA512_DIGEST_LENGTH;
  uint32_t blocks_count = keylen / SHA512_DIGEST_LENGTH;
  if (last_block_size) {
    blocks_count++;
  } else {
    last_block_size = SHA512_DIGEST_LENGTH;
  }
  for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) {
    PBKDF2_HMAC_SHA512_CTX pctx;
    pbkdf2_hmac_sha512_Init(&pctx, pass, passlen, salt, saltlen, blocknr);
    pbkdf2_hmac_sha512_Update(&pctx, iterations);
    uint8_t digest[SHA512_DIGEST_LENGTH];
    pbkdf2_hmac_sha512_Final(&pctx, digest);
    uint32_t key_offset = (blocknr - 1) * SHA512_DIGEST_LENGTH;
    if (blocknr < blocks_count) {
      memcpy(key + key_offset, digest, SHA512_DIGEST_LENGTH);
    } else {
      memcpy(key + key_offset, digest, last_block_size);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %r9, -0x58(%rbp)
movl %r8d, -0x34(%rbp)
movl %ecx, -0x30(%rbp)
movq %rdx, -0x50(%rbp)
movl %esi, -0x2c(%rbp)
movq %rdi, -0x48(%rbp)
movl 0x10(%rbp), %esi
pushq $0x40
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
movl %eax, %edx
shll $0x6, %edx
xorl %r12d, %r12d
subl %edx, %esi
setne %r12b
cmovel %ecx, %esi
movq %rsi, -0x40(%rbp)
addl %eax, %r12d
pushq $0x1
popq %r14
xorl %r13d, %r13d
leaq -0x1e8(%rbp), %r15
leaq -0xa0(%rbp), %rbx
cmpl %r12d, %r14d
ja 0x8726
movq %r15, %rdi
movq -0x48(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq -0x50(%rbp), %rcx
movl -0x30(%rbp), %r8d
movl %r14d, %r9d
callq 0x8440
movq %r15, %rdi
movl -0x34(%rbp), %esi
callq 0x8576
movq %r15, %rdi
movq %rbx, %rsi
callq 0x85f0
movl %r13d, %edi
addq -0x58(%rbp), %rdi
cmpl %r12d, %r14d
jae 0x870e
movaps -0xa0(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
movaps -0x80(%rbp), %xmm2
movaps -0x70(%rbp), %xmm3
movups %xmm3, 0x30(%rdi)
movups %xmm2, 0x20(%rdi)
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
jmp 0x871a
movq %rbx, %rsi
movq -0x40(%rbp), %rdx
callq 0x8080
incl %r14d
addl $0x40, %r13d
jmp 0x869f
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha1_Final
void sha1_Final(SHA1_CTX* context, sha2_byte digest[]) {
	unsigned int	usedspace;

	/* If no digest buffer is passed, we don't bother doing this: */
	if (digest != (sha2_byte*)0) {
		usedspace = (context->bitcount >> 3) % SHA1_BLOCK_LENGTH;
		/* Begin padding with a 1 bit: */
		((uint8_t*)context->buffer)[usedspace++] = 0x80;

		if (usedspace > SHA1_SHORT_BLOCK_LENGTH) {
			memzero(((uint8_t*)context->buffer) + usedspace, SHA1_BLOCK_LENGTH - usedspace);

#if BYTE_ORDER == LITTLE_ENDIAN
			/* Convert TO host byte order */
			for (int j = 0; j < 16; j++) {
				REVERSE32(context->buffer[j],context->buffer[j]);
			}
#endif
			/* Do second-to-last transform: */
			sha1_Transform(context->state, context->buffer, context->state);

			/* And prepare the last transform: */
			usedspace = 0;
		}
		/* Set-up for the last transform: */
		memzero(((uint8_t*)context->buffer) + usedspace, SHA1_SHORT_BLOCK_LENGTH - usedspace);

#if BYTE_ORDER == LITTLE_ENDIAN
		/* Convert TO host byte order */
		for (int j = 0; j < 14; j++) {
			REVERSE32(context->buffer[j],context->buffer[j]);
		}
#endif
		/* Set the bit count: */
		context->buffer[14] = context->bitcount >> 32;
		context->buffer[15] = context->bitcount & 0xffffffff;

		/* Final transform: */
		sha1_Transform(context->state, context->buffer, context->state);

#if BYTE_ORDER == LITTLE_ENDIAN
		/* Convert FROM host byte order */
		for (int j = 0; j < 5; j++) {
			REVERSE32(context->state[j],context->state[j]);
		}
#endif
		MEMCPY_BCOPY(digest, context->state, SHA1_DIGEST_LENGTH);
	}

	/* Clean up state data: */
	memzero(context, sizeof(SHA1_CTX));
	usedspace = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x8bdf
movq %rsi, %r14
movl 0x18(%rbx), %esi
shrl $0x3, %esi
andl $0x3f, %esi
leaq 0x20(%rbx), %r15
leal 0x1(%rsi), %eax
movb $-0x80, 0x20(%rbx,%rsi)
cmpl $0x38, %esi
jb 0x8b7a
movl %eax, %edi
addq %r15, %rdi
xorl $0x3f, %esi
callq 0x81bc
pushq $0x8
popq %rax
cmpq $0x18, %rax
je 0x8b6a
movl (%rbx,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x8b57
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x876a
xorl %eax, %eax
pushq $0x8
popq %r12
movl %eax, %edi
addq %r15, %rdi
pushq $0x38
popq %rsi
subl %eax, %esi
callq 0x81bc
cmpq $0x16, %r12
je 0x8ba2
movl (%rbx,%r12,4), %eax
bswapl %eax
movl %eax, (%rbx,%r12,4)
incq %r12
jmp 0x8b8d
movq 0x18(%rbx), %rax
rorq $0x20, %rax
movq %rax, 0x58(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x876a
xorl %eax, %eax
cmpq $0x5, %rax
je 0x8bd1
movl (%rbx,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x8bbe
movl 0x10(%rbx), %eax
movl %eax, 0x10(%r14)
movups (%rbx), %xmm0
movups %xmm0, (%r14)
pushq $0x60
popq %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha1_End
char *sha1_End(SHA1_CTX* context, char buffer[]) {
	sha2_byte	digest[SHA1_DIGEST_LENGTH], *d = digest;
	int		i;

	if (buffer != (char*)0) {
		sha1_Final(context, digest);

		for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
			*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
			*buffer++ = sha2_hex_digits[*d & 0x0f];
			d++;
		}
		*buffer = (char)0;
	} else {
		memzero(context, sizeof(SHA1_CTX));
	}
	memzero(digest, SHA1_DIGEST_LENGTH);
	return buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x8c42
movq %rsi, %rbx
leaq -0x20(%rbp), %rsi
callq 0x8b13
xorl %eax, %eax
leaq 0x37fb(%rip), %rcx      # 0xc410
cmpl $0x14, %eax
je 0x8c3d
movzbl -0x20(%rbp,%rax), %edx
movl %edx, %esi
shrl $0x4, %esi
movb (%rsi,%rcx), %sil
movb %sil, (%rbx)
andl $0xf, %edx
movb (%rdx,%rcx), %dl
movb %dl, 0x1(%rbx)
addq $0x2, %rbx
incq %rax
jmp 0x8c15
movb $0x0, (%rbx)
jmp 0x8c4c
pushq $0x60
popq %rsi
callq 0x81bc
xorl %ebx, %ebx
leaq -0x20(%rbp), %rdi
pushq $0x14
popq %rsi
callq 0x81bc
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha1_Raw
void sha1_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA1_DIGEST_LENGTH]) {
	SHA1_CTX	context;
	sha1_Init(&context);
	sha1_Update(&context, data, len);
	sha1_Final(&context, digest);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x80(%rbp), %r12
movq %r12, %rdi
callq 0x8738
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x89e6
movq %r12, %rdi
movq %rbx, %rsi
callq 0x8b13
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha1_Data
char* sha1_Data(const sha2_byte* data, size_t len, char digest[SHA1_DIGEST_STRING_LENGTH]) {
	SHA1_CTX	context;

	sha1_Init(&context);
	sha1_Update(&context, data, len);
	return sha1_End(&context, digest);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x80(%rbp), %r12
movq %r12, %rdi
callq 0x8738
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x89e6
movq %r12, %rdi
movq %rbx, %rsi
callq 0x8bf2
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha256_Init
void sha256_Init(SHA256_CTX* context) {
	if (context == (SHA256_CTX*)0) {
		return;
	}
	MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
	memzero(context->buffer, SHA256_BLOCK_LENGTH);
	context->bitcount = 0;
}

// Assembly:
testq %rdi, %rdi
je 0x8d30
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movaps 0x3335(%rip), %xmm0     # 0xc040
movups %xmm0, 0x10(%rdi)
movaps 0x331a(%rip), %xmm0     # 0xc030
movups %xmm0, (%rdi)
addq $0x28, %rdi
pushq $0x40
popq %rsi
callq 0x81bc
andq $0x0, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha256_Final
void sha256_Final(SHA256_CTX* context, sha2_byte digest[]) {
	unsigned int	usedspace;

	/* If no digest buffer is passed, we don't bother doing this: */
	if (digest != (sha2_byte*)0) {
		usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
		/* Begin padding with a 1 bit: */
		((uint8_t*)context->buffer)[usedspace++] = 0x80;
		
		if (usedspace > SHA256_SHORT_BLOCK_LENGTH) {
			memzero(((uint8_t*)context->buffer) + usedspace, SHA256_BLOCK_LENGTH - usedspace);

#if BYTE_ORDER == LITTLE_ENDIAN
			/* Convert TO host byte order */
			for (int j = 0; j < 16; j++) {
				REVERSE32(context->buffer[j],context->buffer[j]);
			}
#endif
			/* Do second-to-last transform: */
			sha256_Transform(context->state, context->buffer, context->state);
			
			/* And prepare the last transform: */
			usedspace = 0;
		}
		/* Set-up for the last transform: */
		memzero(((uint8_t*)context->buffer) + usedspace, SHA256_SHORT_BLOCK_LENGTH - usedspace);

#if BYTE_ORDER == LITTLE_ENDIAN
		/* Convert TO host byte order */
		for (int j = 0; j < 14; j++) {
			REVERSE32(context->buffer[j],context->buffer[j]);
		}
#endif
		/* Set the bit count: */
		context->buffer[14] = context->bitcount >> 32;
		context->buffer[15] = context->bitcount & 0xffffffff;

		/* Final transform: */
		sha256_Transform(context->state, context->buffer, context->state);

#if BYTE_ORDER == LITTLE_ENDIAN
		/* Convert FROM host byte order */
		for (int j = 0; j < 8; j++) {
			REVERSE32(context->state[j],context->state[j]);
		}
#endif
		MEMCPY_BCOPY(digest, context->state, SHA256_DIGEST_LENGTH);
	}

	/* Clean up state data: */
	memzero(context, sizeof(SHA256_CTX));
	usedspace = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x915c
movq %rsi, %r14
movl 0x20(%rbx), %esi
shrl $0x3, %esi
andl $0x3f, %esi
leaq 0x28(%rbx), %r15
leal 0x1(%rsi), %eax
movb $-0x80, 0x28(%rbx,%rsi)
cmpl $0x38, %esi
jb 0x90f5
movl %eax, %edi
addq %r15, %rdi
xorl $0x3f, %esi
callq 0x81bc
pushq $0xa
popq %rax
cmpq $0x1a, %rax
je 0x90e5
movl (%rbx,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x90d2
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x8d31
xorl %eax, %eax
pushq $0xa
popq %r12
movl %eax, %edi
addq %r15, %rdi
pushq $0x38
popq %rsi
subl %eax, %esi
callq 0x81bc
cmpq $0x18, %r12
je 0x911d
movl (%rbx,%r12,4), %eax
bswapl %eax
movl %eax, (%rbx,%r12,4)
incq %r12
jmp 0x9108
movq 0x20(%rbx), %rax
rorq $0x20, %rax
movq %rax, 0x60(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x8d31
xorl %eax, %eax
cmpq $0x8, %rax
je 0x914c
movl (%rbx,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x9139
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%r14)
movups %xmm0, (%r14)
pushq $0x68
popq %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha256_End
char *sha256_End(SHA256_CTX* context, char buffer[]) {
	sha2_byte	digest[SHA256_DIGEST_LENGTH], *d = digest;
	int		i;

	if (buffer != (char*)0) {
		sha256_Final(context, digest);

		for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
			*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
			*buffer++ = sha2_hex_digits[*d & 0x0f];
			d++;
		}
		*buffer = (char)0;
	} else {
		memzero(context, sizeof(SHA256_CTX));
	}
	memzero(digest, SHA256_DIGEST_LENGTH);
	return buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
testq %rsi, %rsi
je 0x91bf
movq %rsi, %rbx
leaq -0x30(%rbp), %rsi
callq 0x908e
xorl %eax, %eax
leaq 0x327e(%rip), %rcx      # 0xc410
cmpl $0x20, %eax
je 0x91ba
movzbl -0x30(%rbp,%rax), %edx
movl %edx, %esi
shrl $0x4, %esi
movb (%rsi,%rcx), %sil
movb %sil, (%rbx)
andl $0xf, %edx
movb (%rdx,%rcx), %dl
movb %dl, 0x1(%rbx)
addq $0x2, %rbx
incq %rax
jmp 0x9192
movb $0x0, (%rbx)
jmp 0x91c9
pushq $0x68
popq %rsi
callq 0x81bc
xorl %ebx, %ebx
leaq -0x30(%rbp), %rdi
pushq $0x20
popq %rsi
callq 0x81bc
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha256_Raw
void sha256_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA256_DIGEST_LENGTH]) {
	SHA256_CTX	context;
	sha256_Init(&context);
	sha256_Update(&context, data, len);
	sha256_Final(&context, digest);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x88(%rbp), %r12
movq %r12, %rdi
callq 0x8cf6
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x8f61
movq %r12, %rdi
movq %rbx, %rsi
callq 0x908e
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_Init
void sha512_Init(SHA512_CTX* context) {
	if (context == (SHA512_CTX*)0) {
		return;
	}
	MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
	memzero(context->buffer, SHA512_BLOCK_LENGTH);
	context->bitcount[0] = context->bitcount[1] =  0;
}

// Assembly:
testq %rdi, %rdi
je 0x92cd
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movaps 0x2df2(%rip), %xmm0     # 0xc080
movups %xmm0, 0x30(%rdi)
movaps 0x2dd7(%rip), %xmm0     # 0xc070
movups %xmm0, 0x20(%rdi)
movaps 0x2dbc(%rip), %xmm0     # 0xc060
movups %xmm0, 0x10(%rdi)
movaps 0x2da1(%rip), %xmm0     # 0xc050
movups %xmm0, (%rdi)
addq $0x50, %rdi
movl $0x80, %esi
callq 0x81bc
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_Final
void sha512_Final(SHA512_CTX* context, sha2_byte digest[]) {
	/* If no digest buffer is passed, we don't bother doing this: */
	if (digest != (sha2_byte*)0) {
		sha512_Last(context);

		/* Save the hash data for output: */
#if BYTE_ORDER == LITTLE_ENDIAN
		/* Convert FROM host byte order */
		for (int j = 0; j < 8; j++) {
			REVERSE64(context->state[j],context->state[j]);
		}
#endif
		MEMCPY_BCOPY(digest, context->state, SHA512_DIGEST_LENGTH);
	}

	/* Zero out state data */
	memzero(context, sizeof(SHA512_CTX));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x978c
movq %rsi, %r14
movl 0x40(%rbx), %esi
shrl $0x3, %esi
andl $0x7f, %esi
leaq 0x50(%rbx), %r15
leal 0x1(%rsi), %eax
movb $-0x80, 0x50(%rbx,%rsi)
cmpl $0x70, %esi
jb 0x9705
movl %eax, %edi
addq %r15, %rdi
xorl $0x7f, %esi
callq 0x81bc
pushq $0xa
popq %rax
cmpq $0x1a, %rax
je 0x96f5
movq (%rbx,%rax,8), %rcx
bswapq %rcx
movq %rcx, (%rbx,%rax,8)
incq %rax
jmp 0x96df
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x92ce
xorl %eax, %eax
pushq $0xa
popq %r12
movl %eax, %edi
addq %r15, %rdi
pushq $0x70
popq %rsi
subl %eax, %esi
callq 0x81bc
cmpq $0x18, %r12
je 0x972e
movq (%rbx,%r12,8), %rax
bswapq %rax
movq %rax, (%rbx,%r12,8)
incq %r12
jmp 0x9718
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rcx
movq %rcx, 0xc0(%rbx)
movq %rax, 0xc8(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x92ce
xorl %eax, %eax
cmpq $0x8, %rax
je 0x976a
movq (%rbx,%rax,8), %rcx
bswapq %rcx
movq %rcx, (%rbx,%rax,8)
incq %rax
jmp 0x9754
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups 0x30(%rbx), %xmm3
movups %xmm3, 0x30(%r14)
movups %xmm2, 0x20(%r14)
movups %xmm1, 0x10(%r14)
movups %xmm0, (%r14)
movl $0xd0, %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_End
char *sha512_End(SHA512_CTX* context, char buffer[]) {
	sha2_byte	digest[SHA512_DIGEST_LENGTH], *d = digest;
	int		i;

	if (buffer != (char*)0) {
		sha512_Final(context, digest);

		for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
			*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
			*buffer++ = sha2_hex_digits[*d & 0x0f];
			d++;
		}
		*buffer = (char)0;
	} else {
		memzero(context, sizeof(SHA512_CTX));
	}
	memzero(digest, SHA512_DIGEST_LENGTH);
	return buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x48, %rsp
testq %rsi, %rsi
je 0x97f1
movq %rsi, %rbx
leaq -0x50(%rbp), %rsi
callq 0x969b
xorl %eax, %eax
leaq 0x2c4c(%rip), %rcx      # 0xc410
cmpl $0x40, %eax
je 0x97ec
movzbl -0x50(%rbp,%rax), %edx
movl %edx, %esi
shrl $0x4, %esi
movb (%rsi,%rcx), %sil
movb %sil, (%rbx)
andl $0xf, %edx
movb (%rdx,%rcx), %dl
movb %dl, 0x1(%rbx)
addq $0x2, %rbx
incq %rax
jmp 0x97c4
movb $0x0, (%rbx)
jmp 0x97fd
movl $0xd0, %esi
callq 0x81bc
xorl %ebx, %ebx
leaq -0x50(%rbp), %rdi
pushq $0x40
popq %rsi
callq 0x81bc
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_Raw
void sha512_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA512_DIGEST_LENGTH]) {
	SHA512_CTX	context;
	sha512_Init(&context);
	sha512_Update(&context, data, len);
	sha512_Final(&context, digest);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
callq 0x9279
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9537
movq %r12, %rdi
movq %rbx, %rsi
callq 0x969b
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_Data
char* sha512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
	SHA512_CTX	context;

	sha512_Init(&context);
	sha512_Update(&context, data, len);
	return sha512_End(&context, digest);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
callq 0x9279
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9537
movq %r12, %rdi
movq %rbx, %rsi
callq 0x97a1
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/hmac.c
// Function: hmac_sha256_Init
void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key,
                      const uint32_t keylen) {
  static CONFIDENTIAL uint8_t i_key_pad[SHA256_BLOCK_LENGTH];
  memzero(i_key_pad, SHA256_BLOCK_LENGTH);
  if (keylen > SHA256_BLOCK_LENGTH) {
    sha256_Raw(key, keylen, i_key_pad);
  } else {
    memcpy(i_key_pad, key, keylen);
  }
  for (int i = 0; i < SHA256_BLOCK_LENGTH; i++) {
    hctx->o_key_pad[i] = i_key_pad[i] ^ 0x5c;
    i_key_pad[i] ^= 0x36;
  }
  sha256_Init(&(hctx->ctx));
  sha256_Update(&(hctx->ctx), i_key_pad, SHA256_BLOCK_LENGTH);
  memzero(i_key_pad, sizeof(i_key_pad));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xf229(%rip), %r14      # 0x18b00
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x81bc
movl %r12d, %edx
cmpl $0x41, %r12d
jb 0x9902
leaq 0xf20e(%rip), %rax      # 0x18b00
movq %r15, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x91df
jmp 0x9911
leaq 0xf1f7(%rip), %rdi      # 0x18b00
movq %r15, %rsi
callq 0x8080
xorl %eax, %eax
cmpq $0x40, %rax
je 0x992d
movb (%rax,%r14), %cl
xorb $0x5c, %cl
movb %cl, (%rbx,%rax)
xorb $0x36, (%rax,%r14)
incq %rax
jmp 0x9913
addq $0x40, %rbx
movq %rbx, %rdi
callq 0x8cf6
leaq 0xf1c0(%rip), %r14      # 0x18b00
pushq $0x40
popq %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x8f61
movq %r14, %rdi
movq %r15, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/hmac.c
// Function: hmac_sha256_Final
void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac) {
  sha256_Final(&(hctx->ctx), hmac);
  sha256_Init(&(hctx->ctx));
  sha256_Update(&(hctx->ctx), hctx->o_key_pad, SHA256_BLOCK_LENGTH);
  sha256_Update(&(hctx->ctx), hmac, SHA256_DIGEST_LENGTH);
  sha256_Final(&(hctx->ctx), hmac);
  memzero(hctx, sizeof(HMAC_SHA256_CTX));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x40(%rdi), %r15
movq %r15, %rdi
callq 0x908e
movq %r15, %rdi
callq 0x8cf6
pushq $0x40
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8f61
pushq $0x20
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x8f61
movq %r15, %rdi
movq %r14, %rsi
callq 0x908e
movl $0xa8, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x81bc
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/hmac.c
// Function: hmac_sha256
void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg,
                 const uint32_t msglen, uint8_t *hmac) {
  static CONFIDENTIAL HMAC_SHA256_CTX hctx;
  hmac_sha256_Init(&hctx, key, keylen);
  hmac_sha256_Update(&hctx, msg, msglen);
  hmac_sha256_Final(&hctx, hmac);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movl %ecx, %r14d
movq %rdx, %r15
movl %esi, %edx
movq %rdi, %rsi
leaq 0xf149(%rip), %r12      # 0x18b40
movq %r12, %rdi
callq 0x98bc
movl %r14d, %edx
leaq 0xf177(%rip), %rdi      # 0x18b80
movq %r15, %rsi
callq 0x8f61
movq %r12, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9975
// File: /workspace/github_c_makefile_star2_O2/Seclabs-htc[P]slip39/trezor-crypto/hmac.c
// Function: hmac_sha256_prepare
void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen,
                         uint32_t *opad_digest, uint32_t *ipad_digest) {
  static CONFIDENTIAL uint32_t key_pad[SHA256_BLOCK_LENGTH / sizeof(uint32_t)];

  memzero(key_pad, sizeof(key_pad));
  if (keylen > SHA256_BLOCK_LENGTH) {
    static CONFIDENTIAL SHA256_CTX context;
    sha256_Init(&context);
    sha256_Update(&context, key, keylen);
    sha256_Final(&context, (uint8_t *)key_pad);
  } else {
    memcpy(key_pad, key, keylen);
  }

  /* compute o_key_pad and its digest */
  for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) {
    uint32_t data;
#if BYTE_ORDER == LITTLE_ENDIAN
    REVERSE32(key_pad[i], data);
#else
    data = key_pad[i];
#endif
    key_pad[i] = data ^ 0x5c5c5c5c;
  }
  sha256_Transform(sha256_initial_hash_value, key_pad, opad_digest);

  /* convert o_key_pad to i_key_pad and compute its digest */
  for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) {
    key_pad[i] = key_pad[i] ^ 0x5c5c5c5c ^ 0x36363636;
  }
  sha256_Transform(sha256_initial_hash_value, key_pad, ipad_digest);
  memzero(key_pad, sizeof(key_pad));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, -0x30(%rbp)
movq %rdx, %r15
movl %esi, %r13d
movq %rdi, %r12
leaq 0xf1aa(%rip), %r14      # 0x18bf0
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x81bc
cmpl $0x41, %r13d
jb 0x9a85
leaq 0xf1d2(%rip), %rbx      # 0x18c30
movq %rbx, %rdi
callq 0x8cf6
movl %r13d, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8f61
leaq 0xf175(%rip), %rsi      # 0x18bf0
movq %rbx, %rdi
callq 0x908e
jmp 0x9a97
movl %r13d, %edx
leaq 0xf161(%rip), %rdi      # 0x18bf0
movq %r12, %rsi
callq 0x8080
xorl %eax, %eax
movl $0x5c5c5c5c, %ecx       # imm = 0x5C5C5C5C
cmpq $0x40, %rax
je 0x9ab6
movl (%rax,%r14), %edx
xorl %ecx, %edx
bswapl %edx
movl %edx, (%rax,%r14)
addq $0x4, %rax
jmp 0x9a9e
leaq 0x2573(%rip), %rdi      # 0xc030
movq %r14, %rsi
movq %r15, %rdx
callq 0x8d31
xorl %eax, %eax
cmpq $0x40, %rax
je 0x9ade
xorl $0x6a6a6a6a, (%rax,%r14) # imm = 0x6A6A6A6A
addq $0x4, %rax
jmp 0x9aca
leaq 0x254b(%rip), %rdi      # 0xc030
leaq 0xf104(%rip), %rbx      # 0x18bf0
movq %rbx, %rsi
movq -0x30(%rbp), %rdx
callq 0x8d31
pushq $0x40
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81bc