#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 uint16_t;
typedef int /*<<< orphan*/ buffer;
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 main(void) {
  uint16_t buffer[] = {1, 5, 9, 1, 2, 14, 1, 3, 9,  1, 4, 7,  2, 5, 9,
                       3, 2, 2, 3, 6, 11, 4, 3, 10, 4, 6, 15, 6, 5, 6};
  FILE *f = fopen("../data/map.bin", "w");
  int i = 0;
  for (; i < sizeof(buffer) / sizeof(*buffer); ++i) {
    fwrite(buffer + i, sizeof(*buffer), 1, f);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x78,%edx
call   1040 <memcpy@plt>
lea    0xf0a(%rip),%rdi
lea    0xf13(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movslq -0x8c(%rbp),%rax
cmp    $0x1e,%rax
jae    11d8 <main+0x98>
lea    -0x80(%rbp),%rdi
movslq -0x8c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x88(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    118b <main+0x4b>
mov    -0x88(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    0xf32(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xf16(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xefa(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe6e(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xedb(%rip),%rdi
lea    0xee4(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
add    $0x4,%rbx
cmp    $0x78,%rbx
jne    11b0 <main+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.buffer = [30 x i32] [i32 1, i32 5, i32 9, i32 1, i32 2, i32 14, i32 1, i32 3, i32 9, i32 1, i32 4, i32 7, i32 2, i32 5, i32 9, i32 3, i32 2, i32 2, i32 3, i32 6, i32 11, i32 4, i32 3, i32 10, i32 4, i32 6, i32 15, i32 6, i32 5, i32 6]
@.str = [16 x i8] c"../data/map.bin\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [30 x i32]* %2 to i8*
%6 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
store i32 0, i32* %4
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 30
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32*, i32** %3
%17 = call i32 @fwrite(i32* %15, i32 4, i32 1, i32* %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %7
21: ; preds = %7
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buffer = [30 x i32] [i32 1, i32 5, i32 9, i32 1, i32 2, i32 14, i32 1, i32 3, i32 9, i32 1, i32 4, i32 7, i32 2, i32 5, i32 9, i32 3, i32 2, i32 2, i32 3, i32 6, i32 11, i32 4, i32 3, i32 10, i32 4, i32 6, i32 15, i32 6, i32 5, i32 6]
@.str = [16 x i8] c"../data/map.bin\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %8, %4 ]
%6 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %5
%7 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32* %3)
%8 = add nuw nsw i64 %5, 1
%9 = icmp eq i64 %8, 30
br i1 %9, label %10, label %4
10: ; preds = %4
%11 = tail call i32 @fclose(i32* %3)
ret i32 0
}