#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 */
int atoi(char *);
int /*<<< orphan*/ errAbort(char *, char *, char *);
scalar_t__ isdigit(char);
char *mustFindVarData(char *);
char *skipLeadingSpaces(char *);
int cgiInt(char *varName) {
  char *data;
  char c;
  data = mustFindVarData(varName);
  data = skipLeadingSpaces(data);
  c = data[0];
  if (!(isdigit(c) || (c == '-' && isdigit(data[1]))))
    errAbort("Expecting number in %s, got \"%s\"\n", varName, data);
  return atoi(data);
}


x86 assembly (clang, -O0):
<cgiInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <mustFindVarData@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <skipLeadingSpaces@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11ca <cgiInt+0x7a>
movsbl -0x11(%rbp),%eax
cmp    $0x2d,%eax
jne    11b6 <cgiInt+0x66>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11ca <cgiInt+0x7a>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe3b(%rip),%rdi
call   1040 <errAbort@plt>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgiInt>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1070 <mustFindVarData@plt>
mov    %rax,%rdi
call   1050 <skipLeadingSpaces@plt>
mov    %rax,%r15
mov    (%rax),%bl
movsbl %bl,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    119d <cgiInt+0x4d>
cmp    $0x2d,%bl
jne    118b <cgiInt+0x3b>
movsbl 0x1(%r15),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    119d <cgiInt+0x4d>
lea    0xe6e(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <errAbort@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <atoi@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Expecting number in %s, got \22%s\22\0A\00"
define i32 @cgiInt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @mustFindVarData(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @skipLeadingSpaces(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
store i8 %11, i8* %4
%12 = load i8, i8* %4
%13 = call i64 @isdigit(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %29, label %15
15: ; preds = %1
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = call i64 @isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %19, %15
%26 = load i8*, i8** %2
%27 = load i8*, i8** %3
%28 = call i32 @errAbort(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
br label %29
29: ; preds = %25, %19, %1
%30 = load i8*, i8** %3
%31 = call i32 @atoi(i8* %30)
ret i32 %31
}

LLVM IR (-O2):
@.str = [34 x i8] c"Expecting number in %s, got \22%s\22\0A\00"
define i32 @cgiInt(i8* %0) {
%2 = tail call i8* @mustFindVarData(i8* %0)
%3 = tail call i8* @skipLeadingSpaces(i8* %2)
%4 = load i8, i8* %3
%5 = tail call i64 @isdigit(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = icmp eq i8 %4, 45
br i1 %8, label %9, label %14
9: ; preds = %7
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9, %7
%15 = tail call i32 @errAbort(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %3)
br label %16
16: ; preds = %14, %9, %1
%17 = tail call i32 @atoi(i8* %3)
ret i32 %17
}