#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void write_csv(int x, int y, float **array, FILE *fp) {
  int i = 0, j = 0;
  for (i = 0; i < x; i++) {
    for (j = 0; j < y; j++) {
      fprintf(fp, "%.6e, ", array[i][j]);
    }
    fprintf(fp, "\n");
  }
}


x86 assembly (clang, -O0):
<write_csv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b3 <write_csv+0xa3>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1193 <write_csv+0x83>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe82(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <write_csv+0x3e>
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <write_csv+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_csv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
test   %edi,%edi
jle    11b6 <write_csv+0x96>
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %edi,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebp
xor    %r15d,%r15d
lea    0xeab(%rip),%r13
jmp    1178 <write_csv+0x58>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r15
cmp    0x10(%rsp),%r15
je     11b6 <write_csv+0x96>
cmpl   $0x0,0xc(%rsp)
jle    1160 <write_csv+0x40>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%r15,8),%rax
movss  (%rax,%r12,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1190 <write_csv+0x70>
jmp    1160 <write_csv+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%.6e, \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @write_csv(i32 %0, i32 %1, float** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store float** %2, float*** %7
store i32* %3, i32** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %9
br label %11
11: ; preds = %39, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %42
15: ; preds = %11
store i32 0, i32* %10
br label %16
16: ; preds = %33, %15
%17 = load i32, i32* %10
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i32*, i32** %8
%22 = load float**, float*** %7
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float*, float** %22, i64 %24
%26 = load float*, float** %25
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %31)
br label %33
33: ; preds = %20
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %16
36: ; preds = %16
%37 = load i32*, i32** %8
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %36
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %11
42: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.6e, \00"
define void @write_csv(i32 %0, i32 %1, float** nocapture %2, i32* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %27
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %23
%11 = phi i64 [ 0, %6 ], [ %25, %23 ]
br i1 %7, label %12, label %23
12: ; preds = %10
%13 = getelementptr inbounds float*, float** %2, i64 %11
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %21, %14 ]
%16 = load float*, float** %13
%17 = getelementptr inbounds float, float* %16, i64 %15
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %19)
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, %9
br i1 %22, label %23, label %14
23: ; preds = %14, %10
%24 = tail call i32 @fputc(i32 10, i32* %3)
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %10
27: ; preds = %23, %4
ret void
}