#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void debug_dump_octave_matrix(char *name, float *m, int w, int h) {
  FILE *out;
  out = fopen(name, "w");
  for (int i = 0; i < h; i++, fputc('\n', out))
    for (int j = 0; j < w; j++)
      fprintf(out, "%f%s", m[j + i * w], (j == w - 1) ? "" : "\t");
  fclose(out);
}


x86 assembly (clang, -O0):
<debug_dump_octave_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1204 <debug_dump_octave_matrix+0xc4>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e3 <debug_dump_octave_matrix+0xa3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%ecx
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
lea    0xe4b(%rip),%rdx
lea    0xe45(%rip),%rax
cmp    %esi,%ecx
cmove  %rax,%rdx
lea    0xe32(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1184 <debug_dump_octave_matrix+0x44>
jmp    11e8 <debug_dump_octave_matrix+0xa8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1040 <fputc@plt>
jmp    1171 <debug_dump_octave_matrix+0x31>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_dump_octave_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%ebp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r14
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
test   %ebp,%ebp
jle    1238 <debug_dump_octave_matrix+0xf8>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%ebx
cltq
mov    %ebp,%ecx
mov    %rcx,0x10(%rsp)
mov    %eax,%r15d
shl    $0x2,%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
mov    %rbx,0x28(%rsp)
jmp    11c2 <debug_dump_octave_matrix+0x82>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x20(%rsp),%rbp
add    $0x1,%rbp
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
add    0x18(%rsp),%r14
cmp    0x10(%rsp),%rbp
je     1238 <debug_dump_octave_matrix+0xf8>
mov    %rbp,0x20(%rsp)
cmpl   $0x0,0x8(%rsp)
lea    0xe35(%rip),%rax
lea    0xe2d(%rip),%rcx
lea    0xe21(%rip),%rsi
jle    11a0 <debug_dump_octave_matrix+0x60>
xor    %r13d,%r13d
mov    %r14,0x30(%rsp)
nopl   0x0(%rax,%rax,1)
movss  (%r14,%r13,4),%xmm0
cmp    %r13,%rbx
mov    %r15,%rbx
mov    %rcx,%r15
mov    %rcx,%rdx
cmove  %rax,%rdx
mov    %r12,%rdi
mov    %rax,%rbp
mov    %rsi,%r14
call   1050 <fprintf@plt>
mov    %r14,%rsi
mov    %r15,%rcx
mov    %rbx,%r15
mov    0x30(%rsp),%r14
mov    0x28(%rsp),%rbx
mov    %rbp,%rax
add    $0x1,%r13
cmp    %r13,%r15
jne    11f0 <debug_dump_octave_matrix+0xb0>
jmp    11a0 <debug_dump_octave_matrix+0x60>
mov    %r12,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [5 x i8] c"%f%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"\09\00"
define void @debug_dump_octave_matrix(i8* nocapture %0, float* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = icmp sgt i32 %2, 0
%9 = add nsw i32 %2, -1
%10 = zext i32 %9 to i64
%11 = sext i32 %2 to i64
%12 = zext i32 %3 to i64
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %7, %20
%15 = phi i64 [ 0, %7 ], [ %21, %20 ]
br i1 %8, label %16, label %20
16: ; preds = %14
%17 = mul nsw i64 %15, %11
br label %24
18: ; preds = %20, %4
%19 = tail call i32 @fclose(i32* %5)
ret void
20: ; preds = %24, %14
%21 = add nuw nsw i64 %15, 1
%22 = tail call i32 @fputc(i8 signext 10, i32* %5)
%23 = icmp eq i64 %21, %12
br i1 %23, label %18, label %14
24: ; preds = %16, %24
%25 = phi i64 [ 0, %16 ], [ %32, %24 ]
%26 = add nsw i64 %25, %17
%27 = getelementptr inbounds float, float* %1, i64 %26
%28 = load float, float* %27
%29 = icmp eq i64 %25, %10
%30 = select i1 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%31 = tail call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %28, i8* %30)
%32 = add nuw nsw i64 %25, 1
%33 = icmp eq i64 %32, %13
br i1 %33, label %20, label %24
}