#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);
void dump_memory_structure_conv_to_file(float ***mem, int sh0, int sh1,
                                        int sh2) {
  FILE *out;
  int i, j, k;
  out = fopen("debug_c.txt", "w");
  for (i = 0; i < sh0; i++) {
    for (j = 0; j < sh1; j++) {
      for (k = 0; k < sh2; k++) {
        fprintf(out, "%.12lf\n", mem[i][j][k]);
      }
    }
  }
  fclose(out);
}


x86 assembly (clang, -O0):
<dump_memory_structure_conv_to_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    0xeb4(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f6 <dump_memory_structure_conv_to_file+0xc6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e3 <dump_memory_structure_conv_to_file+0xb3>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d0 <dump_memory_structure_conv_to_file+0xa0>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe51(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1189 <dump_memory_structure_conv_to_file+0x59>
jmp    11d5 <dump_memory_structure_conv_to_file+0xa5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1176 <dump_memory_structure_conv_to_file+0x46>
jmp    11e8 <dump_memory_structure_conv_to_file+0xb8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1163 <dump_memory_structure_conv_to_file+0x33>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_memory_structure_conv_to_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,0x4(%rsp)
mov    %edx,(%rsp)
mov    %esi,%r12d
mov    %rdi,0x18(%rsp)
lea    0xeac(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r13
test   %r12d,%r12d
jle    1209 <dump_memory_structure_conv_to_file+0xd9>
mov    %r12d,%eax
mov    %rax,0x8(%rsp)
mov    (%rsp),%eax
mov    %rax,0x10(%rsp)
mov    0x4(%rsp),%eax
xor    %ebx,%ebx
lea    0xe85(%rip),%rbp
mov    %rax,0x20(%rsp)
mov    0x18(%rsp),%r14
jmp    11ab <dump_memory_structure_conv_to_file+0x7b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
je     1209 <dump_memory_structure_conv_to_file+0xd9>
cmpl   $0x0,(%rsp)
jle    11a0 <dump_memory_structure_conv_to_file+0x70>
xor    %r15d,%r15d
jmp    11cb <dump_memory_structure_conv_to_file+0x9b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    0x10(%rsp),%r15
je     11a0 <dump_memory_structure_conv_to_file+0x70>
cmpl   $0x0,0x4(%rsp)
jle    11c0 <dump_memory_structure_conv_to_file+0x90>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbx,8),%rax
mov    (%rax,%r15,8),%rax
movss  (%rax,%r12,4),%xmm0
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <fprintf@plt>
mov    0x20(%rsp),%rax
add    $0x1,%r12
cmp    %r12,%rax
jne    11e0 <dump_memory_structure_conv_to_file+0xb0>
jmp    11c0 <dump_memory_structure_conv_to_file+0x90>
mov    %r13,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

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