#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*/ dump_int(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite_safe(float *, int, int, int /*<<< orphan*/ *);
void dump_2d_float_array(float **array, int dim1, int dim2, FILE *fp) {
  dump_int(dim1, fp);
  dump_int(dim2, fp);
  if (dim1 > 0 && dim2 > 0) {
    fwrite_safe(*array, sizeof(float), dim1 * dim2, fp);
  }
  return;
}


x86 assembly (clang, -O0):
<dump_2d_float_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <dump_int@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <dump_int@plt>
cmpl   $0x0,-0xc(%rbp)
jle    117e <dump_2d_float_array+0x5e>
cmpl   $0x0,-0x10(%rbp)
jle    117e <dump_2d_float_array+0x5e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0xc(%rbp),%edx
imul   -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fwrite_safe@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_2d_float_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
mov    %esi,%edi
mov    %rcx,%rsi
call   1030 <dump_int@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <dump_int@plt>
test   %ebx,%ebx
jle    116c <dump_2d_float_array+0x4c>
test   %ebp,%ebp
jle    116c <dump_2d_float_array+0x4c>
mov    (%r15),%rdi
imul   %ebx,%ebp
mov    $0x4,%esi
mov    %ebp,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite_safe@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dump_2d_float_array(float** %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca float**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store float** %0, float*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%9 = load i32, i32* %6
%10 = load i32*, i32** %8
%11 = call i32 @dump_int(i32 %9, i32* %10)
%12 = load i32, i32* %7
%13 = load i32*, i32** %8
%14 = call i32 @dump_int(i32 %12, i32* %13)
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %4
%18 = load i32, i32* %7
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load float**, float*** %5
%22 = load float*, float** %21
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = mul nsw i32 %23, %24
%26 = load i32*, i32** %8
%27 = call i32 @fwrite_safe(float* %22, i32 4, i32 %25, i32* %26)
br label %28
28: ; preds = %20, %17, %4
ret void
}

LLVM IR (-O2):
define void @dump_2d_float_array(float** nocapture %0, i32 %1, i32 %2, i32* %3) {
%5 = tail call i32 @dump_int(i32 %1, i32* %3)
%6 = tail call i32 @dump_int(i32 %2, i32* %3)
%7 = icmp sgt i32 %1, 0
%8 = icmp sgt i32 %2, 0
%9 = and i1 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load float*, float** %0
%12 = mul nsw i32 %2, %1
%13 = tail call i32 @fwrite_safe(float* %11, i32 4, i32 %12, i32* %3)
br label %14
14: ; preds = %10, %4
ret void
}