#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[5], b[5];
  int i, size = sizeof(int);
  FILE *fp;
  if ((fp = fopen("/home/gerry/ssh3", "rb+")) == NULL) {
    printf("cannot open file, press any key to exit!\n");
    getchar();
    exit(1);
  }
  for (i = 0; i < 5; i++) {
    scanf("%d", &a[i]);
  }
  rewind(fp);
  fread(b, size, 5, fp);
  for (i = 0; i < 5; i++) {
    printf("%d", b[i]);
  }
  printf("\n");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x48(%rbp)
lea    0xe63(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    11d6 <main+0x56>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    1210 <main+0x90>
movslq -0x44(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe42(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11dd <main+0x5d>
mov    -0x50(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
mov    -0x50(%rbp),%rcx
mov    $0x5,%edx
call   1030 <fread@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    1263 <main+0xe3>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1235 <main+0xb5>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xe52(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     128c <main+0xec>
mov    %rax,%r14
lea    0xe48(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
mov    %r14,%rdi
call   1080 <rewind@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd85(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/home/gerry/ssh3\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [42 x i8] c"cannot open file, press any key to exit!\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"\0A\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
store i32 4, i32* %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (...) @getchar()
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
store i32 0, i32* %4
br label %14
14: ; preds = %22, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %14
25: ; preds = %14
%26 = load i32*, i32** %6
%27 = call i32 @rewind(i32* %26)
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %5
%30 = load i32*, i32** %6
%31 = call i32 @fread(i32* %28, i32 %29, i32 5, i32* %30)
store i32 0, i32* %4
br label %32
32: ; preds = %41, %25
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 5
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %32
44: ; preds = %32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"/home/gerry/ssh3\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.3 = [3 x i8] c"%d\00"
@str = [41 x i8] c"cannot open file, press any key to exit!\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %37, label %7
7: ; preds = %0
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %16)
%18 = call i32 @rewind(i32* %5)
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%20 = call i32 @fread(i32* %19, i32 4, i32 5, i32* %5)
%21 = load i32, i32* %19
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 4
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = call i32 @putchar(i32 10)
%36 = call i32 @fclose(i32* %5)
ret i32 0
37: ; preds = %0
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%39 = tail call i32 (...) @getchar()
%40 = tail call i32 @exit(i32 1)
unreachable
}