// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: readMasterJournal
static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){
  int rc;                    /* Return code */
  u32 len;                   /* Length in bytes of master journal name */
  i64 szJ;                   /* Total size in bytes of journal file pJrnl */
  u32 cksum;                 /* MJ checksum value read from journal */
  u32 u;                     /* Unsigned loop counter */
  unsigned char aMagic[8];   /* A buffer to hold the magic header */
  zMaster[0] = '\0';

  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))
   || szJ<16
   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))
   || len>=nMaster 
   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))
   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))
   || memcmp(aMagic, aJournalMagic, 8)
   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))
  ){
    return rc;
  }

  /* See if the checksum matches the master journal name */
  for(u=0; u<len; u++){
    cksum -= zMaster[u];
  }
  if( cksum ){
    /* If the checksum doesn't add up, then one or more of the disk sectors
    ** containing the master journal filename is corrupted. This means
    ** definitely roll back, so just return SQLITE_OK and report a (nul)
    ** master-journal filename.
    */
    len = 0;
  }
  zMaster[len] = '\0';
   
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x23e00
movl %eax, %ecx
movl %ecx, -0x20(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28b0e
cmpq $0x10, -0x30(%rbp)
jl 0x28b0e
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
subq $0x10, %rsi
leaq -0x24(%rbp), %rdx
callq 0x287c0
movl %eax, %ecx
movl %ecx, -0x20(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28b0e
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x28b0e
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
subq $0xc, %rsi
leaq -0x34(%rbp), %rdx
callq 0x287c0
movl %eax, %ecx
movl %ecx, -0x20(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28b0e
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rcx
subq $0x8, %rcx
movl $0x8, %edx
callq 0x23e30
movl %eax, %ecx
movl %ecx, -0x20(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28b0e
leaq -0x40(%rbp), %rax
movq (%rax), %rax
movabsq $-0x289c5edf06fa2a27, %rcx # imm = 0xD763A120F905D5D9
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x28b0e
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rcx
subq $0x10, %rcx
movl -0x24(%rbp), %eax
subq %rax, %rcx
callq 0x23e30
movl %eax, %ecx
movl %ecx, -0x20(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x28b16
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x28b62
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x28b43
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movsbl (%rax,%rcx), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x28b1d
cmpl $0x0, -0x34(%rbp)
je 0x28b50
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)