#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*/ Associa_Valores_Array(int *, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int main() {
  int i;
  FILE *fp;
  int vetor1[500];
  Associa_Valores_Array(vetor1, 500);
  fp = fopen("arquivo_500_Decresc.bin", "wb");
  for (i = 0; i < 500; i++) {
    fwrite(&vetor1[i], sizeof(int), 1, fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7e0(%rbp),%rdi
mov    $0x1f4,%esi
call   1030 <Associa_Valores_Array@plt>
lea    0xea6(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jge    11b1 <main+0x81>
movslq -0x8(%rbp),%rax
lea    -0x7e0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x41>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    %rsp,%rdi
mov    $0x1f4,%esi
call   1030 <Associa_Valores_Array@plt>
lea    0xeb2(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
nop
lea    (%rsp,%rbx,1),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
add    $0x4,%rbx
cmp    $0x7d0,%rbx
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"arquivo_500_Decresc.bin\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca [500 x i32]
%2 = bitcast [500 x i32]* %1 to i8*
%3 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 0
%4 = call i32 @Associa_Valores_Array(i32* %3, i32 500)
%5 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %10, %6 ]
%8 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %7
%9 = call i32 @fwrite(i32* %8, i32 4, i32 1, i32* %5)
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i64 %10, 500
br i1 %11, label %12, label %6
12: ; preds = %6
ret i32 0
}