#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*/ *);
void main(int argc, char *argv[]) {
  FILE *fp;
  int a[800];
  int i, j;
  for (i = 0; i < 800; i++) {
    a[i] = 800 - i;
  }
  fp = fopen("binaryfile", "wb");
  fwrite(a, sizeof(int), 800, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xca4(%rbp)
cmpl   $0x320,-0xca4(%rbp)
jge    1189 <main+0x59>
mov    $0x320,%ecx
sub    -0xca4(%rbp),%ecx
movslq -0xca4(%rbp),%rax
mov    %ecx,-0xca0(%rbp,%rax,4)
mov    -0xca4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xca4(%rbp)
jmp    114c <main+0x1c>
lea    0xe70(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0xca0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
mov    $0x320,%edx
call   1050 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xcb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xc80,%rsp
movdqa 0xec0(%rip),%xmm0
mov    $0x1c,%eax
movdqa 0xec2(%rip),%xmm8
movdqa 0xec9(%rip),%xmm9
movdqa 0xed0(%rip),%xmm10
movdqa 0xed7(%rip),%xmm11
movdqa 0xedf(%rip),%xmm5
movdqa 0xee7(%rip),%xmm6
movdqa 0xeef(%rip),%xmm7
movdqa 0xef7(%rip),%xmm1
movdqa 0xeff(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqa %xmm8,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm9,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x70(%rsp,%rax,4)
movdqa %xmm4,-0x60(%rsp,%rax,4)
movdqa %xmm10,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm11,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x50(%rsp,%rax,4)
movdqa %xmm4,-0x40(%rsp,%rax,4)
movdqa %xmm5,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm6,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x30(%rsp,%rax,4)
movdqa %xmm4,-0x20(%rsp,%rax,4)
movdqa %xmm7,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm1,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x10(%rsp,%rax,4)
movdqa %xmm4,(%rsp,%rax,4)
paddd  %xmm2,%xmm0
add    $0x20,%rax
cmp    $0x33c,%rax
jne    11a0 <main+0x70>
lea    0xe72(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x320,%edx
mov    %rax,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
add    $0xc80,%rsp
pop    %rbx
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"binaryfile\00"
@.str.1 = [3 x i8] c"wb\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [800 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %7
br label %9
9: ; preds = %18, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 800
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %7
%14 = sub nsw i32 800, %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [800 x i32], [800 x i32]* %6, i64 0, i64 %16
store i32 %14, i32* %17
br label %18
18: ; preds = %12
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %9
21: ; preds = %9
%22 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %5
%23 = getelementptr inbounds [800 x i32], [800 x i32]* %6, i64 0, i64 0
%24 = load i32*, i32** %5
%25 = call i32 @fwrite(i32* %23, i32 4, i32 800, i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"binaryfile\00"
@.str.1 = [3 x i8] c"wb\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [800 x i32]
%4 = bitcast [800 x i32]* %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ 0, %2 ], [ %35, %5 ]
%7 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %36, %5 ]
%8 = getelementptr inbounds [800 x i32], [800 x i32]* %3, i64 0, i64 %6
%9 = sub <4 x i32> <i32 800, i32 800, i32 800, i32 800>, %7
%10 = sub <4 x i32> <i32 796, i32 796, i32 796, i32 796>, %7
%11 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %9, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %8, i64 4
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %13
%14 = or i64 %6, 8
%15 = getelementptr inbounds [800 x i32], [800 x i32]* %3, i64 0, i64 %14
%16 = sub <4 x i32> <i32 792, i32 792, i32 792, i32 792>, %7
%17 = sub <4 x i32> <i32 788, i32 788, i32 788, i32 788>, %7
%18 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %18
%19 = getelementptr inbounds i32, i32* %15, i64 4
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %20
%21 = or i64 %6, 16
%22 = getelementptr inbounds [800 x i32], [800 x i32]* %3, i64 0, i64 %21
%23 = sub <4 x i32> <i32 784, i32 784, i32 784, i32 784>, %7
%24 = sub <4 x i32> <i32 780, i32 780, i32 780, i32 780>, %7
%25 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %23, <4 x i32>* %25
%26 = getelementptr inbounds i32, i32* %22, i64 4
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %27
%28 = or i64 %6, 24
%29 = getelementptr inbounds [800 x i32], [800 x i32]* %3, i64 0, i64 %28
%30 = sub <4 x i32> <i32 776, i32 776, i32 776, i32 776>, %7
%31 = sub <4 x i32> <i32 772, i32 772, i32 772, i32 772>, %7
%32 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %32
%33 = getelementptr inbounds i32, i32* %29, i64 4
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %34
%35 = add nuw nsw i64 %6, 32
%36 = add <4 x i32> %7, <i32 32, i32 32, i32 32, i32 32>
%37 = icmp eq i64 %35, 800
br i1 %37, label %38, label %5
38: ; preds = %5
%39 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%40 = getelementptr inbounds [800 x i32], [800 x i32]* %3, i64 0, i64 0
%41 = call i32 @fwrite(i32* %40, i32 4, i32 800, i32* %39)
%42 = tail call i32 @fclose(i32* %39)
ret void
}