#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*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main() {
  int resist_array[8 * 5] = {
      5, 5, 5, 4, 4, 5, 5, 4, 4, 3, 5, 4, 4, 3, 3, 6, 4, 3, 3, 6,
      6, 4, 3, 3, 6, 5, 4, 4, 3, 3, 5, 5, 4, 4, 3, 5, 5, 5, 4, 4,
  };
  FILE *pFile;
  pFile = fopen("./5.lvl", "wb");
  if (!pFile) {
    printf("Unable to open file!");
    return 1;
  }
  fwrite(resist_array, sizeof(int), 8 * 5, pFile);
  fclose(pFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
lea    0xf1f(%rip),%rdi
lea    0xf20(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
jne    11ba <main+0x6a>
lea    0xf02(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ea <main+0x9a>
lea    -0xb0(%rbp),%rdi
mov    -0xb8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x28,%edx
call   1070 <fwrite@plt>
mov    -0xb8(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xa0,%rsp
lea    0xea1(%rip),%rsi
mov    %rsp,%rdi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
lea    0xf2d(%rip),%rdi
lea    0xf2e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a8 <main+0x58>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x28,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11b9 <main+0x69>
lea    0xefc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.resist_array = [40 x i32] [i32 5, i32 5, i32 5, i32 4, i32 4, i32 5, i32 5, i32 4, i32 4, i32 3, i32 5, i32 4, i32 4, i32 3, i32 3, i32 6, i32 4, i32 3, i32 3, i32 6, i32 6, i32 4, i32 3, i32 3, i32 6, i32 5, i32 4, i32 4, i32 3, i32 3, i32 5, i32 5, i32 4, i32 4, i32 3, i32 5, i32 5, i32 5, i32 4, i32 4]
@.str = [8 x i8] c"./5.lvl\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [21 x i8] c"Unable to open file!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i32]
%3 = alloca i32*
store i32 0, i32* %1
%4 = bitcast [40 x i32]* %2 to i8*
%5 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %16
10: ; preds = %0
%11 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32 @fwrite(i32* %11, i32 4, i32 40, i32* %12)
%14 = load i32*, i32** %3
%15 = call i32 @fclose(i32* %14)
store i32 0, i32* %1
br label %16
16: ; preds = %10, %8
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@__const.main.resist_array = [40 x i32] [i32 5, i32 5, i32 5, i32 4, i32 4, i32 5, i32 5, i32 4, i32 4, i32 3, i32 5, i32 4, i32 4, i32 3, i32 3, i32 6, i32 4, i32 3, i32 3, i32 6, i32 6, i32 4, i32 3, i32 3, i32 6, i32 5, i32 4, i32 4, i32 3, i32 3, i32 5, i32 5, i32 4, i32 4, i32 3, i32 5, i32 5, i32 5, i32 4, i32 4]
@.str = [8 x i8] c"./5.lvl\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [21 x i8] c"Unable to open file!\00"
define i32 @main() {
%1 = alloca [40 x i32]
%2 = bitcast [40 x i32]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %11
7: ; preds = %0
%8 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 0
%9 = call i32 @fwrite(i32* %8, i32 4, i32 40, i32* %3)
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %7, %5
%12 = phi i32 [ 0, %7 ], [ 1, %5 ]
ret i32 %12
}