// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: charFunc
static void charFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  unsigned char *z, *zOut;
  int i;
  zOut = z = sqlite3_malloc64( argc*4+1 );
  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_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %eax
shll $0x2, %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x3c07c0
movq %rax, -0x20(%rbp)
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x466811
movq -0x8(%rbp), %rdi
callq 0x3c8b60
jmp 0x466a18
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4669f3
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3c7af0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jl 0x46684a
cmpq $0x10ffff, -0x38(%rbp)  # imm = 0x10FFFF
jle 0x466852
movq $0xfffd, -0x38(%rbp)    # imm = 0xFFFD
movq -0x38(%rbp), %rax
andq $0x1fffff, %rax         # imm = 0x1FFFFF
movl %eax, -0x3c(%rbp)
cmpl $0x80, -0x3c(%rbp)
jae 0x466888
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 0x4669e3
cmpl $0x800, -0x3c(%rbp)     # imm = 0x800
jae 0x4668db
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 0x4669e1
cmpl $0x10000, -0x3c(%rbp)   # imm = 0x10000
jae 0x466952
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 0x4669df
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 0x4669e1
jmp 0x4669e3
jmp 0x4669e5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x466818
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq -0xa620d(%rip), %rcx    # 0x3c0800
movl $0x1, %r8d
callq 0x3c8700
addq $0x40, %rsp
popq %rbp
retq
nop