#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*/ *);
short fgetshi(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[], char *env[]) {
  FILE *f = fopen(argv[1], "r+");
  short int T[7];
  for (int i = 0; i < 7; i++) {
    T[i] = fgetshi(f);
    if (T[i] == 16777470)
      T[i] = -1;
    printf("%i ", T[i]);
  }
  printf("\n");
  fclose(f);
}


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)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x7,-0x34(%rbp)
jge    11dc <main+0x9c>
mov    -0x20(%rbp),%rdi
call   1030 <fgetshi@plt>
mov    %ax,%cx
movslq -0x34(%rbp),%rax
mov    %cx,-0x2e(%rbp,%rax,2)
movslq -0x34(%rbp),%rax
movswl -0x2e(%rbp,%rax,2),%eax
cmp    $0x10000fe,%eax
jne    11b7 <main+0x77>
movslq -0x34(%rbp),%rax
movw   $0xffff,-0x2e(%rbp,%rax,2)
movslq -0x34(%rbp),%rax
movswl -0x2e(%rbp,%rax,2),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1179 <main+0x39>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
lea    0xe8a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetshi@plt>
movswl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca [7 x i16]
%10 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %8
store i32 0, i32* %10
br label %15
15: ; preds = %41, %3
%16 = load i32, i32* %10
%17 = icmp slt i32 %16, 7
br i1 %17, label %18, label %44
18: ; preds = %15
%19 = load i32*, i32** %8
%20 = call signext i16 @fgetshi(i32* %19)
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [7 x i16], [7 x i16]* %9, i64 0, i64 %22
store i16 %20, i16* %23
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [7 x i16], [7 x i16]* %9, i64 0, i64 %25
%27 = load i16, i16* %26
%28 = sext i16 %27 to i32
%29 = icmp eq i32 %28, 16777470
br i1 %29, label %30, label %34
30: ; preds = %18
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [7 x i16], [7 x i16]* %9, i64 0, i64 %32
store i16 -1, i16* %33
br label %34
34: ; preds = %30, %18
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [7 x i16], [7 x i16]* %9, i64 0, i64 %36
%38 = load i16, i16* %37
%39 = sext i16 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %15
44: ; preds = %15
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32*, i32** %8
%47 = call i32 @fclose(i32* %46)
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@.str.1 = [4 x i8] c"%i \00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = tail call signext i16 @fgetshi(i32* %6)
%8 = sext i16 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call signext i16 @fgetshi(i32* %6)
%11 = sext i16 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call signext i16 @fgetshi(i32* %6)
%14 = sext i16 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call signext i16 @fgetshi(i32* %6)
%17 = sext i16 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = tail call signext i16 @fgetshi(i32* %6)
%20 = sext i16 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = tail call signext i16 @fgetshi(i32* %6)
%23 = sext i16 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = tail call signext i16 @fgetshi(i32* %6)
%26 = sext i16 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = tail call i32 @putchar(i32 10)
%29 = tail call i32 @fclose(i32* %6)
ret i32 0
}