// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: trimFunc
static void trimFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const unsigned char *zIn;         /* Input string */
  const unsigned char *zCharSet;    /* Set of characters to trim */
  int nIn;                          /* Number of bytes in input */
  int flags;                        /* 1: trimleft  2: trimright  3: trim */
  int i;                            /* Loop counter */
  unsigned char *aLen = 0;          /* Length of each character in zCharSet */
  unsigned char **azChar = 0;       /* Individual characters in zCharSet */
  int nChar;                        /* Number of characters in zCharSet */

  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
    return;
  }
  zIn = sqlite3_value_text(argv[0]);
  if( zIn==0 ) return;
  nIn = sqlite3_value_bytes(argv[0]);
  assert( zIn==sqlite3_value_text(argv[0]) );
  if( argc==1 ){
    static const unsigned char lenOne[] = { 1 };
    static unsigned char * const azOne[] = { (u8*)" " };
    nChar = 1;
    aLen = (u8*)lenOne;
    azChar = (unsigned char **)azOne;
    zCharSet = 0;
  }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){
    return;
  }else{
    const unsigned char *z;
    for(z=zCharSet, nChar=0; *z; nChar++){
      SQLITE_SKIP_UTF8(z);
    }
    if( nChar>0 ){
      azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));
      if( azChar==0 ){
        return;
      }
      aLen = (unsigned char*)&azChar[nChar];
      for(z=zCharSet, nChar=0; *z; nChar++){
        azChar[nChar] = (unsigned char *)z;
        SQLITE_SKIP_UTF8(z);
        aLen[nChar] = (u8)(z - azChar[nChar]);
      }
    }
  }
  if( nChar>0 ){
    flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));
    if( flags & 1 ){
      while( nIn>0 ){
        int len = 0;
        for(i=0; i<nChar; i++){
          len = aLen[i];
          if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;
        }
        if( i>=nChar ) break;
        zIn += len;
        nIn -= len;
      }
    }
    if( flags & 2 ){
      while( nIn>0 ){
        int len = 0;
        for(i=0; i<nChar; i++){
          len = aLen[i];
          if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break;
        }
        if( i>=nChar ) break;
        nIn -= len;
      }
    }
    if( zCharSet ){
      sqlite3_free(azChar);
    }
  }
  sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10770
cmpl $0x5, %eax
jne 0x84f79
jmp 0x852a4
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10350
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x84f95
jmp 0x852a4
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10370
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0x84fd4
movl $0x1, -0x4c(%rbp)
leaq 0x28824(%rip), %rax     # 0xad7dc
movq %rax, -0x40(%rbp)
leaq 0x4a7ed(%rip), %rax     # 0xcf7b0
movq %rax, -0x48(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x8512b
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10350
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x84ff0
jmp 0x852a4
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x58(%rbp), %rax
cmpb $0x0, (%rax)
je 0x85053
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movzbl (%rax), %eax
cmpl $0xc0, %eax
jl 0x85046
jmp 0x85023
movq -0x58(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x85044
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x85023
jmp 0x85046
jmp 0x85048
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x84fff
cmpl $0x0, -0x4c(%rbp)
jle 0x85127
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rax
imulq $0x9, %rax, %rsi
callq 0x873e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x8507e
jmp 0x852a4
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x58(%rbp), %rax
cmpb $0x0, (%rax)
je 0x85125
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movzbl (%rax), %eax
cmpl $0xc0, %eax
jl 0x850f7
jmp 0x850d4
movq -0x58(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
jne 0x850f5
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x850d4
jmp 0x850f7
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
subq %rcx, %rax
movb %al, %dl
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x850a0
jmp 0x85127
jmp 0x85129
jmp 0x8512b
cmpl $0x0, -0x4c(%rbp)
jle 0x8528d
movq -0x8(%rbp), %rdi
callq 0x11790
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x851e3
jmp 0x85152
cmpl $0x0, -0x2c(%rbp)
jle 0x851e1
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x851b6
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x851a9
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x5c(%rbp), %rdx
callq 0x81c0
cmpl $0x0, %eax
jne 0x851a9
jmp 0x851b6
jmp 0x851ab
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8516a
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jl 0x851c0
jmp 0x851e1
movl -0x5c(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x5c(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x85152
jmp 0x851e3
movl -0x30(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8527b
jmp 0x851f4
cmpl $0x0, -0x2c(%rbp)
jle 0x85279
movl $0x0, -0x60(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x8525f
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x85252
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl -0x60(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x60(%rbp), %rdx
callq 0x81c0
cmpl $0x0, %eax
jne 0x85252
jmp 0x8525f
jmp 0x85254
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x85208
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jl 0x85269
jmp 0x85279
movl -0x60(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x851f4
jmp 0x8527b
cmpq $0x0, -0x28(%rbp)
je 0x8528b
movq -0x48(%rbp), %rdi
callq 0xa420
jmp 0x8528d
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x2c(%rbp), %edx
movq $-0x1, %rcx
callq 0x10d80
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)