// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3GetVarint
SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){
  u32 a,b,s;

  a = *p;
  /* a: p0 (unmasked) */
  if (!(a&0x80))
  {
    *v = a;
    return 1;
  }

  p++;
  b = *p;
  /* b: p1 (unmasked) */
  if (!(b&0x80))
  {
    a &= 0x7f;
    a = a<<7;
    a |= b;
    *v = a;
    return 2;
  }

  /* Verify that constants are precomputed correctly */
  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );

  p++;
  a = a<<14;
  a |= *p;
  /* a: p0<<14 | p2 (unmasked) */
  if (!(a&0x80))
  {
    a &= SLOT_2_0;
    b &= 0x7f;
    b = b<<7;
    a |= b;
    *v = a;
    return 3;
  }

  /* CSE1 from below */
  a &= SLOT_2_0;
  p++;
  b = b<<14;
  b |= *p;
  /* b: p1<<14 | p3 (unmasked) */
  if (!(b&0x80))
  {
    b &= SLOT_2_0;
    /* moved CSE1 up */
    /* a &= (0x7f<<14)|(0x7f); */
    a = a<<7;
    a |= b;
    *v = a;
    return 4;
  }

  /* a: p0<<14 | p2 (masked) */
  /* b: p1<<14 | p3 (unmasked) */
  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
  /* moved CSE1 up */
  /* a &= (0x7f<<14)|(0x7f); */
  b &= SLOT_2_0;
  s = a;
  /* s: p0<<14 | p2 (masked) */

  p++;
  a = a<<14;
  a |= *p;
  /* a: p0<<28 | p2<<14 | p4 (unmasked) */
  if (!(a&0x80))
  {
    /* we can skip these cause they were (effectively) done above in calc'ing s */
    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
    /* b &= (0x7f<<14)|(0x7f); */
    b = b<<7;
    a |= b;
    s = s>>18;
    *v = ((u64)s)<<32 | a;
    return 5;
  }

  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
  s = s<<7;
  s |= b;
  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */

  p++;
  b = b<<14;
  b |= *p;
  /* b: p1<<28 | p3<<14 | p5 (unmasked) */
  if (!(b&0x80))
  {
    /* we can skip this cause it was (effectively) done above in calc'ing s */
    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
    a &= SLOT_2_0;
    a = a<<7;
    a |= b;
    s = s>>18;
    *v = ((u64)s)<<32 | a;
    return 6;
  }

  p++;
  a = a<<14;
  a |= *p;
  /* a: p2<<28 | p4<<14 | p6 (unmasked) */
  if (!(a&0x80))
  {
    a &= SLOT_4_2_0;
    b &= SLOT_2_0;
    b = b<<7;
    a |= b;
    s = s>>11;
    *v = ((u64)s)<<32 | a;
    return 7;
  }

  /* CSE2 from below */
  a &= SLOT_2_0;
  p++;
  b = b<<14;
  b |= *p;
  /* b: p3<<28 | p5<<14 | p7 (unmasked) */
  if (!(b&0x80))
  {
    b &= SLOT_4_2_0;
    /* moved CSE2 up */
    /* a &= (0x7f<<14)|(0x7f); */
    a = a<<7;
    a |= b;
    s = s>>4;
    *v = ((u64)s)<<32 | a;
    return 8;
  }

  p++;
  a = a<<15;
  a |= *p;
  /* a: p4<<29 | p6<<15 | p8 (unmasked) */

  /* moved CSE2 up */
  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */
  b &= SLOT_2_0;
  b = b<<8;
  a |= b;

  s = s<<4;
  b = p[-4];
  b &= 0x7f;
  b = b>>3;
  s |= b;

  *v = ((u64)s)<<32 | a;

  return 9;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c3e8
movl -0x1c(%rbp), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x2c797
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c43b
movl -0x1c(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x2, -0x1(%rbp)
jmp 0x2c797
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c4a5
movl -0x1c(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x3, -0x1(%rbp)
jmp 0x2c797
movl -0x1c(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x20(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c511
movl -0x20(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x4, -0x1(%rbp)
jmp 0x2c797
movl -0x20(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c58b
movl -0x20(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
shrl $0x12, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl -0x1c(%rbp), %eax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x5, -0x1(%rbp)
jmp 0x2c797
movl -0x24(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x20(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c611
movl -0x1c(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
shrl $0x12, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl -0x1c(%rbp), %eax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x6, -0x1(%rbp)
jmp 0x2c797
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c690
movl -0x1c(%rbp), %eax
andl $0xf01fc07f, %eax       # imm = 0xF01FC07F
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
shrl $0xb, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl -0x1c(%rbp), %eax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x7, -0x1(%rbp)
jmp 0x2c797
movl -0x1c(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x20(%rbp), %eax
shll $0xe, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2c70f
movl -0x20(%rbp), %eax
andl $0xf01fc07f, %eax       # imm = 0xF01FC07F
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
shrl $0x4, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl -0x1c(%rbp), %eax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x8, -0x1(%rbp)
jmp 0x2c797
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
shll $0xf, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
andl $0x1fc07f, %eax         # imm = 0x1FC07F
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movzbl -0x4(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shrl $0x3, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl -0x1c(%rbp), %eax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x9, -0x1(%rbp)
movb -0x1(%rbp), %al
popq %rbp
retq
nopl (%rax)