// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: renameParentFunc
static void renameParentFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  char *zOutput = 0;
  char *zResult;
  unsigned char const *zInput = sqlite3_value_text(argv[0]);
  unsigned char const *zOld = sqlite3_value_text(argv[1]);
  unsigned char const *zNew = sqlite3_value_text(argv[2]);

  unsigned const char *z;         /* Pointer to token */
  int n;                          /* Length of token z */
  int token;                      /* Type of token */

  UNUSED_PARAMETER(NotUsed);
  for(z=zInput; *z; z=z+n){
    n = sqlite3GetToken(z, &token);
    if( token==TK_REFERENCES ){
      char *zParent;
      do {
        z += n;
        n = sqlite3GetToken(z, &token);
      }while( token==TK_SPACE );

      zParent = sqlite3DbStrNDup(db, (const char *)z, n);
      if( zParent==0 ) break;
      sqlite3Dequote(zParent);
      if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
        char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"", 
            (zOutput?zOutput:""), z-zInput, zInput, (const char *)zNew
        );
        sqlite3DbFree(db, zOutput);
        zOutput = zOut;
        zInput = &z[n];
      }
      sqlite3DbFree(db, zParent);
    }
  }

  zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput), 
  sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
  sqlite3DbFree(db, zOutput);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x117b0
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10350
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10350
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10350
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpb $0x0, (%rax)
je 0x89db0
movq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x49ae0
movl %eax, -0x54(%rbp)
cmpl $0x66, -0x58(%rbp)
jne 0x89d9a
jmp 0x89cae
movl -0x54(%rbp), %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x49ae0
movl %eax, -0x54(%rbp)
cmpl $0x95, -0x58(%rbp)
je 0x89cae
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %edx
callq 0x4a7a0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x89cf8
jmp 0x89db0
movq -0x60(%rbp), %rdi
callq 0x5e890
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0xc970
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x89d8d
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x89d2f
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x89d3c
leaq 0x290bf(%rip), %rax     # 0xb2df5
movq %rax, -0x78(%rbp)
jmp 0x89d3c
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
subq %rax, %rcx
movq -0x38(%rbp), %r8
movq -0x48(%rbp), %r9
leaq 0x27da0(%rip), %rsi     # 0xb1afe
movb $0x0, %al
callq 0x137f0
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9cd0
movq -0x68(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x9cd0
jmp 0x89d9c
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x89c85
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x89dcc
movq -0x28(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x89ddc
leaq 0x29022(%rip), %rax     # 0xb2df5
movq %rax, -0x88(%rbp)
jmp 0x89ddc
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq 0x2689b(%rip), %rsi     # 0xb068d
movb $0x0, %al
callq 0x137f0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x80481(%rip), %rcx    # 0x9990
callq 0x10d80
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9cd0
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)