LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/ThomasMadappattu[P]Sandmacs/word.c
// Function: capword
int capword (int f, int n)
{
  int c;

  if (n < 0)
    return (FALSE);
  while (n--)
    {
      while (inword () == FALSE)
	{
	  if (forwchar (FALSE, 1) == FALSE)
	    return (FALSE);
	}
      if (inword () != FALSE)
	{
	  c = lgetc (curwp->w_dotp, curwp->w_doto);
	  if (c >= 'a' && c <= 'z')
	    {
	      c -= 'a' - 'A';
	      lputc (curwp->w_dotp, curwp->w_doto, c);
	      lchange (WFHARD);
	    }
	  if (forwchar (FALSE, 1) == FALSE)
	    return (FALSE);
	  while (inword () != FALSE)
	    {
	      c = lgetc (curwp->w_dotp, curwp->w_doto);
	      if (c >= 'A' && c <= 'Z')
		{
		  c += 'a' - 'A';
		  lputc (curwp->w_dotp, curwp->w_doto, c);
		  lchange (WFHARD);
		}
	      if (forwchar (FALSE, 1) == FALSE)
		return (FALSE);
	    }
	}
    }
  return (TRUE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0xbaf0
movl $0x0, -0x4(%rbp)
jmp 0xbc73
jmp 0xbaf2
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0xbc6c
jmp 0xbb08
callq 0xbe70
cmpl $0x0, %eax
jne 0xbb31
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbb2f
movl $0x0, -0x4(%rbp)
jmp 0xbc73
jmp 0xbb08
callq 0xbe70
cmpl $0x0, %eax
je 0xbc67
leaq 0x5d32(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x5d24(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movsbl 0x18(%rax,%rcx), %eax
andl $0xff, %eax
movl %eax, -0x10(%rbp)
cmpl $0x61, -0x10(%rbp)
jl 0xbbac
cmpl $0x7a, -0x10(%rbp)
jg 0xbbac
movl -0x10(%rbp), %eax
subl $0x20, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movb %al, %dl
leaq 0x5cef(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x5ce1(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movb %dl, 0x18(%rax,%rcx)
movl $0x8, %edi
callq 0x70b0
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbbc9
movl $0x0, -0x4(%rbp)
jmp 0xbc73
jmp 0xbbcb
callq 0xbe70
cmpl $0x0, %eax
je 0xbc65
leaq 0x5c98(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x5c8a(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movsbl 0x18(%rax,%rcx), %eax
andl $0xff, %eax
movl %eax, -0x10(%rbp)
cmpl $0x41, -0x10(%rbp)
jl 0xbc46
cmpl $0x5a, -0x10(%rbp)
jg 0xbc46
movl -0x10(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movb %al, %dl
leaq 0x5c55(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x5c47(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movb %dl, 0x18(%rax,%rcx)
movl $0x8, %edi
callq 0x70b0
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbc60
movl $0x0, -0x4(%rbp)
jmp 0xbc73
jmp 0xbbcb
jmp 0xbc67
jmp 0xbaf2
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/ThomasMadappattu[P]Sandmacs/word.c
// Function: delfword
int delfword (int f, int n)
{
  LINE *dotp;
  int size, doto;

  if (n < 0)
    return (FALSE);
  dotp = curwp->w_dotp;
  doto = curwp->w_doto;
  size = 0;
  while (n--)
    {
      while (inword () != FALSE)
	{
	  if (forwchar (FALSE, 1) == FALSE)
	    return (FALSE);
	  ++size;
	}
      while (inword () == FALSE)
	{
	  if (forwchar (FALSE, 1) == FALSE)
	    return (FALSE);
	  ++size;
	}
    }
  curwp->w_dotp = dotp;
  curwp->w_doto = doto;
  return (ldelete (size, TRUE));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0xbca0
movl $0x0, -0x4(%rbp)
jmp 0xbd72
leaq 0x5bd1(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
leaq 0x5bbf(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x20(%rax), %rax
movl %eax, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0xbd3e
jmp 0xbcdc
callq 0xbe70
cmpl $0x0, %eax
je 0xbd0b
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbd00
movl $0x0, -0x4(%rbp)
jmp 0xbd72
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbcdc
jmp 0xbd0d
callq 0xbe70
cmpl $0x0, %eax
jne 0xbd3c
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbd31
movl $0x0, -0x4(%rbp)
jmp 0xbd72
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbd0d
jmp 0xbcca
movq -0x18(%rbp), %rcx
leaq 0x5b2f(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x18(%rax)
movslq -0x20(%rbp), %rcx
leaq 0x5b1d(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x20(%rax)
movl -0x1c(%rbp), %edi
movl $0x1, %esi
callq 0x7750
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ThomasMadappattu[P]Sandmacs/word.c
// Function: delbword
int delbword (int f, int n)
{
  int size;

  if (n < 0)
    return (FALSE);
  if (backchar (FALSE, 1) == FALSE)
    return (FALSE);
  size = 0;
  while (n--)
    {
      while (inword () == FALSE)
	{
	  if (backchar (FALSE, 1) == FALSE)
	    return (FALSE);
	  ++size;
	}
      while (inword () != FALSE)
	{
	  if (backchar (FALSE, 1) == FALSE)
	    return (FALSE);
	  ++size;
	}
    }
  if (forwchar (FALSE, 1) == FALSE)
    return (FALSE);
  return (ldelete (size, TRUE));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0xbda0
movl $0x0, -0x4(%rbp)
jmp 0xbe62
xorl %edi, %edi
movl $0x1, %esi
callq 0x2400
cmpl $0x0, %eax
jne 0xbdbd
movl $0x0, -0x4(%rbp)
jmp 0xbe62
movl $0x0, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0xbe38
jmp 0xbdd6
callq 0xbe70
cmpl $0x0, %eax
jne 0xbe05
xorl %edi, %edi
movl $0x1, %esi
callq 0x2400
cmpl $0x0, %eax
jne 0xbdfa
movl $0x0, -0x4(%rbp)
jmp 0xbe62
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xbdd6
jmp 0xbe07
callq 0xbe70
cmpl $0x0, %eax
je 0xbe36
xorl %edi, %edi
movl $0x1, %esi
callq 0x2400
cmpl $0x0, %eax
jne 0xbe2b
movl $0x0, -0x4(%rbp)
jmp 0xbe62
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xbe07
jmp 0xbdc4
xorl %edi, %edi
movl $0x1, %esi
callq 0x24f0
cmpl $0x0, %eax
jne 0xbe52
movl $0x0, -0x4(%rbp)
jmp 0xbe62
movl -0x10(%rbp), %edi
movl $0x1, %esi
callq 0x7750
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ThomasMadappattu[P]Sandmacs/word.c
// Function: inword
int inword ()
{
  int c;

  if (curwp->w_doto == llength (curwp->w_dotp))
    return (FALSE);
  c = lgetc (curwp->w_dotp, curwp->w_doto);
  if (c >= 'a' && c <= 'z')
    return (TRUE);
  if (c >= 'A' && c <= 'Z')
    return (TRUE);
  if (c >= '0' && c <= '9')
    return (TRUE);
  if (c == '$' || c == '_')	/* For identifiers */
    return (TRUE);
  return (FALSE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x59fd(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x20(%rax), %rax
leaq 0x59ef(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
jne 0xbea5
movl $0x0, -0x4(%rbp)
jmp 0xbf29
leaq 0x59cc(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x59be(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movsbl 0x18(%rax,%rcx), %eax
andl $0xff, %eax
movl %eax, -0x8(%rbp)
cmpl $0x61, -0x8(%rbp)
jl 0xbee3
cmpl $0x7a, -0x8(%rbp)
jg 0xbee3
movl $0x1, -0x4(%rbp)
jmp 0xbf29
cmpl $0x41, -0x8(%rbp)
jl 0xbef8
cmpl $0x5a, -0x8(%rbp)
jg 0xbef8
movl $0x1, -0x4(%rbp)
jmp 0xbf29
cmpl $0x30, -0x8(%rbp)
jl 0xbf0d
cmpl $0x39, -0x8(%rbp)
jg 0xbf0d
movl $0x1, -0x4(%rbp)
jmp 0xbf29
cmpl $0x24, -0x8(%rbp)
je 0xbf19
cmpl $0x5f, -0x8(%rbp)
jne 0xbf22
movl $0x1, -0x4(%rbp)
jmp 0xbf29
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/rikuu[P]kermit/kermit-color.c
// Function: color_stats
static void color_stats(const km_multicolor_t *colors, const size_t n_reads)
{
	size_t uncolored=0, ones=0, twos=0, multis=0;
	for (size_t i = 0; i < n_reads; i++) {
		if (colors[i].n == 0) uncolored++;
		else if (colors[i].n == 1) ones++;
		else if (colors[i].n == 2) twos++;
		else multis++;
	}
	fprintf(stderr, "[M::%s] %zu ones, %zu twos, %zu multis, %zu uncolored\n", __func__, ones, twos, multis, uncolored);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xdd69
movq -0x8(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0xdd06
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xdd56
movq -0x8(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq $0x1, (%rax)
jne 0xdd26
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xdd54
movq -0x8(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq $0x2, (%rax)
jne 0xdd46
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xdd52
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xdd54
jmp 0xdd56
jmp 0xdd58
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xdcd8
movq 0x5288(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x18(%rbp), %rax
leaq 0x1d22(%rip), %rsi      # 0xfaac
leaq 0x1d52(%rip), %rdx      # 0xfae3
movq %rax, (%rsp)
movb $0x0, %al
callq 0x10f0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: Cipher
static void Cipher(state_t* state, uint8_t* RoundKey)
{
  uint8_t round = 0;

  // Add the First round key to the state before starting the rounds.
  AddRoundKey(0, state, RoundKey); 
  
  // There will be Nr rounds.
  // The first Nr-1 rounds are identical.
  // These Nr-1 rounds are executed in the loop below.
  for (round = 1; round < Nr; ++round)
  {
    SubBytes(state);
    ShiftRows(state);
    MixColumns(state);
    AddRoundKey(round, state, RoundKey);
  }
  
  // The last round is given below.
  // The MixColumns function is not here in the last round.
  SubBytes(state);
  ShiftRows(state);
  AddRoundKey(Nr, state, RoundKey);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %edi, %edi
callq 0x28c0
movb $0x1, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0xa, %eax
jge 0x2628
movq -0x8(%rbp), %rdi
callq 0x2950
movq -0x8(%rbp), %rdi
callq 0x29d0
movq -0x8(%rbp), %rdi
callq 0x2aa0
movb -0x11(%rbp), %al
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movzbl %al, %edi
callq 0x28c0
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x25e7
movq -0x8(%rbp), %rdi
callq 0x2950
movq -0x8(%rbp), %rdi
callq 0x29d0
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl $0xa, %edi
callq 0x28c0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: InvCipher
static void InvCipher(state_t* state,uint8_t* RoundKey)
{
  uint8_t round = 0;

  // Add the First round key to the state before starting the rounds.
  AddRoundKey(Nr, state, RoundKey); 

  // There will be Nr rounds.
  // The first Nr-1 rounds are identical.
  // These Nr-1 rounds are executed in the loop below.
  for (round = (Nr - 1); round > 0; --round)
  {
    InvShiftRows(state);
    InvSubBytes(state);
    AddRoundKey(round, state, RoundKey);
    InvMixColumns(state);
  }
  
  // The last round is given below.
  // The MixColumns function is not here in the last round.
  InvShiftRows(state);
  InvSubBytes(state);
  AddRoundKey(0, state, RoundKey);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl $0xa, %edi
callq 0x28c0
movb $0x9, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0x0, %eax
jle 0x26fb
movq -0x8(%rbp), %rdi
callq 0x2c60
movq -0x8(%rbp), %rdi
callq 0x2d30
movb -0x11(%rbp), %al
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movzbl %al, %edi
callq 0x28c0
movq -0x8(%rbp), %rdi
callq 0x2db0
movb -0x11(%rbp), %al
addb $-0x1, %al
movb %al, -0x11(%rbp)
jmp 0x26ba
movq -0x8(%rbp), %rdi
callq 0x2c60
movq -0x8(%rbp), %rdi
callq 0x2d30
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %edi, %edi
callq 0x28c0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: AES_CBC_encrypt_buffer
void AES_CBC_encrypt_buffer(struct AES_ctx *ctx,uint8_t* buf, uint32_t length)
{
  uintptr_t i;
  uint8_t *Iv = ctx->Iv;
  for (i = 0; i < length; i += AES_BLOCKLEN)
  {
    XorWithIv(buf, Iv);
    Cipher((state_t*)buf, ctx->RoundKey);
    Iv = buf;
    buf += AES_BLOCKLEN;
    //printf("Step %d - %d", i/16, i);
  }
  /* store Iv in ctx for next call */
  memcpy(ctx->Iv, Iv, AES_BLOCKLEN);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x27a1
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x27d0
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x25c0
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
jmp 0x2759
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0xb0(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0xb8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: AES_CBC_decrypt_buffer
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf,  uint32_t length)
{
  uintptr_t i;
  uint8_t storeNextIv[AES_BLOCKLEN];
  for (i = 0; i < length; i += AES_BLOCKLEN)
  {
    memcpy(storeNextIv, buf, AES_BLOCKLEN);
    InvCipher((state_t*)buf, ctx->RoundKey);
    XorWithIv(buf, ctx->Iv);
    memcpy(ctx->Iv, storeNextIv, AES_BLOCKLEN);
    buf += AES_BLOCKLEN;
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x28af
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x2690
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0xb0, %rsi
callq 0x27d0
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0xb0(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0xb8(%rax)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
jmp 0x283b
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: AddRoundKey
static void AddRoundKey(uint8_t round,state_t* state,uint8_t* RoundKey)
{
  uint8_t i,j;
  for (i = 0; i < 4; ++i)
  {
    for (j = 0; j < 4; ++j)
    {
      (*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j];
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %dil, %al
movb %al, -0x1(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x4, %eax
jge 0x2942
movb $0x0, -0x1a(%rbp)
movzbl -0x1a(%rbp), %eax
cmpl $0x4, %eax
jge 0x2936
movq -0x18(%rbp), %rax
movzbl -0x1(%rbp), %ecx
shll $0x2, %ecx
shll $0x2, %ecx
movzbl -0x19(%rbp), %edx
shll $0x2, %edx
addl %edx, %ecx
movzbl -0x1a(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
movq -0x10(%rbp), %rax
movzbl -0x19(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movzbl -0x1a(%rbp), %ecx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movb -0x1a(%rbp), %al
addb $0x1, %al
movb %al, -0x1a(%rbp)
jmp 0x28e3
jmp 0x2938
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
jmp 0x28d6
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/aes.c
// Function: InvSubBytes
static void InvSubBytes(state_t* state)
{
  uint8_t i, j;
  for (i = 0; i < 4; ++i)
  {
    for (j = 0; j < 4; ++j)
    {
      (*state)[j][i] = getSBoxInvert((*state)[j][i]);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movb $0x0, -0x9(%rbp)
movzbl -0x9(%rbp), %eax
cmpl $0x4, %eax
jge 0x2da1
movb $0x0, -0xa(%rbp)
movzbl -0xa(%rbp), %eax
cmpl $0x4, %eax
jge 0x2d95
movq -0x8(%rbp), %rax
movzbl -0xa(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movzbl -0x9(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x93ae(%rip), %rax      # 0xc120
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movzbl -0xa(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movzbl -0x9(%rbp), %ecx
movb %dl, (%rax,%rcx)
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x2d49
jmp 0x2d97
movb -0x9(%rbp), %al
addb $0x1, %al
movb %al, -0x9(%rbp)
jmp 0x2d3c
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/crypto.c
// Function: aes128_cbc_encrypt
int aes128_cbc_encrypt(void *key, void *plaintext, void *ciphertext, int length, void *iv) {
    struct AES_ctx ctx;

    unsigned char *temp = (unsigned char *)malloc(length);
    if(!temp) {
        return 1;
    }

    memcpy(temp, plaintext, length);

    AES_init_ctx_iv(&ctx, key, iv);
    AES_CBC_encrypt_buffer(&ctx, temp, length);

    memcpy(ciphertext, temp, length);
    free(temp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movslq -0x24(%rbp), %rdi
callq 0x2100
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
jne 0x39d1
movl $0x1, -0x4(%rbp)
jmp 0x3a36
movq -0xf8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20f0
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x2510
movq -0xf8(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0xf0(%rbp), %rdi
callq 0x2730
movq -0x20(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20f0
movq -0xf8(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/crypto.c
// Function: aes128_cbc_decrypt
int aes128_cbc_decrypt(void *key, void *ciphertext, void *plaintext, int length, void *iv) {
    struct AES_ctx ctx;

    unsigned char *temp = (unsigned char *)malloc(length);
    if(!temp) {
        return 1;
    }

    memcpy(temp, ciphertext, length);

    AES_init_ctx_iv(&ctx, key, iv);
    AES_CBC_decrypt_buffer(&ctx, temp, length);

    memcpy(plaintext, temp, length);
    free(temp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movslq -0x24(%rbp), %rdi
callq 0x2100
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
jne 0x3a91
movl $0x1, -0x4(%rbp)
jmp 0x3af6
movq -0xf8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20f0
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x2510
movq -0xf8(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0xf0(%rbp), %rdi
callq 0x2820
movq -0x20(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20f0
movq -0xf8(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: find_consolemap
struct consolemap_entry *find_consolemap(char *model) {
    int i, k;
    int good;
    char *m;

    for(i = 0; i < NUM_CONSOLES; i++) {
        m = g_consolemap[i].model;

        // loop and take wildcard into account
        good = 0;
        for(k = 0; k < MIN(strlen(m), strlen(model)); k++) {
            if(m[k] == '?' || m[k] == model[k]) {
                good = 1;
            } else {
                good = 0;
                break;
            }
        }

        if(good) {
            return &g_consolemap[i];
        }
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x6, %rax
jae 0x55b8
movslq -0x14(%rbp), %rcx
leaq 0xabf4(%rip), %rax      # 0x100c0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2070
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2070
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x5521
movq -0x28(%rbp), %rdi
callq 0x2070
movq %rax, -0x40(%rbp)
jmp 0x552e
movq -0x10(%rbp), %rdi
callq 0x2070
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jae 0x558a
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
je 0x5568
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x5571
movl $0x1, -0x1c(%rbp)
jmp 0x557a
movl $0x0, -0x1c(%rbp)
jmp 0x558a
jmp 0x557c
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x54e8
cmpl $0x0, -0x1c(%rbp)
je 0x55a8
movslq -0x14(%rbp), %rcx
leaq 0xab25(%rip), %rax      # 0x100c0
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x55c0
jmp 0x55aa
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x54b3
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: find_codename
struct codename_entry *find_codename(char *codename) {
    int i;

    for(i = 0; i < NUM_CODENAMES; i++) {
        if(!strcmp(g_codenames[i].codename, codename)) {
            return &g_codenames[i];
        }
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x14, %rax
jae 0x5635
movslq -0x14(%rbp), %rcx
leaq 0xab28(%rip), %rax      # 0x10120
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x20c0
cmpl $0x0, %eax
jne 0x5628
movslq -0x14(%rbp), %rcx
leaq 0xab05(%rip), %rax      # 0x10120
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x563d
jmp 0x562a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x55e3
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: hexdump
void hexdump(unsigned char *data, int length, int newlines) {
    int i, k;

    for(i = 0; i < length; i++) {
        printf("%02X ", data[i]);

        if(newlines) {
            if(i != 0 && (i + 1) % 16 == 0) {
                printf("\n");
            }
        }
    }

    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x56c7
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x6e2d(%rip), %rdi      # 0xc4b1
movb $0x0, %al
callq 0x2080
cmpl $0x0, -0x10(%rbp)
je 0x56ba
cmpl $0x0, -0x14(%rbp)
je 0x56b8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x56b8
leaq 0x7448(%rip), %rdi      # 0xcaf9
movb $0x0, %al
callq 0x2080
jmp 0x56ba
jmp 0x56bc
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5669
leaq 0x742b(%rip), %rdi      # 0xcaf9
movb $0x0, %al
callq 0x2080
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: dumpbin
int dumpbin(unsigned char *filename, unsigned char *data, int length) {
    FILE *fp;

    fp = fopen(filename, "wb");
    if(!fp) {
        return 1;
    }
    
    fwrite(data, 1, length, fp);
    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6db9(%rip), %rsi      # 0xc4b7
callq 0x2130
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5717
movl $0x1, -0x4(%rbp)
jmp 0x573d
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0x2140
movq -0x28(%rbp), %rdi
callq 0x2060
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: readbin
int readbin(unsigned char *filename, unsigned char **data, int *length) {
    FILE *fp;
    unsigned char *ptr;
    long size;

    fp = fopen(filename, "rb");
    if(!fp) {
        return 1;
    }

    fseek(fp, 0, SEEK_END);
    size = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    
    ptr = (unsigned char *)malloc(size);
    if(!ptr) {
        return 1;
    }

    memset(ptr, 0, size);
    fread(ptr, 1, size, fp);
    fclose(fp);

    if(data) {
        *data = ptr;
    } else {
        free(ptr);
    }

    if(length) {
        *length = size;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6d4b(%rip), %rsi      # 0xc4ba
callq 0x2130
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x578b
movl $0x1, -0x4(%rbp)
jmp 0x583b
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x2110
movq -0x28(%rbp), %rdi
callq 0x20e0
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2110
movq -0x38(%rbp), %rdi
callq 0x2100
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x57d6
movl $0x1, -0x4(%rbp)
jmp 0x583b
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
xorl %esi, %esi
callq 0x20a0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0x2050
movq -0x28(%rbp), %rdi
callq 0x2060
cmpq $0x0, -0x18(%rbp)
je 0x5818
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5821
movq -0x30(%rbp), %rdi
callq 0x2030
cmpq $0x0, -0x20(%rbp)
je 0x5834
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: load_flashdump
unsigned char *load_flashdump(char *flashfile) {
    FILE *fp;
    unsigned char *data;
    int length;

    printf("loading flash dump '%s' ...\n", flashfile);

    if(readbin(flashfile, &data, &length)) {
        return NULL;
    }

    if(length != FLASH_SIZE) {
        printf("warning: flash size mismatch. is your flash really 32MB?\n");
    }

    return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x6c56(%rip), %rdi      # 0xc4bd
movb $0x0, %al
callq 0x2080
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x5750
cmpl $0x0, %eax
je 0x588e
movq $0x0, -0x8(%rbp)
jmp 0x58ad
cmpl $0x2000000, -0x24(%rbp) # imm = 0x2000000
je 0x58a5
leaq 0x6c3c(%rip), %rdi      # 0xc4da
movb $0x0, %al
callq 0x2080
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: dump_console_info
int dump_console_info(unsigned char *flashdata, unsigned char *path) {
    struct nvs_console_info cinfo;
    char macaddress[6];
    FILE *fp = NULL;
    int i;

    // read console info and mac address
    nvs_read(flashdata, 0, 2, NVS_VAR_BLOCK2_CONSOLE_INF0, sizeof(cinfo), (unsigned char *)&cinfo);
    nvs_read(flashdata, 0, 0, NVS_VAR_BLOCK0_MAC_ADDRESS, sizeof(macaddress), macaddress);

    fp = fopen(path, "w");
    if(!fp) {
        return 1;
    }

    fprintf(fp, "motherboard serial: %.*s\n", (int)sizeof(cinfo.moboserial), cinfo.moboserial);
    fprintf(fp, "serial: %.*s\n", (int)sizeof(cinfo.serial), cinfo.serial);
    fprintf(fp, "model: %.*s\n", (int)sizeof(cinfo.model), cinfo.model);
    fprintf(fp, "mac address: ");
    for(i = 0; i < sizeof(macaddress); i++) {
        fprintf(fp, "%02X%c", macaddress[i] & 0xFF, (i == sizeof(macaddress) - 1) ? '\n' : ':');
    }

    fprintf(fp, "\n");

    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
xorl %ecx, %ecx
movl $0x2, %edx
movl $0x4e, %r8d
leaq -0x66(%rbp), %r9
movl %ecx, %esi
callq 0x7290
movq -0x10(%rbp), %rdi
leaq -0x6c(%rbp), %r9
xorl %edx, %edx
movl $0x21, %ecx
movl $0x6, %r8d
movl %edx, %esi
callq 0x7290
movq -0x18(%rbp), %rdi
leaq 0x6a8c(%rip), %rsi      # 0xc3aa
callq 0x2130
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x593a
movl $0x1, -0x4(%rbp)
jmp 0x5a19
movq -0x78(%rbp), %rdi
leaq -0x66(%rbp), %rcx
leaq 0x6bd4(%rip), %rsi      # 0xc51d
movl $0xe, %edx
movb $0x0, %al
callq 0x20d0
movq -0x78(%rbp), %rdi
leaq -0x66(%rbp), %rcx
addq $0x30, %rcx
leaq 0x6bd1(%rip), %rsi      # 0xc539
movl $0xa, %edx
movb $0x0, %al
callq 0x20d0
movq -0x78(%rbp), %rdi
leaq -0x66(%rbp), %rcx
addq $0x41, %rcx
leaq 0x6bc2(%rip), %rsi      # 0xc549
movl $0xd, %edx
movb $0x0, %al
callq 0x20d0
movq -0x78(%rbp), %rdi
leaq 0x6bba(%rip), %rsi      # 0xc558
movb $0x0, %al
callq 0x20d0
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
cmpq $0x6, %rax
jae 0x59f7
movq -0x78(%rbp), %rdi
movslq -0x7c(%rbp), %rax
movsbl -0x6c(%rbp,%rax), %edx
andl $0xff, %edx
movslq -0x7c(%rbp), %rsi
movl $0x3a, %ecx
movl $0xa, %eax
cmpq $0x5, %rsi
cmovel %eax, %ecx
leaq 0x6b2f(%rip), %rsi      # 0xc514
movb $0x0, %al
callq 0x20d0
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x59ac
movq -0x78(%rbp), %rdi
leaq 0x70f7(%rip), %rsi      # 0xcaf9
movb $0x0, %al
callq 0x20d0
movq -0x78(%rbp), %rdi
callq 0x2060
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: print_flashinfo
void print_flashinfo(unsigned char *flashdata) {
    struct nvs_console_info cinfo;
    char macaddress[6];
    int i;

    // read console info and mac address
    nvs_read(flashdata, 0, 2, NVS_VAR_BLOCK2_CONSOLE_INF0, sizeof(cinfo), (unsigned char *)&cinfo);
    nvs_read(flashdata, 0, 0, NVS_VAR_BLOCK0_MAC_ADDRESS, sizeof(macaddress), macaddress);

    printf("* motherboard serial: %.*s\n", (int)sizeof(cinfo.moboserial), cinfo.moboserial);
    printf("* serial: %.*s\n", (int)sizeof(cinfo.serial), cinfo.serial);
    printf("* model: %.*s\n", (int)sizeof(cinfo.model), cinfo.model);
    printf("* mac address: ");
    for(i = 0; i < sizeof(macaddress); i++) {
        printf("%02X%c", macaddress[i] & 0xFF, (i == sizeof(macaddress) - 1) ? '\n' : ':');
    }

    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
xorl %ecx, %ecx
movl $0x2, %edx
movl $0x4e, %r8d
leaq -0x56(%rbp), %r9
movl %ecx, %esi
callq 0x7290
movq -0x8(%rbp), %rdi
leaq -0x5c(%rbp), %r9
xorl %edx, %edx
movl $0x21, %ecx
movl $0x6, %r8d
movl %edx, %esi
callq 0x7290
leaq -0x56(%rbp), %rdx
leaq 0x6a9c(%rip), %rdi      # 0xc51b
movl $0xe, %esi
movb $0x0, %al
callq 0x2080
leaq -0x56(%rbp), %rdx
addq $0x30, %rdx
leaq 0x6a9d(%rip), %rdi      # 0xc537
movl $0xa, %esi
movb $0x0, %al
callq 0x2080
leaq -0x56(%rbp), %rdx
addq $0x41, %rdx
leaq 0x6a92(%rip), %rdi      # 0xc547
movl $0xd, %esi
movb $0x0, %al
callq 0x2080
leaq 0x6a8e(%rip), %rdi      # 0xc556
movb $0x0, %al
callq 0x2080
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
cmpq $0x6, %rax
jae 0x5b1d
movslq -0x60(%rbp), %rax
movsbl -0x5c(%rbp,%rax), %esi
andl $0xff, %esi
movslq -0x60(%rbp), %rcx
movl $0x3a, %edx
movl $0xa, %eax
cmpq $0x5, %rcx
cmovel %eax, %edx
leaq 0x6a09(%rip), %rdi      # 0xc514
movb $0x0, %al
callq 0x2080
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x5ad6
leaq 0x6fd5(%rip), %rdi      # 0xcaf9
movb $0x0, %al
callq 0x2080
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: extract_flashdump
int extract_flashdump(unsigned char *flashdata, char *extractdir) {
    unsigned char *ptr;
    int len;
    char path[512];
    
    printf("extracting flash to '%s' directory ...\n", extractdir);
    
    mkdir(extractdir, S_IRWXU);

    snprintf(path, sizeof(path), "%s/%s", extractdir, "emcipl.bin");
    if(decrypt_emc_ipl(flashdata, &ptr, &len)) {
        return 1;
    }

    dumpbin(path, ptr, len);
    free(ptr);

    printf("extracted EMC IPL to '%s'!\n", path);

    snprintf(path, sizeof(path), "%s/%s", extractdir, "eapkbl.elf");
    if(decrypt_eap_kbl(flashdata, &ptr, &len)) {
        return 1;
    }

    dumpbin(path, ptr, len);
    free(ptr);
    
    printf("extracted EAP KBL to '%s'!\n", path);

    snprintf(path, sizeof(path), "%s/%s", extractdir, "consoleinfo.txt");
    dump_console_info(flashdata, path);
    
    printf("wrote console info to '%s'!\n", path);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x6a02(%rip), %rdi      # 0xc5b0
movb $0x0, %al
callq 0x2080
movq -0x18(%rbp), %rdi
movl $0x1c0, %esi            # imm = 0x1C0
callq 0x2040
leaq -0x230(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x69fe(%rip), %rdx      # 0xc5d8
leaq 0x69fd(%rip), %r8       # 0xc5de
movb $0x0, %al
callq 0x2090
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0xa110
cmpl $0x0, %eax
je 0x5c0a
movl $0x1, -0x4(%rbp)
jmp 0x5d04
leaq -0x230(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x56e0
movq -0x20(%rbp), %rdi
callq 0x2030
leaq -0x230(%rbp), %rsi
leaq 0x69f1(%rip), %rdi      # 0xc625
movb $0x0, %al
callq 0x2080
leaq -0x230(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x6986(%rip), %rdx      # 0xc5d8
leaq 0x6990(%rip), %r8       # 0xc5e9
movb $0x0, %al
callq 0x2090
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0xa700
cmpl $0x0, %eax
je 0x5c82
movl $0x1, -0x4(%rbp)
jmp 0x5d04
leaq -0x230(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x56e0
movq -0x20(%rbp), %rdi
callq 0x2030
leaq -0x230(%rbp), %rsi
leaq 0x6999(%rip), %rdi      # 0xc645
movb $0x0, %al
callq 0x2080
leaq -0x230(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x690e(%rip), %rdx      # 0xc5d8
leaq 0x6923(%rip), %r8       # 0xc5f4
movb $0x0, %al
callq 0x2090
movq -0x10(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x58c0
leaq -0x230(%rbp), %rsi
leaq 0x690e(%rip), %rdi      # 0xc604
movb $0x0, %al
callq 0x2080
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/flashtool.c
// Function: rawextract_flashdump
int rawextract_flashdump(unsigned char *flashdata, char *extractdir) {
    struct bldr_hdr *emc_blhdr = flash_locate_emc_ipl(flashdata, 0);
    struct bldr_hdr *eap_blhdr = flash_locate_eap_kbl(flashdata);
    char path[512];

    snprintf(path, sizeof(path), "%s/%s", extractdir, "emcipl.bin");
    dumpbin(path, (unsigned char *)emc_blhdr, emc_blhdr->hdr_len + emc_blhdr->body_len);

    printf("raw extracted EMC IPL to '%s'!\n", path);

    snprintf(path, sizeof(path), "%s/%s", extractdir, "eapkbl.elf");
    dumpbin(path, (unsigned char *)eap_blhdr, eap_blhdr->hdr_len + eap_blhdr->body_len);

    printf("raw extracted EAP KBL to '%s'!\n", path);

    snprintf(path, sizeof(path), "%s/%s", extractdir, "consoleinfo.txt");
    dump_console_info(flashdata, path);
    
    printf("wrote console info to '%s'!\n", path);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x9b10
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9cc0
movq %rax, -0x20(%rbp)
leaq -0x220(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x6882(%rip), %rdx      # 0xc5d8
leaq 0x6881(%rip), %r8       # 0xc5de
movb $0x0, %al
callq 0x2090
leaq -0x220(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x18(%rbp), %rax
addl 0xc(%rax), %edx
callq 0x56e0
leaq -0x220(%rbp), %rsi
leaq 0x6891(%rip), %rdi      # 0xc621
movb $0x0, %al
callq 0x2080
leaq -0x220(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x682a(%rip), %rdx      # 0xc5d8
leaq 0x6834(%rip), %r8       # 0xc5e9
movb $0x0, %al
callq 0x2090
leaq -0x220(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x20(%rbp), %rax
addl 0xc(%rax), %edx
callq 0x56e0
leaq -0x220(%rbp), %rsi
leaq 0x6859(%rip), %rdi      # 0xc641
movb $0x0, %al
callq 0x2080
leaq -0x220(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x67d2(%rip), %rdx      # 0xc5d8
leaq 0x67e7(%rip), %r8       # 0xc5f4
movb $0x0, %al
callq 0x2090
movq -0x8(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x58c0
leaq -0x220(%rbp), %rsi
leaq 0x67d2(%rip), %rdi      # 0xc604
movb $0x0, %al
callq 0x2080
xorl %eax, %eax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/./slb2.h
// Function: find_and_print_slb2_info
static void find_and_print_slb2_info(unsigned char *flashdata) {
    struct slb2_header *hdr;
    struct slb2_entry *entry;
    unsigned char *ptr;
    int i, k;

    ptr = (unsigned char *)flashdata;

    while(ptr < (unsigned char *)(flashdata + 0x2000000)) {
        if(*(unsigned int *)ptr == SLB2_MAGIC) {
            hdr = (struct slb2_header *)ptr;

            printf("* found slb2_header at 0x%llX\n", (unsigned long long)(ptr - flashdata));

            for(k = 0; k < hdr->file_count; k++) {
                entry = &hdr->entry_list[k];
                printf("\tfile_name: %s block_offset: 0x%X file_size 0x%X\n", entry->file_name, entry->block_offset, entry->file_size);
            }
        }

        ptr += 4;
    }

    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
addq $0x2000000, %rcx        # imm = 0x2000000
cmpq %rcx, %rax
jae 0x6d64
movq -0x20(%rbp), %rax
cmpl $0x32424c53, (%rax)     # imm = 0x32424C53
jne 0x6d53
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rsi
movq -0x8(%rbp), %rax
subq %rax, %rsi
leaq 0x632d(%rip), %rdi      # 0xd01f
movb $0x0, %al
callq 0x2080
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x6d51
movq -0x10(%rbp), %rax
addq $0x20, %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
leaq 0x62ff(%rip), %rdi      # 0xd03e
movb $0x0, %al
callq 0x2080
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x6d00
jmp 0x6d53
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
jmp 0x6cb4
leaq 0x5d8e(%rip), %rdi      # 0xcaf9
movb $0x0, %al
callq 0x2080
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/keymgr.c
// Function: keymgr_cleanup
void keymgr_cleanup() {
    if(kmgrstate.keynames) {
        free(kmgrstate.keynames);
    }

    if(kmgrstate.keytypes) {
        free(kmgrstate.keytypes);
    }

    if(kmgrstate.keydata) {
        free(kmgrstate.keydata);
    }

    if(kmgrstate.filedata) {
        free(kmgrstate.filedata);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpq $0x0, 0x9224(%rip)      # 0x10350
je 0x713a
movq 0x921b(%rip), %rdi      # 0x10350
callq 0x2030
cmpq $0x0, 0x9216(%rip)      # 0x10358
je 0x7150
movq 0x920d(%rip), %rdi      # 0x10358
callq 0x2030
cmpq $0x0, 0x9208(%rip)      # 0x10360
je 0x7166
movq 0x91ff(%rip), %rdi      # 0x10360
callq 0x2030
cmpq $0x0, 0x91fa(%rip)      # 0x10368
je 0x717c
movq 0x91f1(%rip), %rdi      # 0x10368
callq 0x2030
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/keymgr.c
// Function: keymgr_printkeys
void keymgr_printkeys() {
    int i;

    printf("\nkey manager state:\n");
    for(i = 0; i < kmgrstate.numkeys; i++) {
        printf("\tname: '%s' keytype: 0x%X\n", kmgrstate.keynames[i], kmgrstate.keytypes[i]);
        //hexdump(kmgrstate.keydata[i], 0x10);
    }
    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x5efc(%rip), %rdi      # 0xd08b
movb $0x0, %al
callq 0x2080
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x91ca(%rip), %eax      # 0x10370
jge 0x71de
movq 0x91a1(%rip), %rax      # 0x10350
movslq -0x4(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x919a(%rip), %rax      # 0x10358
movslq -0x4(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x5ed4(%rip), %rdi      # 0xd0a0
movb $0x0, %al
callq 0x2080
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x719d
leaq 0x5914(%rip), %rdi      # 0xcaf9
movb $0x0, %al
callq 0x2080
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/keymgr.c
// Function: keymgr_getkey
unsigned char *keymgr_getkey(const char *keyname, int keytype) {
    int i;

    for(i = 0; i < kmgrstate.numkeys; i++) {
        if(!strcmp(kmgrstate.keynames[i], keyname) && kmgrstate.keytypes[i] == keytype) {
            return kmgrstate.keydata[i];
        }
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x9151(%rip), %eax      # 0x10370
jge 0x7273
movq 0x9128(%rip), %rax      # 0x10350
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
callq 0x20c0
cmpl $0x0, %eax
jne 0x7266
movq 0x9113(%rip), %rax      # 0x10358
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x14(%rbp), %eax
jne 0x7266
movq 0x9108(%rip), %rax      # 0x10360
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x727b
jmp 0x7268
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x7216
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/nvs.c
// Function: nvs_read
int nvs_read(unsigned char *flashdata, unsigned int bank, unsigned int block, unsigned int offset, int size, unsigned char *buffer) {
    if(bank != 0) {
        printf("error: invalid NVS bank number %i\n", bank);
        return 1;
    }

    if(block > 4) {
        printf("error: invalid NVS block number %i\n", block);
        return 1;
    }

    if(offset >= g_nvs_block_sizes[block]) {
        printf("error: invalid NVS offset 0x%X\n", offset);
        return 1;
    }

    memcpy(buffer, flashdata + g_nvs_block_offsets[block] + offset, size);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x72cd
movl -0x14(%rbp), %esi
leaq 0x5dfe(%rip), %rdi      # 0xd0bb
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x734b
cmpl $0x4, -0x18(%rbp)
jbe 0x72ed
movl -0x18(%rbp), %esi
leaq 0x5e01(%rip), %rdi      # 0xd0de
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x734b
movl -0x1c(%rbp), %eax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
leaq 0x9004(%rip), %rcx      # 0x10300
cmpl (%rcx,%rdx,4), %eax
jb 0x731b
movl -0x1c(%rbp), %esi
leaq 0x5df7(%rip), %rdi      # 0xd102
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x734b
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %eax
movl %eax, %ecx
leaq 0x8ff1(%rip), %rax      # 0x10320
movl (%rax,%rcx,4), %eax
addq %rax, %rsi
movl -0x1c(%rbp), %eax
addq %rax, %rsi
movslq -0x20(%rbp), %rdx
callq 0x20f0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jogolden[P]ps4flashtool/nvs.c
// Function: nvs_write
int nvs_write(unsigned char *flashdata, unsigned int bank, unsigned int block, unsigned int offset, int size, unsigned char *buffer) {
    if(bank != 0) {
        printf("error: invalid NVS bank number %i\n", bank);
        return 1;
    }

    if(block > 4) {
        printf("error: invalid NVS block number %i\n", block);
        return 1;
    }

    if(offset >= g_nvs_block_sizes[block]) {
        printf("error: invalid NVS offset 0x%X\n", offset);
        return 1;
    }

    memcpy(flashdata + g_nvs_block_offsets[block] + offset, buffer, size);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x739d
movl -0x14(%rbp), %esi
leaq 0x5d2e(%rip), %rdi      # 0xd0bb
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x741b
cmpl $0x4, -0x18(%rbp)
jbe 0x73bd
movl -0x18(%rbp), %esi
leaq 0x5d31(%rip), %rdi      # 0xd0de
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x741b
movl -0x1c(%rbp), %eax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
leaq 0x8f34(%rip), %rcx      # 0x10300
cmpl (%rcx,%rdx,4), %eax
jb 0x73eb
movl -0x1c(%rbp), %esi
leaq 0x5d27(%rip), %rdi      # 0xd102
movb $0x0, %al
callq 0x2080
movl $0x1, -0x4(%rbp)
jmp 0x741b
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %ecx
leaq 0x8f25(%rip), %rax      # 0x10320
movl (%rax,%rcx,4), %eax
addq %rax, %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movslq -0x20(%rbp), %rdx
callq 0x20f0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop