#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*/ fwrite(double *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_file(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int /*<<< orphan*/);
void output(double *q, int nx, int ny, int nz, char *name) {
  FILE *f;
  char filename[512];
  int i, j, k;
  sprintf(filename, "%s%06d.dat", name, 0);
  f = open_file(name, 0, "w");
  fwrite(q, sizeof(double) * nx * ny * nz, 1, f);
  printf("Subdivision de %s OK\n", filename);
  fclose(f);
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe82(%rip),%rsi
xor    %ecx,%ecx
call   1060 <sprintf@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
lea    0xe79(%rip),%rdx
call   1040 <open_file@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
movslq -0x14(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1070 <fwrite@plt>
lea    -0x230(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r13
lea    0xe8a(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r8,%rdx
xor    %ecx,%ecx
call   1060 <sprintf@plt>
lea    0xe7e(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <open_file@plt>
mov    %rax,%rbx
imul   %r12d,%ebp
imul   %r15d,%ebp
shl    $0x3,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xe4f(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s%06d.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"Subdivision de %s OK\0A\00"
define void @output(double* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca [512 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%17 = load i8*, i8** %10
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17, i32 0)
%19 = load i8*, i8** %10
%20 = call i32* @open_file(i8* %19, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %11
%21 = load double*, double** %6
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = mul i64 8, %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = mul i64 %24, %26
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = mul i64 %27, %29
%31 = trunc i64 %30 to i32
%32 = load i32*, i32** %11
%33 = call i32 @fwrite(double* %21, i32 %31, i32 1, i32* %32)
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32*, i32** %11
%37 = call i32 @fclose(i32* %36)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s%06d.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"Subdivision de %s OK\0A\00"
define void @output(double* nocapture %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4, i32 0)
%9 = tail call i32* @open_file(i8* %4, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = shl i32 %1, 3
%11 = mul i32 %10, %2
%12 = mul i32 %11, %3
%13 = tail call i32 @fwrite(double* %0, i32 %12, i32 1, i32* %9)
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%15 = call i32 @fclose(i32* %9)
ret void
}