#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 /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int f91(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int num;
  if (argc != 2) {
    printf("Usage: %s INPUT_FILE\n\n", argv[0]);
    exit(-1);
  }
  if (access(argv[1], F_OK)) {
    printf("Error: INPUT_FILE %s does not exist\n\n", argv[1]);
    exit(-1);
  }
  freopen(argv[1], "r", stdin);
  while (scanf("%d", &num) && num) {
    printf("f91(%d) = %d\n", num, f91(num));
  }
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11af <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0x0,%rax
je     11ef <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
lea    0xe36(%rip),%rsi
call   1060 <freopen@plt>
lea    0xe2c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x15(%rbp)
je     1238 <main+0xc8>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1248 <main+0xd8>
jmp    126e <main+0xfe>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <f91@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    120c <main+0x9c>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1245 <main+0xd5>
mov    0x8(%rbx),%rdi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
mov    0x8(%rbx),%rcx
test   %rax,%rax
jne    1251 <main+0xe1>
mov    0x2e3a(%rip),%r12
mov    (%r12),%edx
lea    0xe84(%rip),%rsi
mov    %rcx,%rdi
call   1060 <freopen@plt>
lea    0xe77(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
test   %rax,%rax
je     122d <main+0xbd>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
je     122d <main+0xbd>
lea    0xe5c(%rip),%r14
lea    0xe52(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1030 <f91@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %rax,%rax
je     122d <main+0xbd>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jne    1200 <main+0x90>
mov    (%r12),%edi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xdb1(%rip),%rdi
jmp    125b <main+0xeb>
lea    0xdbf(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c"f91(%d) = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @F_OK
%20 = call i64 @access(i8* %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %15
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i32, i32* @stdin
%33 = call i32 @freopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %42, %28
%35 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br label %40
40: ; preds = %37, %34
%41 = phi i1 [ false, %34 ], [ %39, %37 ]
br i1 %41, label %42, label %47
42: ; preds = %40
%43 = load i32, i32* %6
%44 = load i32, i32* %6
%45 = call i32 @f91(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %45)
br label %34
47: ; preds = %40
%48 = load i32, i32* @stdin
%49 = call i32 @fclose(i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c"f91(%d) = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @F_OK
%14 = tail call i64 @access(i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = load i8*, i8** %11
br i1 %15, label %20, label %17
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %10
%21 = load i32, i32* @stdin
%22 = tail call i32 @freopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%24 = icmp ne i64 %23, 0
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %28, label %37
28: ; preds = %20, %28
%29 = phi i32 [ %34, %28 ], [ %25, %20 ]
%30 = call i32 @f91(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30)
%32 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%33 = icmp ne i64 %32, 0
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 0
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %28, label %37
37: ; preds = %28, %20
%38 = load i32, i32* @stdin
%39 = call i32 @fclose(i32 %38)
ret i32 0
}