// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: charFunc
static void charFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  unsigned char *z, *zOut;
  int i;
  zOut = z = sqlite3_malloc( argc*4 );
  if( z==0 ){
    sqlite3_result_error_nomem(context);
    return;
  }
  for(i=0; i<argc; i++){
    sqlite3_int64 x;
    unsigned c;
    x = sqlite3_value_int64(argv[i]);
    if( x<0 || x>0x10ffff ) x = 0xfffd;
    c = (unsigned)(x & 0x1fffff);
    if( c<0x00080 ){
      *zOut++ = (u8)(c&0xFF);
    }else if( c<0x00800 ){
      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);
      *zOut++ = 0x80 + (u8)(c & 0x3F);
    }else if( c<0x10000 ){
      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);
      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
      *zOut++ = 0x80 + (u8)(c & 0x3F);
    }else{
      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);
      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);
      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
      *zOut++ = 0x80 + (u8)(c & 0x3F);
    }                                                    \
  }
  sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %edi
shll $0x2, %edi
callq 0xa380
movq %rax, -0x20(%rbp)
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x85c1b
movq -0x8(%rbp), %rdi
callq 0x11120
jmp 0x85e1e
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x85dfd
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x105c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jl 0x85c54
cmpq $0x10ffff, -0x38(%rbp)  # imm = 0x10FFFF
jle 0x85c5c
movq $0xfffd, -0x38(%rbp)    # imm = 0xFFFD
movq -0x38(%rbp), %rax
andq $0x1fffff, %rax         # imm = 0x1FFFFF
movl %eax, -0x3c(%rbp)
cmpl $0x80, -0x3c(%rbp)
jae 0x85c92
movl -0x3c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x85ded
cmpl $0x800, -0x3c(%rbp)     # imm = 0x800
jae 0x85ce5
movl -0x3c(%rbp), %eax
shrl $0x6, %eax
andl $0x1f, %eax
movzbl %al, %eax
addl $0xc0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x85deb
cmpl $0x10000, -0x3c(%rbp)   # imm = 0x10000
jae 0x85d5c
movl -0x3c(%rbp), %eax
shrl $0xc, %eax
andl $0xf, %eax
movzbl %al, %eax
addl $0xe0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x85de9
movl -0x3c(%rbp), %eax
shrl $0x12, %eax
andl $0x7, %eax
movzbl %al, %eax
addl $0xf0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
shrl $0xc, %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x3c(%rbp), %eax
andl $0x3f, %eax
movzbl %al, %eax
addl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x85deb
jmp 0x85ded
jmp 0x85def
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x85c22
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
leaq -0x7b9f9(%rip), %rcx    # 0xa420
callq 0x10d80
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)