#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 value {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_str(struct value *);
int sscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ stderr;
int get_int(struct value *v) {
  int i;
  int scanned = sscanf(get_str(v), "%i", &i);
  if (scanned != 1) {
    fprintf(stderr, "get_int: could not parse int\n");
    exit(0);
  }
  return i;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_str@plt>
mov    %eax,%edi
lea    0xea2(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1190 <get_int+0x50>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rax
call   1050 <get_str@plt>
lea    0xeb3(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %eax,%edi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1164 <get_int+0x24>
mov    0x4(%rsp),%eax
pop    %rcx
ret
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.value = type { i32 }
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"get_int: could not parse int\0A\00"
define i32 @get_int(%struct.value* %0) {
%2 = alloca %struct.value*
%3 = alloca i32
%4 = alloca i32
store %struct.value* %0, %struct.value** %2
%5 = load %struct.value*, %struct.value** %2
%6 = call i32 @get_str(%struct.value* %5)
%7 = call i32 @sscanf(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %1
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
%struct.value = type { i32 }
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"get_int: could not parse int\0A\00"
define i32 @get_int(%struct.value* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @get_str(%struct.value* %0)
%5 = call i32 @sscanf(i32 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %1
%12 = load i32, i32* %2
ret i32 %12
}