#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 *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int expected_outputs[] = {495000, 430100, 7700, 0, 1225};
  int readings[5];
  int i;
  int alright = 1;
  FILE *fp = fopen("output", "r");
  if (fp == NULL) {
    printf("Error opening file");
    return 1;
  }
  for (i = 0; i < 5; i++)
    fscanf(fp, "%d\n", &readings[i]);
  for (i = 0; i < 5; i++)
    if (expected_outputs[i] != readings[i])
      alright = 0;
  if (alright == 1)
    printf("Expected outputs!");
  else
    printf("ERROR! Unexpected outputs!");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x48(%rbp)
lea    0xe98(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11af <main+0x6f>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1265 <main+0x125>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    11ed <main+0xad>
mov    -0x50(%rbp),%rdi
movslq -0x44(%rbp),%rax
lea    -0x40(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe56(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b6 <main+0x76>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    122e <main+0xee>
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
movslq -0x44(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
je     121b <main+0xdb>
movl   $0x0,-0x48(%rbp)
jmp    1220 <main+0xe0>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11f4 <main+0xb4>
cmpl   $0x1,-0x48(%rbp)
jne    1249 <main+0x109>
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
jmp    1255 <main+0x115>
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11fd <main+0xbd>
mov    %rax,%rbx
lea    0xebf(%rip),%r14
mov    %rsp,%rdx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
cmpl   $0x78d98,(%rsp)
movdqu 0x4(%rsp),%xmm0
pcmpeqd 0xe30(%rip),%xmm0
lea    0xe59(%rip),%rdi
lea    0xe64(%rip),%rax
cmovne %rax,%rdi
movmskps %xmm0,%ecx
cmp    $0xf,%ecx
cmovne %rax,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    120e <main+0xce>
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.expected_outputs = [5 x i32] [i32 495000, i32 430100, i32 7700, i32 0, i32 1225]
@.str = [7 x i8] c"output\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error opening file\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [18 x i8] c"Expected outputs!\00"
@.str.5 = [27 x i8] c"ERROR! Unexpected outputs!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
%7 = bitcast [5 x i32]* %2 to i8*
store i32 1, i32* %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %55
13: ; preds = %0
store i32 0, i32* %4
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i32*, i32** %6
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %20
%22 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %14
26: ; preds = %14
store i32 0, i32* %4
br label %27
27: ; preds = %42, %26
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 5
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp ne i32 %34, %38
br i1 %39, label %40, label %41
40: ; preds = %30
store i32 0, i32* %5
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %27
45: ; preds = %27
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %52
50: ; preds = %45
%51 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
store i32 0, i32* %1
br label %55
55: ; preds = %52, %11
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
@.str = [7 x i8] c"output\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error opening file\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [18 x i8] c"Expected outputs!\00"
@.str.5 = [27 x i8] c"ERROR! Unexpected outputs!\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %28, label %5
5: ; preds = %0
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%9 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%11 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%13 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%15 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 495000
%18 = bitcast i32* %8 to <4 x i32>*
%19 = load <4 x i32>, <4 x i32>* %18
%20 = freeze <4 x i32> %19
%21 = icmp ne <4 x i32> %20, <i32 430100, i32 7700, i32 0, i32 1225>
%22 = bitcast <4 x i1> %21 to i4
%23 = icmp eq i4 %22, 0
%24 = select i1 %23, i1 %17, i1 false
%25 = select i1 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0)
%26 = call i32 @printf(i8* dereferenceable(1) %25)
%27 = call i32 @fclose(i32* %3)
br label %30
28: ; preds = %0
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %5, %28
%31 = phi i32 [ 1, %28 ], [ 0, %5 ]
ret i32 %31
}