#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 *, ...);
int /*<<< orphan*/ *stderr;
void AdjacencyMatrix_writeToFile(FILE *out, float *matrix, size_t n) {
  size_t i, j;
  if (!(n && matrix)) {
    fprintf(stderr, "AdjacencyMatrix_writeToFile() : "
                    "Matrix not initialized.\n");
    return;
  }
  fprintf(out, "%zu\n", n);
  for (i = 0; i < n; i++) {
    fprintf(out, "%zu", i + 1);
    for (j = 0; j < n; j++)
      fprintf(out, "\t%.1f", matrix[i * n + j]);
    fprintf(out, "\n");
  }
}


x86 assembly (clang, -O0):
<AdjacencyMatrix_writeToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     113a <AdjacencyMatrix_writeToFile+0x2a>
cmpq   $0x0,-0x10(%rbp)
jne    1157 <AdjacencyMatrix_writeToFile+0x47>
mov    0x2e9f(%rip),%rax
mov    (%rax),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1213 <AdjacencyMatrix_writeToFile+0x103>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xed3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1213 <AdjacencyMatrix_writeToFile+0x103>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
add    $0x1,%rdx
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11f0 <AdjacencyMatrix_writeToFile+0xe0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
imul   -0x18(%rbp),%rcx
add    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6a(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11a5 <AdjacencyMatrix_writeToFile+0x95>
mov    -0x8(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1175 <AdjacencyMatrix_writeToFile+0x65>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AdjacencyMatrix_writeToFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11e5 <AdjacencyMatrix_writeToFile+0xb5>
mov    %rdx,%r14
test   %rdx,%rdx
je     11e5 <AdjacencyMatrix_writeToFile+0xb5>
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xedc(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x0(,%r14,4),%rax
mov    %rax,(%rsp)
lea    0xec8(%rip),%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
add    $0x1,%rbp
mov    %r15,%rdi
lea    0xeb0(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
movss  (%rbx,%r12,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    11a0 <AdjacencyMatrix_writeToFile+0x70>
mov    $0xa,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    (%rsp),%rbx
cmp    %r14,%rbp
jne    1180 <AdjacencyMatrix_writeToFile+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df4(%rip),%rax
mov    (%rax),%rcx
lea    0xe0a(%rip),%rdi
mov    $0x38,%esi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [57 x i8] c"AdjacencyMatrix_writeToFile() : Matrix not initialized.\0A\00"
@.str.1 = [5 x i8] c"%zu\0A\00"
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [6 x i8] c"\09%.1f\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @AdjacencyMatrix_writeToFile(i32* %0, float* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca float*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %4
store float* %1, float** %5
store i64 %2, i64* %6
%9 = load i64, i64* %6
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load float*, float** %5
%13 = icmp ne float* %12, null
br i1 %13, label %17, label %14
14: ; preds = %11, %3
%15 = load i32*, i32** @stderr
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %55
17: ; preds = %11
%18 = load i32*, i32** %4
%19 = load i64, i64* %6
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %19)
store i64 0, i64* %7
br label %21
21: ; preds = %52, %17
%22 = load i64, i64* %7
%23 = load i64, i64* %6
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %55
25: ; preds = %21
%26 = load i32*, i32** %4
%27 = load i64, i64* %7
%28 = add i64 %27, 1
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %28)
store i64 0, i64* %8
br label %30
30: ; preds = %46, %25
%31 = load i64, i64* %8
%32 = load i64, i64* %6
%33 = icmp ult i64 %31, %32
br i1 %33, label %34, label %49
34: ; preds = %30
%35 = load i32*, i32** %4
%36 = load float*, float** %5
%37 = load i64, i64* %7
%38 = load i64, i64* %6
%39 = mul i64 %37, %38
%40 = load i64, i64* %8
%41 = add i64 %39, %40
%42 = getelementptr inbounds float, float* %36, i64 %41
%43 = load float, float* %42
%44 = fpext float %43 to double
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %44)
br label %46
46: ; preds = %34
%47 = load i64, i64* %8
%48 = add i64 %47, 1
store i64 %48, i64* %8
br label %30
49: ; preds = %30
%50 = load i32*, i32** %4
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %49
%53 = load i64, i64* %7
%54 = add i64 %53, 1
store i64 %54, i64* %7
br label %21
55: ; preds = %14, %21
ret void
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [57 x i8] c"AdjacencyMatrix_writeToFile() : Matrix not initialized.\0A\00"
@.str.1 = [5 x i8] c"%zu\0A\00"
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [6 x i8] c"\09%.1f\00"
define void @AdjacencyMatrix_writeToFile(i32* nocapture %0, float* %1, i64 %2) {
%4 = icmp ne i64 %2, 0
%5 = icmp ne float* %1, null
%6 = and i1 %5, %4
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = load i32*, i32** @stderr
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 56, i64 1, i32* %8)
br label %29
10: ; preds = %3
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %2)
br label %12
12: ; preds = %10, %26
%13 = phi i64 [ %14, %26 ], [ 0, %10 ]
%14 = add nuw i64 %13, 1
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = mul i64 %13, %2
br label %17
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %24, %17 ]
%19 = add i64 %18, %16
%20 = getelementptr inbounds float, float* %1, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %22)
%24 = add nuw i64 %18, 1
%25 = icmp eq i64 %24, %2
br i1 %25, label %26, label %17
26: ; preds = %17
%27 = tail call i32 @fputc(i32 10, i32* %0)
%28 = icmp eq i64 %14, %2
br i1 %28, label %29, label %12
29: ; preds = %26, %7
ret void
}