#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 */
char *fgets(char *, int, int /*<<< orphan*/);
long oatoi(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
long get_int(char *ch, int no) {
  int len = 100;
  char *tstr;
  char str[100];
  printf("%s: ", ch);
  tstr = fgets(str, len, stdin);
  if (tstr == NULL)
    return (no);
  return (oatoi(str, no));
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118d <get_int+0x5d>
movslq -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <get_int+0x70>
lea    -0x90(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <oatoi@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rbx
sub    $0x70,%rsp
mov    %esi,%ebx
mov    %rdi,%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     116d <get_int+0x3d>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1050 <oatoi@plt>
jmp    1170 <get_int+0x40>
movslq %ebx,%rax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define i64 @get_int(i8* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [100 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 100, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%12 = load i32, i32* %6
%13 = load i32, i32* @stdin
%14 = call i8* @fgets(i8* %11, i32 %12, i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
store i64 %19, i64* %3
br label %24
20: ; preds = %2
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i64 @oatoi(i8* %21, i32 %22)
store i64 %23, i64* %3
br label %24
24: ; preds = %20, %17
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define i64 @get_int(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stdin
%7 = call i8* @fgets(i8* %4, i32 100, i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = sext i32 %1 to i64
br label %13
11: ; preds = %2
%12 = call i64 @oatoi(i8* %4, i32 %1)
br label %13
13: ; preds = %11, %9
%14 = phi i64 [ %10, %9 ], [ %12, %11 ]
ret i64 %14
}