#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 */
struct gff3File {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gff3FileErr(struct gff3File *, char *, char *);
long strtol(char *, char **, int /*<<< orphan*/);
int gff3FileStrToInt(struct gff3File *g3f, char *str) {
  char *end;
  long val = strtol(str, &end, 0);
  if ((end == str) || (*end != '\0'))
    gff3FileErr(g3f, "invalid integer: %s", str);
  return (int)val;
}


x86 assembly (clang, -O0):
<gff3FileStrToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1161 <gff3FileStrToInt+0x41>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1175 <gff3FileStrToInt+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe90(%rip),%rsi
call   1040 <gff3FileErr@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gff3FileStrToInt>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rax
cmp    %rbx,%rax
je     1150 <gff3FileStrToInt+0x30>
cmpb   $0x0,(%rax)
je     1162 <gff3FileStrToInt+0x42>
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <gff3FileErr@plt>
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.gff3File = type { i32 }
@.str = [20 x i8] c"invalid integer: %s\00"
define i32 @gff3FileStrToInt(%struct.gff3File* %0, i8* %1) {
%3 = alloca %struct.gff3File*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store %struct.gff3File* %0, %struct.gff3File** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strtol(i8* %7, i8** %5, i32 0)
store i64 %8, i64* %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp eq i8* %9, %10
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12, %2
%18 = load %struct.gff3File*, %struct.gff3File** %3
%19 = load i8*, i8** %4
%20 = call i32 @gff3FileErr(%struct.gff3File* %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %12
%22 = load i64, i64* %6
%23 = trunc i64 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%struct.gff3File = type { i32 }
@.str = [20 x i8] c"invalid integer: %s\00"
define i32 @gff3FileStrToInt(%struct.gff3File* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtol(i8* %1, i8** %3, i32 0)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %2
%12 = tail call i32 @gff3FileErr(%struct.gff3File* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %13
13: ; preds = %11, %8
%14 = trunc i64 %5 to i32
ret i32 %14
}