#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ memcmp(char const *, char *, int);
int sqlite3FitsIn64Bits(const char *zNum) {
  int i, c;
  if (*zNum == '-' || *zNum == '+')
    zNum++;
  for (i = 0; (c = zNum[i]) >= '0' && c <= '9'; i++) {
  }
  return i < 19 || (i == 19 && memcmp(zNum, "9223372036854775807", 19) <= 0);
}


x86 assembly (clang, -O0):
<sqlite3FitsIn64Bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     113c <sqlite3FitsIn64Bits+0x2c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1148 <sqlite3FitsIn64Bits+0x38>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    %ecx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x11(%rbp)
jl     1176 <sqlite3FitsIn64Bits+0x66>
cmpl   $0x39,-0x10(%rbp)
setle  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1186 <sqlite3FitsIn64Bits+0x76>
jmp    1199 <sqlite3FitsIn64Bits+0x89>
jmp    118b <sqlite3FitsIn64Bits+0x7b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <sqlite3FitsIn64Bits+0x3f>
mov    $0x1,%al
cmpl   $0x13,-0xc(%rbp)
mov    %al,-0x12(%rbp)
jl     11dc <sqlite3FitsIn64Bits+0xcc>
xor    %eax,%eax
cmpl   $0x13,-0xc(%rbp)
mov    %al,-0x13(%rbp)
jne    11d6 <sqlite3FitsIn64Bits+0xc6>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x13,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
setle  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite3FitsIn64Bits>:
push   %rax
mov    (%rdi),%al
cmp    $0x2d,%al
je     111b <sqlite3FitsIn64Bits+0xb>
cmp    $0x2b,%al
jne    111f <sqlite3FitsIn64Bits+0xf>
add    $0x1,%rdi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rdi,%rcx,1),%eax
add    $0xd0,%al
add    $0x1,%rcx
cmp    $0xa,%al
jb     1130 <sqlite3FitsIn64Bits+0x20>
lea    -0x1(%rcx),%edx
mov    $0x1,%eax
cmp    $0x13,%edx
jb     116e <sqlite3FitsIn64Bits+0x5e>
xor    %eax,%eax
cmp    $0x14,%ecx
jne    116e <sqlite3FitsIn64Bits+0x5e>
lea    0xea7(%rip),%rsi
mov    $0x13,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setle  %al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"9223372036854775807\00"
define i32 @sqlite3FitsIn64Bits(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 45
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 43
br i1 %13, label %14, label %17
14: ; preds = %9, %1
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
br label %17
17: ; preds = %14, %9
store i32 0, i32* %3
br label %18
18: ; preds = %32, %17
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %4
%25 = icmp sge i32 %24, 48
br i1 %25, label %26, label %29
26: ; preds = %18
%27 = load i32, i32* %4
%28 = icmp sle i32 %27, 57
br label %29
29: ; preds = %26, %18
%30 = phi i1 [ false, %18 ], [ %28, %26 ]
br i1 %30, label %31, label %35
31: ; preds = %29
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %18
35: ; preds = %29
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 19
br i1 %37, label %47, label %38
38: ; preds = %35
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 19
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i8*, i8** %2
%43 = call i64 @memcmp(i8* %42, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
%44 = icmp sle i64 %43, 0
br label %45
45: ; preds = %41, %38
%46 = phi i1 [ false, %38 ], [ %44, %41 ]
br label %47
47: ; preds = %45, %35
%48 = phi i1 [ true, %35 ], [ %46, %45 ]
%49 = zext i1 %48 to i32
ret i32 %49
}

LLVM IR (-O2):
@.str = [20 x i8] c"9223372036854775807\00"
define i32 @sqlite3FitsIn64Bits(i8* %0) {
%2 = load i8, i8* %0
switch i8 %2, label %5 [
i8 45, label %3
i8 43, label %3
]
3: ; preds = %1, %1
%4 = getelementptr inbounds i8, i8* %0, i64 1
br label %5
5: ; preds = %1, %3
%6 = phi i8* [ %4, %3 ], [ %0, %1 ]
br label %7
7: ; preds = %7, %5
%8 = phi i64 [ %13, %7 ], [ 0, %5 ]
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = add i8 %10, -48
%12 = icmp ult i8 %11, 10
%13 = add nuw i64 %8, 1
br i1 %12, label %7, label %14
14: ; preds = %7
%15 = trunc i64 %8 to i32
%16 = icmp ult i32 %15, 19
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = icmp eq i32 %15, 19
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = tail call i64 @memcmp(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
%21 = icmp slt i64 %20, 1
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %17, %19, %14
%24 = phi i32 [ 1, %14 ], [ 0, %17 ], [ %22, %19 ]
ret i32 %24
}