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

  if( ((signed char*)p)[0]>=0 ){
    *v = *p;
    return 1;
  }
  if( ((signed char*)p)[1]>=0 ){
    *v = ((u32)(p[0]&0x7f)<<7) | p[1];
    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)) );

  a = ((u32)p[0])<<14;
  b = p[1];
  p += 2;
  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
    ** while calculating 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
movsbl (%rax), %eax
cmpl $0x0, %eax
jl 0x3e4ba1
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x3e4f44
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jl 0x3e4bd9
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7f, %eax
shll $0x7, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x2, -0x1(%rbp)
jmp 0x3e4f44
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0xe, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%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 0x3e4c52
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 0x3e4f44
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 0x3e4cbe
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 0x3e4f44
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 0x3e4d38
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 0x3e4f44
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 0x3e4dbe
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 0x3e4f44
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 0x3e4e3d
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 0x3e4f44
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 0x3e4ebc
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 0x3e4f44
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)