#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, float, float,
                           float);
int /*<<< orphan*/ printf(char *, char *);
void write_data(char file[200], float METDATA[4749][4]) {
  FILE *fp;
  int i;
  if ((fp = fopen(file, "w")) == NULL) {
    printf("Cannot open file %s \n", file);
    exit(0);
  }
  for (i = 0; i < 4749; i++) {
    fprintf(fp, "%6.2f %6.2f %6.2f %6.2f\n", METDATA[i][0], METDATA[i][1],
            METDATA[i][2], METDATA[i][3]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<write_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1195 <write_data+0x45>
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x128d,-0x1c(%rbp)
jge    1216 <write_data+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movss  0x4(%rax),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movss  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movss  0xc(%rax),%xmm3
lea    0xe15(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119c <write_data+0x4c>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r15
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c6 <write_data+0x76>
mov    %rax,%r14
mov    $0xc,%ebx
lea    0xe9a(%rip),%r15
xchg   %ax,%ax
movss  -0xc(%r12,%rbx,1),%xmm0
movss  -0x8(%r12,%rbx,1),%xmm1
movss  -0x4(%r12,%rbx,1),%xmm2
movss  (%r12,%rbx,1),%xmm3
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fprintf@plt>
add    $0x10,%rbx
cmp    $0x128dc,%rbx
jne    1180 <write_data+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
lea    0xe35(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [25 x i8] c"%6.2f %6.2f %6.2f %6.2f\0A\00"
define void @write_data(i8* %0, [4 x float]* %1) {
%3 = alloca i8*
%4 = alloca [4 x float]*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store [4 x float]* %1, [4 x float]** %4
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
store i32 0, i32* %6
br label %15
15: ; preds = %45, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 4749
br i1 %17, label %18, label %48
18: ; preds = %15
%19 = load i32*, i32** %5
%20 = load [4 x float]*, [4 x float]** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x float], [4 x float]* %20, i64 %22
%24 = getelementptr inbounds [4 x float], [4 x float]* %23, i64 0, i64 0
%25 = load float, float* %24
%26 = load [4 x float]*, [4 x float]** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x float], [4 x float]* %26, i64 %28
%30 = getelementptr inbounds [4 x float], [4 x float]* %29, i64 0, i64 1
%31 = load float, float* %30
%32 = load [4 x float]*, [4 x float]** %4
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x float], [4 x float]* %32, i64 %34
%36 = getelementptr inbounds [4 x float], [4 x float]* %35, i64 0, i64 2
%37 = load float, float* %36
%38 = load [4 x float]*, [4 x float]** %4
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x float], [4 x float]* %38, i64 %40
%42 = getelementptr inbounds [4 x float], [4 x float]* %41, i64 0, i64 3
%43 = load float, float* %42
%44 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), float %25, float %31, float %37, float %43)
br label %45
45: ; preds = %18
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %15
48: ; preds = %15
%49 = load i32*, i32** %5
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [25 x i8] c"%6.2f %6.2f %6.2f %6.2f\0A\00"
define void @write_data(i8* %0, [4 x float]* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2, %8
%9 = phi i64 [ %19, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 0
%11 = load float, float* %10
%12 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 1
%13 = load float, float* %12
%14 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 2
%15 = load float, float* %14
%16 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 %9, i64 3
%17 = load float, float* %16
%18 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), float %11, float %13, float %15, float %17)
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, 4749
br i1 %20, label %21, label %8
21: ; preds = %8
%22 = tail call i32 @fclose(i32* %3)
ret void
}