#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readInput(int /*<<< orphan*/ *, char *, int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  FILE *in_file;
  int array[150];
  int size;
  char in_file_name[] = "array.dat";
  printf("\n\n=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\n\n");
  printf("\n\n");
  int desired_number = 0;
  printf("Enter what number to find: ");
  scanf("%d", &desired_number);
  readInput(in_file, in_file_name, array, desired_number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x27e(%rbp)
mov    0xeb1(%rip),%ax
mov    %ax,-0x276(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x284(%rbp)
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x284(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x27e(%rbp),%rsi
lea    -0x270(%rbp),%rdx
mov    -0x284(%rbp),%ecx
call   1040 <readInput@plt>
xor    %eax,%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x278,%rsp
movabs $0x61642e7961727261,%rax
2e 64 61
mov    %rax,0x10(%rsp)
movw   $0x74,0x18(%rsp)
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xe96(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    0x10(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1050 <readInput@plt>
xor    %eax,%eax
add    $0x278,%rsp
ret

LLVM IR (-O0):
@__const.main.in_file_name = [10 x i8] c"array.dat\00"
@.str = [56 x i8] c"\0A\0A=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\0A\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [28 x i8] c"Enter what number to find: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [150 x i32]
%4 = alloca i32
%5 = alloca [10 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i8]* %5 to i8*
%8 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%12 = load i32*, i32** %2
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [150 x i32], [150 x i32]* %3, i64 0, i64 0
%15 = load i32, i32* %6
%16 = call i32 @readInput(i32* %12, i8* %13, i32* %14, i32 %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.in_file_name = [10 x i8] c"array.dat\00"
@.str.2 = [28 x i8] c"Enter what number to find: \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [55 x i8] c"\0A\0A=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\0A\00"
@str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [150 x i32]
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = bitcast [150 x i32]* %1 to i8*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = getelementptr inbounds [150 x i32], [150 x i32]* %1, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @readInput(i32* undef, i8* %5, i32* %11, i32 %12)
ret i32 0
}