#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int sscanf(char *, char *, long *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
void readLong(char *s, long *x) {
  int err;
  err = sscanf(s, "%ld", x);
  if (err == 0 || err == EOF) {
    fprintf(stderr, "\"%s\" is not an integer!\n", s);
    usage();
    exit(1);
  }
}


x86 assembly (clang, -O0):
<readLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xea1(%rip),%rsi
call   1040 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1183 <readLong+0x43>
mov    -0x14(%rbp),%eax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
jne    11ad <readLong+0x6d>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLong>:
push   %rbx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeb2(%rip),%rsi
call   1040 <sscanf@plt>
test   %eax,%eax
je     1164 <readLong+0x24>
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1164 <readLong+0x24>
pop    %rbx
ret
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"\22%s\22 is not an integer!\0A\00"
define void @readLong(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i32
store i8* %0, i8** %3
store i64* %1, i64** %4
%6 = load i8*, i8** %3
%7 = load i64*, i64** %4
%8 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* %5
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11, %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %3
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (...) @usage()
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"\22%s\22 is not an integer!\0A\00"
define void @readLong(i8* %0, i64* %1) {
%3 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp eq i32 %3, 0
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %3, %5
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = tail call i32 (...) @usage()
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
ret void
}