#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int userInt = 0;
  printf("Please enter a positive integer: ");
  scanf("%d", &userInt);
  printf("You entered positive integer: %d\n", userInt);
  int *intData = NULL;
  int intSize = 0;
  int foundUserInt = 0;
  FILE *fileHandle = fopen("./Data1.txt", "r");
  {
    fscanf(fileHandle, "%d", &intSize);
    intData = (int *)(malloc(sizeof(int) * intSize));
    for (int intFor1 = 0; intFor1 < intSize; intFor1++) {
      fscanf(fileHandle, "%d", &intData[intFor1]);
    }
  }
  fclose(fileHandle);
  for (int intFor1 = 0; intFor1 < intSize; intFor1++) {
    if (userInt == intData[intFor1]) {
      printf("Number %d found at index %d.\n", userInt, intFor1);
      foundUserInt++;
    }
  }
  if (!foundUserInt) {
    printf("Integer NOT FOUND.\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xe7e(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe3e(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <fscanf@plt>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1240 <main+0xe0>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdf5(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1207 <main+0xa7>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a0 <main+0x140>
mov    -0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x38(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    128d <main+0x12d>
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1292 <main+0x132>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1250 <main+0xf0>
cmpl   $0x0,-0x28(%rbp)
jne    12b8 <main+0x158>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe89(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0xe80(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <fscanf@plt>
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0x8(%rsp)
jle    1230 <main+0xc0>
xor    %ebp,%ebp
lea    0xe1d(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1210 <main+0xa0>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    127f <main+0x10f>
lea    0xe0e(%rip),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    125c <main+0xec>
nopl   (%rax)
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    127b <main+0x10b>
mov    0xc(%rsp),%esi
cmp    (%r14,%rbx,4),%esi
jne    1250 <main+0xe0>
mov    %r15,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
jmp    1250 <main+0xe0>
test   %ebp,%ebp
jne    128b <main+0x11b>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Please enter a positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"You entered positive integer: %d\0A\00"
@.str.3 = [12 x i8] c"./Data1.txt\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [30 x i8] c"Number %d found at index %d.\0A\00"
@.str.6 = [20 x i8] c"Integer NOT FOUND.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %15)
store i32* null, i32** %7
store i32 0, i32* %8
store i32 0, i32* %9
%17 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %17, i32** %10
%18 = load i32*, i32** %10
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = mul i64 4, %21
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %7
store i32 0, i32* %11
br label %26
26: ; preds = %37, %2
%27 = load i32, i32* %11
%28 = load i32, i32* %8
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32*, i32** %10
%32 = load i32*, i32** %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %26
40: ; preds = %26
%41 = load i32*, i32** %10
%42 = call i32 @fclose(i32* %41)
store i32 0, i32* %12
br label %43
43: ; preds = %62, %40
%44 = load i32, i32* %12
%45 = load i32, i32* %8
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %65
47: ; preds = %43
%48 = load i32, i32* %6
%49 = load i32*, i32** %7
%50 = load i32, i32* %12
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = icmp eq i32 %48, %53
br i1 %54, label %55, label %61
55: ; preds = %47
%56 = load i32, i32* %6
%57 = load i32, i32* %12
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %56, i32 %57)
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %61
61: ; preds = %55, %47
br label %62
62: ; preds = %61
%63 = load i32, i32* %12
%64 = add nsw i32 %63, 1
store i32 %64, i32* %12
br label %43
65: ; preds = %43
%66 = load i32, i32* %9
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [34 x i8] c"Please enter a positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"You entered positive integer: %d\0A\00"
@.str.3 = [12 x i8] c"./Data1.txt\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [30 x i8] c"Number %d found at index %d.\0A\00"
@str = [19 x i8] c"Integer NOT FOUND.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %4
%14 = shl i32 %13, 2
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %23, %2
%20 = call i32 @fclose(i32* %11)
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %33, label %52
23: ; preds = %2, %23
%24 = phi i64 [ %27, %23 ], [ 0, %2 ]
%25 = getelementptr inbounds i32, i32* %16, i64 %24
%26 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = add nuw nsw i64 %24, 1
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %23, label %19
31: ; preds = %46
%32 = icmp eq i32 %48, 0
br i1 %32, label %52, label %54
33: ; preds = %19, %46
%34 = phi i32 [ %47, %46 ], [ %21, %19 ]
%35 = phi i64 [ %49, %46 ], [ 0, %19 ]
%36 = phi i32 [ %48, %46 ], [ 0, %19 ]
%37 = load i32, i32* %3
%38 = getelementptr inbounds i32, i32* %16, i64 %35
%39 = load i32, i32* %38
%40 = icmp eq i32 %37, %39
br i1 %40, label %41, label %46
41: ; preds = %33
%42 = trunc i64 %35 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 %42)
%44 = add nsw i32 %36, 1
%45 = load i32, i32* %4
br label %46
46: ; preds = %33, %41
%47 = phi i32 [ %45, %41 ], [ %34, %33 ]
%48 = phi i32 [ %44, %41 ], [ %36, %33 ]
%49 = add nuw nsw i64 %35, 1
%50 = sext i32 %47 to i64
%51 = icmp slt i64 %49, %50
br i1 %51, label %33, label %31
52: ; preds = %19, %31
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %54
54: ; preds = %52, %31
ret i32 0
}