#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 float uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(float *, int, float, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void outputData(char *fName, float *h_A0, int nx, int ny, int nz) {
  FILE *fid = fopen(fName, "w");
  uint32_t tmp32;
  if (fid == NULL) {
    fprintf(stderr, "Cannot open output file\n");
    exit(-1);
  }
  tmp32 = nx * ny * nz;
  fwrite(&tmp32, sizeof(uint32_t), 1, fid);
  fwrite(h_A0, sizeof(float), tmp32, fid);
  fclose(fid);
}


x86 assembly (clang, -O0):
<outputData>:
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    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a8 <outputData+0x58>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
movss  0xe2f(%rip),%xmm0
call   1070 <fwrite@plt>
mov    -0x10(%rbp),%rdi
movss  -0x2c(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
call   1070 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %rsi,%r14
lea    0xe96(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d2 <outputData+0x82>
mov    %rax,%rbx
imul   %r12d,%ebp
imul   %r15d,%ebp
cvtsi2ss %ebp,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xc(%rsp),%rdi
movss  0xe66(%rip),%xmm0
mov    $0x4,%esi
mov    %rax,%rdx
call   1070 <fwrite@plt>
movss  0xc(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Cannot open output file\0A\00"
define void @outputData(i8* %0, float* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca float
store i8* %0, i8** %6
store float* %1, float** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %11
%15 = load i32*, i32** %11
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %5
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %5
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = mul nsw i32 %22, %23
%25 = load i32, i32* %10
%26 = mul nsw i32 %24, %25
%27 = sitofp i32 %26 to float
store float %27, float* %12
%28 = load i32*, i32** %11
%29 = call i32 @fwrite(float* %12, i32 4, float 1.000000e+00, i32* %28)
%30 = load float*, float** %7
%31 = load float, float* %12
%32 = load i32*, i32** %11
%33 = call i32 @fwrite(float* %30, i32 4, float %31, i32* %32)
%34 = load i32*, i32** %11
%35 = call i32 @fclose(i32* %34)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Cannot open output file\0A\00"
define void @outputData(i8* nocapture %0, float* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca float
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = bitcast float* %6 to i8*
%9 = icmp eq i32* %7, null
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %5
%15 = mul nsw i32 %3, %2
%16 = mul nsw i32 %15, %4
%17 = sitofp i32 %16 to float
store float %17, float* %6
%18 = call i32 @fwrite(float* %6, i32 4, float 1.000000e+00, i32* %7)
%19 = load float, float* %6
%20 = call i32 @fwrite(float* %1, i32 4, float %19, i32* %7)
%21 = call i32 @fclose(i32* %7)
ret void
}