// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: roundFunc
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  int n = 0;
  double r;
  char *zBuf;
  assert( argc==1 || argc==2 );
  if( argc==2 ){
    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
    n = sqlite3_value_int(argv[1]);
    if( n>30 ) n = 30;
    if( n<0 ) n = 0;
  }
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  r = sqlite3_value_double(argv[0]);
  /* If Y==0 and X will fit in a 64-bit int,
  ** handle the rounding directly,
  ** otherwise use printf.
  */
  if( n==0 && r>=0 && r<LARGEST_INT64-1 ){
    r = (double)((sqlite_int64)(r+0.5));
  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){
    r = -(double)((sqlite_int64)((-r)+0.5));
  }else{
    zBuf = sqlite3_mprintf("%.*f",n,r);
    if( zBuf==0 ){
      sqlite3_result_error_nomem(context);
      return;
    }
    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
    sqlite3_free(zBuf);
  }
  sqlite3_result_double(context, r);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0xc(%rbp)
jne 0x85f89
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10770
movl %eax, %ecx
movl $0x5, %eax
cmpl %ecx, %eax
jne 0x85f5d
jmp 0x860ec
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10500
movl %eax, -0x1c(%rbp)
cmpl $0x1e, -0x1c(%rbp)
jle 0x85f7a
movl $0x1e, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x85f87
movl $0x0, -0x1c(%rbp)
jmp 0x85f89
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10770
cmpl $0x5, %eax
jne 0x85f9f
jmp 0x860ec
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x10430
movsd %xmm0, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x85ff4
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x85ff4
movsd 0x27e7c(%rip), %xmm0    # 0xade48
ucomisd -0x28(%rbp), %xmm0
jbe 0x85ff4
movsd 0x27e15(%rip), %xmm0    # 0xaddf0
addsd -0x28(%rbp), %xmm0
cvttsd2si %xmm0, %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x860de
cmpl $0x0, -0x1c(%rbp)
jne 0x86082
xorps %xmm0, %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x86082
movsd -0x28(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x27e1c(%rip), %xmm0    # 0xade48
ucomisd %xmm1, %xmm0
jbe 0x86082
movsd -0x28(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x27d9a(%rip), %xmm1    # 0xaddf0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
cvtsi2sd %rax, %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x860dc
movl -0x1c(%rbp), %esi
movsd -0x28(%rbp), %xmm0
leaq 0x2b937(%rip), %rdi     # 0xb19c8
movb $0x1, %al
callq 0xc400
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x860ae
movq -0x8(%rbp), %rdi
callq 0x11120
jmp 0x860ec
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x92f0
movq -0x38(%rbp), %rdi
movl %eax, %edx
leaq -0x28(%rbp), %rsi
movl $0x1, %ecx
callq 0x308d0
movq -0x30(%rbp), %rdi
callq 0xa420
jmp 0x860de
movq -0x8(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
callq 0x10820
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)