#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*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void matrixWriteToFile(FILE *file, double **matrix, int n0, int n1) {
  int i, j;
  char line_for_output[10000];
  sprintf(line_for_output, "[");
  fputs(line_for_output, file);
  for (i = 0; i < n0; i++) {
    sprintf(line_for_output, "[");
    fputs(line_for_output, file);
    for (j = 0; j < n1; j++) {
      sprintf(line_for_output, "%lf", matrix[i][j]);
      fputs(line_for_output, file);
      if (j < n1 - 1) {
        sprintf(line_for_output, ", ");
        fputs(line_for_output, file);
      }
    }
    if (i == n0 - 1)
      sprintf(line_for_output, "]");
    else
      sprintf(line_for_output, "];");
    fputs(line_for_output, file);
  }
  sprintf(line_for_output, "]\n");
  fputs(line_for_output, file);
}


x86 assembly (clang, -O0):
<matrixWriteToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
lea    -0x2730(%rbp),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128a <matrixWriteToFile+0x16a>
lea    -0x2730(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122c <matrixWriteToFile+0x10c>
lea    -0x2730(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe36(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1219 <matrixWriteToFile+0xf9>
lea    -0x2730(%rbp),%rdi
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
jmp    121e <matrixWriteToFile+0xfe>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119d <matrixWriteToFile+0x7d>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1257 <matrixWriteToFile+0x137>
lea    -0x2730(%rbp),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    126c <matrixWriteToFile+0x14c>
lea    -0x2730(%rbp),%rdi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <matrixWriteToFile+0x45>
lea    -0x2730(%rbp),%rdi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixWriteToFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2738,%rsp
mov    %rcx,(%rsp)
mov    %edx,%ebx
mov    %rsi,0x18(%rsp)
mov    %rdi,%r12
movw   $0x5b,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
test   %ebx,%ebx
jle    1247 <matrixWriteToFile+0x127>
mov    (%rsp),%rcx
lea    -0x1(%rcx),%eax
lea    -0x1(%rbx),%edx
mov    %rdx,0x10(%rsp)
movslq %eax,%r14
mov    %ebx,%eax
mov    %rax,0x8(%rsp)
mov    %ecx,%ebp
xor    %r13d,%r13d
lea    0x20(%rsp),%rbx
jmp    11a6 <matrixWriteToFile+0x86>
movb   $0x0,0x22(%rsp)
movw   $0x3b5d,0x20(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
add    $0x1,%r13
cmp    0x8(%rsp),%r13
je     1247 <matrixWriteToFile+0x127>
movw   $0x5b,0x20(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
cmpl   $0x0,(%rsp)
jle    1230 <matrixWriteToFile+0x110>
xor    %r15d,%r15d
jmp    11d9 <matrixWriteToFile+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r15
cmp    %r15,%rbp
je     1230 <matrixWriteToFile+0x110>
mov    0x18(%rsp),%rax
mov    (%rax,%r13,8),%rax
movsd  (%rax,%r15,8),%xmm0
mov    %rbx,%rdi
lea    0xe0e(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
cmp    %r14,%r15
jge    11d0 <matrixWriteToFile+0xb0>
movb   $0x0,0x22(%rsp)
movw   $0x202c,0x20(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
jmp    11d0 <matrixWriteToFile+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    0x10(%rsp),%r13
jne    1180 <matrixWriteToFile+0x60>
movw   $0x5d,0x20(%rsp)
jmp    118c <matrixWriteToFile+0x6c>
movb   $0x0,0x22(%rsp)
movw   $0xa5d,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
add    $0x2738,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [2 x i8] c"]\00"
@.str.4 = [3 x i8] c"];\00"
@.str.5 = [3 x i8] c"]\0A\00"
define void @matrixWriteToFile(i32* %0, double** %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10000 x i8]
store i32* %0, i32** %5
store double** %1, double*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = call i32 @fputs(i8* %14, i32* %15)
store i32 0, i32* %9
br label %17
17: ; preds = %75, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %78
21: ; preds = %17
%22 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%25 = load i32*, i32** %5
%26 = call i32 @fputs(i8* %24, i32* %25)
store i32 0, i32* %10
br label %27
27: ; preds = %57, %21
%28 = load i32, i32* %10
%29 = load i32, i32* %8
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %60
31: ; preds = %27
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%33 = load double**, double*** %6
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
%37 = load double*, double** %36
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %41)
%43 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%44 = load i32*, i32** %5
%45 = call i32 @fputs(i8* %43, i32* %44)
%46 = load i32, i32* %10
%47 = load i32, i32* %8
%48 = sub nsw i32 %47, 1
%49 = icmp slt i32 %46, %48
br i1 %49, label %50, label %56
50: ; preds = %31
%51 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%53 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%54 = load i32*, i32** %5
%55 = call i32 @fputs(i8* %53, i32* %54)
br label %56
56: ; preds = %50, %31
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %27
60: ; preds = %27
%61 = load i32, i32* %9
%62 = load i32, i32* %7
%63 = sub nsw i32 %62, 1
%64 = icmp eq i32 %61, %63
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %71
68: ; preds = %60
%69 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %68, %65
%72 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%73 = load i32*, i32** %5
%74 = call i32 @fputs(i8* %72, i32* %73)
br label %75
75: ; preds = %71
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 1
store i32 %77, i32* %9
br label %17
78: ; preds = %17
%79 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%80 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%81 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%82 = load i32*, i32** %5
%83 = call i32 @fputs(i8* %81, i32* %82)
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [3 x i8] c", \00"
@.str.4 = [3 x i8] c"];\00"
@.str.5 = [3 x i8] c"]\0A\00"
define void @matrixWriteToFile(i32* nocapture %0, double** nocapture %1, i32 %2, i32 %3) {
%5 = alloca [10000 x i8]
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%7 = bitcast [10000 x i8]* %5 to i16*
store i16 91, i16* %7
%8 = call i32 @fputs(i8* %6, i32* %0)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %44
10: ; preds = %4
%11 = icmp sgt i32 %3, 0
%12 = add nsw i32 %3, -1
%13 = add nsw i32 %2, -1
%14 = sext i32 %12 to i64
%15 = zext i32 %13 to i64
%16 = zext i32 %2 to i64
%17 = zext i32 %3 to i64
br label %18
18: ; preds = %10, %40
%19 = phi i64 [ 0, %10 ], [ %42, %40 ]
store i16 91, i16* %7
%20 = call i32 @fputs(i8* %6, i32* %0)
br i1 %11, label %21, label %36
21: ; preds = %18
%22 = getelementptr inbounds double*, double** %1, i64 %19
br label %23
23: ; preds = %21, %33
%24 = phi i64 [ 0, %21 ], [ %34, %33 ]
%25 = load double*, double** %22
%26 = getelementptr inbounds double, double* %25, i64 %24
%27 = load double, double* %26
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 @fputs(i8* %6, i32* %0)
%30 = icmp slt i64 %24, %14
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @fputs(i8* %6, i32* %0)
br label %33
33: ; preds = %23, %31
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, %17
br i1 %35, label %36, label %23
36: ; preds = %33, %18
%37 = icmp eq i64 %19, %15
br i1 %37, label %38, label %39
38: ; preds = %36
store i16 93, i16* %7
br label %40
39: ; preds = %36
br label %40
40: ; preds = %39, %38
%41 = call i32 @fputs(i8* %6, i32* %0)
%42 = add nuw nsw i64 %19, 1
%43 = icmp eq i64 %42, %16
br i1 %43, label %44, label %18
44: ; preds = %40, %4
%45 = call i32 @fputs(i8* %6, i32* %0)
ret void
}