#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 *, ...);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ fwrite(double *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
void dump_velocity_c(char *dname, char *fname, int nx, int ny, int nz,
                     double *array) {
  int i, j, k;
  FILE *fp;
  char errmsg[256];
  char buf[256];
  double *wbuf;
  snprintf(buf, 256, "%s/%s.bov", dname, fname);
  fp = fopen(buf, "wb");
  if (fp == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to create BOV file (%s)", buf);
    perror(errmsg);
    return;
  }
  snprintf(buf, 256, "%s.dat", fname);
  fprintf(fp, "VARIABLE: velocity\n");
  fprintf(fp, "DATA_FILE: %s\n", buf);
  fprintf(fp, "DATA_SIZE: %d %d %d\n", nx, ny, nz);
  fprintf(fp, "DATA_COMPONENTS: 3\n");
  fprintf(fp, "DATA_FORMAT: DOUBLE\n");
  fprintf(fp, "DATA_ENDIAN: LITTLE\n");
  fclose(fp);
  snprintf(buf, 256, "%s/%s.dat", dname, fname);
  fp = fopen(buf, "wb");
  if (fp == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to create DAT file (%s)", buf);
    perror(errmsg);
    return;
  }
  wbuf = (double *)malloc(3 * nx * ny * nz * sizeof(double));
  if (wbuf == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to allocate write buffer");
    perror(errmsg);
    return;
  }
  for (i = 0; i < 3 * nx * ny * nz; i++)
    wbuf[i] = array[2 * i];
  fwrite(wbuf, sizeof(double), 3 * nx * ny * nz, fp);
  free(wbuf);
  fclose(fp);
}


x86 assembly (clang, -O0):
<dump_velocity_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x100,%esi
lea    0xe44(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x240(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1217 <dump_velocity_c+0x97>
lea    -0x140(%rbp),%rdi
lea    -0x240(%rbp),%rcx
mov    $0x100,%esi
lea    0xe0e(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x140(%rbp),%rdi
call   1090 <perror@plt>
jmp    140e <dump_velocity_c+0x28e>
lea    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xe80(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x240(%rbp),%rdx
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x240(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x100,%esi
lea    0xdd5(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x240(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1331 <dump_velocity_c+0x1b1>
lea    -0x140(%rbp),%rdi
lea    -0x240(%rbp),%rcx
mov    $0x100,%esi
lea    0xd9c(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x140(%rbp),%rdi
call   1090 <perror@plt>
jmp    140e <dump_velocity_c+0x28e>
imul   $0x3,-0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    138a <dump_velocity_c+0x20a>
lea    -0x140(%rbp),%rdi
mov    $0x100,%esi
lea    0xd6b(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x140(%rbp),%rdi
call   1090 <perror@plt>
jmp    140e <dump_velocity_c+0x28e>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   $0x3,-0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    13d8 <dump_velocity_c+0x258>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x248(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1391 <dump_velocity_c+0x211>
mov    -0x248(%rbp),%rdi
imul   $0x3,-0x14(%rbp),%edx
imul   -0x18(%rbp),%edx
imul   -0x1c(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    $0x8,%esi
call   10a0 <fwrite@plt>
mov    -0x248(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_velocity_c>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %r9,%r14
mov    %r8d,0xc(%rsp)
mov    %ecx,0x8(%rsp)
mov    %edx,%ebx
mov    %rsi,%r13
mov    %rdi,%r15
lea    0xe54(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xe3d(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     143c <dump_velocity_c+0x2bc>
mov    %rax,%r12
mov    %r14,%rbp
lea    0xec3(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10a0 <fwrite@plt>
lea    0xe27(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe22(%rip),%rsi
mov    %r12,%rdi
mov    %ebx,%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe1b(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10a0 <fwrite@plt>
lea    0xe16(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10a0 <fwrite@plt>
lea    0xe12(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10a0 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe06(%rip),%rdx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xd49(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1445 <dump_velocity_c+0x2c5>
mov    %rax,%r15
imul   0x8(%rsp),%ebx
imul   0xc(%rsp),%ebx
lea    (%rbx,%rbx,2),%r12d
lea    0x0(,%r12,8),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     146a <dump_velocity_c+0x2ea>
mov    %rax,%rbx
test   %r12d,%r12d
jle    1407 <dump_velocity_c+0x287>
mov    %rbp,%r8
mov    %r12d,%eax
cmp    $0x4,%r12d
jbe    132d <dump_velocity_c+0x1ad>
mov    %rax,%rcx
shl    $0x4,%rcx
add    %r8,%rcx
add    $0xfffffffffffffff8,%rcx
cmp    %rcx,%rbx
jae    1331 <dump_velocity_c+0x1b1>
lea    (%rbx,%rax,8),%rcx
cmp    %r8,%rcx
jbe    1331 <dump_velocity_c+0x1b1>
xor    %ecx,%ecx
jmp    1375 <dump_velocity_c+0x1f5>
mov    %eax,%ecx
and    $0x3,%ecx
test   %rcx,%rcx
mov    $0x4,%edx
cmovne %rcx,%rdx
mov    %rax,%rcx
sub    %rdx,%rcx
lea    0x20(%r8),%rdx
xor    %esi,%esi
xchg   %ax,%ax
movups -0x20(%rdx),%xmm0
movhps -0x10(%rdx),%xmm0
movups (%rdx),%xmm1
movhps 0x10(%rdx),%xmm1
movups %xmm0,(%rbx,%rsi,8)
movups %xmm1,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0x40,%rdx
cmp    %rsi,%rcx
jne    1350 <dump_velocity_c+0x1d0>
mov    %eax,%esi
sub    %ecx,%esi
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
and    $0x3,%rsi
je     13b7 <dump_velocity_c+0x237>
mov    %rcx,%rdi
shl    $0x4,%rdi
add    %r8,%rdi
shl    $0x3,%rsi
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsd  (%rdi,%rbp,2),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
add    $0x8,%rbp
cmp    %rbp,%rsi
jne    13a0 <dump_velocity_c+0x220>
cmp    $0x3,%rdx
jb     1407 <dump_velocity_c+0x287>
mov    %rcx,%rdx
shl    $0x4,%rdx
add    %r8,%rdx
add    $0x30,%rdx
nopl   0x0(%rax,%rax,1)
movsd  -0x30(%rdx),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
movsd  -0x20(%rdx),%xmm0
movsd  %xmm0,0x8(%rbx,%rcx,8)
movsd  -0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rbx,%rcx,8)
movsd  (%rdx),%xmm0
movsd  %xmm0,0x18(%rbx,%rcx,8)
add    $0x4,%rcx
add    $0x40,%rdx
cmp    %rcx,%rax
jne    13d0 <dump_velocity_c+0x250>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %r12d,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbca(%rip),%rdx
jmp    144c <dump_velocity_c+0x2cc>
lea    0xc69(%rip),%rdx
lea    0x110(%rsp),%rbx
lea    0x10(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1488 <dump_velocity_c+0x308>
lea    0xc6c(%rip),%rdx
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1090 <perror@plt>
jmp    142a <dump_velocity_c+0x2aa>

LLVM IR (-O0):
@.str = [10 x i8] c"%s/%s.bov\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [40 x i8] c"WARNING: Unable to create BOV file (%s)\00"
@.str.3 = [7 x i8] c"%s.dat\00"
@.str.4 = [20 x i8] c"VARIABLE: velocity\0A\00"
@.str.5 = [15 x i8] c"DATA_FILE: %s\0A\00"
@.str.6 = [21 x i8] c"DATA_SIZE: %d %d %d\0A\00"
@.str.7 = [20 x i8] c"DATA_COMPONENTS: 3\0A\00"
@.str.8 = [21 x i8] c"DATA_FORMAT: DOUBLE\0A\00"
@.str.9 = [21 x i8] c"DATA_ENDIAN: LITTLE\0A\00"
@.str.10 = [10 x i8] c"%s/%s.dat\00"
@.str.11 = [40 x i8] c"WARNING: Unable to create DAT file (%s)\00"
@.str.12 = [41 x i8] c"WARNING: Unable to allocate write buffer\00"
define void @dump_velocity_c(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, double* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca [256 x i8]
%18 = alloca [256 x i8]
%19 = alloca double*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double* %5, double** %12
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %20, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %16
%26 = load i32*, i32** %16
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %6
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%31 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %29, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%33 = call i32 @perror(i8* %32)
br label %127
34: ; preds = %6
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%36 = load i8*, i8** %8
%37 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %35, i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load i32*, i32** %16
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32*, i32** %16
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = load i32*, i32** %16
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = load i32, i32* %11
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
%48 = load i32*, i32** %16
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%50 = load i32*, i32** %16
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%52 = load i32*, i32** %16
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%54 = load i32*, i32** %16
%55 = call i32 @fclose(i32* %54)
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%57 = load i8*, i8** %7
%58 = load i8*, i8** %8
%59 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %56, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %57, i8* %58)
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %61, i32** %16
%62 = load i32*, i32** %16
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %70
64: ; preds = %34
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%67 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %65, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %66)
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%69 = call i32 @perror(i8* %68)
br label %127
70: ; preds = %34
%71 = load i32, i32* %9
%72 = mul nsw i32 3, %71
%73 = load i32, i32* %10
%74 = mul nsw i32 %72, %73
%75 = load i32, i32* %11
%76 = mul nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 8
%79 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to double*
store double* %81, double** %19
%82 = load double*, double** %19
%83 = icmp eq double* %82, null
br i1 %83, label %84, label %89
84: ; preds = %70
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%86 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %85, i32 256, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0))
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%88 = call i32 @perror(i8* %87)
br label %127
89: ; preds = %70
store i32 0, i32* %13
br label %90
90: ; preds = %110, %89
%91 = load i32, i32* %13
%92 = load i32, i32* %9
%93 = mul nsw i32 3, %92
%94 = load i32, i32* %10
%95 = mul nsw i32 %93, %94
%96 = load i32, i32* %11
%97 = mul nsw i32 %95, %96
%98 = icmp slt i32 %91, %97
br i1 %98, label %99, label %113
99: ; preds = %90
%100 = load double*, double** %12
%101 = load i32, i32* %13
%102 = mul nsw i32 2, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %100, i64 %103
%105 = load double, double* %104
%106 = load double*, double** %19
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
store double %105, double* %109
br label %110
110: ; preds = %99
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
store i32 %112, i32* %13
br label %90
113: ; preds = %90
%114 = load double*, double** %19
%115 = load i32, i32* %9
%116 = mul nsw i32 3, %115
%117 = load i32, i32* %10
%118 = mul nsw i32 %116, %117
%119 = load i32, i32* %11
%120 = mul nsw i32 %118, %119
%121 = load i32*, i32** %16
%122 = call i32 @fwrite(double* %114, i32 8, i32 %120, i32* %121)
%123 = load double*, double** %19
%124 = call i32 @free(double* %123)
%125 = load i32*, i32** %16
%126 = call i32 @fclose(i32* %125)
br label %127
127: ; preds = %113, %84, %64, %28
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s/%s.bov\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [40 x i8] c"WARNING: Unable to create BOV file (%s)\00"
@.str.3 = [7 x i8] c"%s.dat\00"
@.str.4 = [20 x i8] c"VARIABLE: velocity\0A\00"
@.str.5 = [15 x i8] c"DATA_FILE: %s\0A\00"
@.str.6 = [21 x i8] c"DATA_SIZE: %d %d %d\0A\00"
@.str.7 = [20 x i8] c"DATA_COMPONENTS: 3\0A\00"
@.str.8 = [21 x i8] c"DATA_FORMAT: DOUBLE\0A\00"
@.str.9 = [21 x i8] c"DATA_ENDIAN: LITTLE\0A\00"
@.str.10 = [10 x i8] c"%s/%s.dat\00"
@.str.11 = [40 x i8] c"WARNING: Unable to create DAT file (%s)\00"
@.str.12 = [41 x i8] c"WARNING: Unable to allocate write buffer\00"
define void @dump_velocity_c(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, double* nocapture %5) {
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%12 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%16 = call i32 @perror(i8* %9)
br label %129
17: ; preds = %6
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%19 = call i64 bitcast (i32 (double*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 19, i64 1, i32* %12)
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 %3, i32 %4)
%22 = call i64 bitcast (i32 (double*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i64 19, i64 1, i32* %12)
%23 = call i64 bitcast (i32 (double*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i64 20, i64 1, i32* %12)
%24 = call i64 bitcast (i32 (double*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i64 20, i64 1, i32* %12)
%25 = call i32 @fclose(i32* %12)
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* %1)
%27 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %17
%30 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %10)
%31 = call i32 @perror(i8* %9)
br label %129
32: ; preds = %17
%33 = mul nsw i32 %2, 3
%34 = mul nsw i32 %33, %3
%35 = mul nsw i32 %34, %4
%36 = shl i32 %35, 3
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to double*
%39 = inttoptr i64 %37 to i8*
%40 = icmp eq i64 %37, 0
br i1 %40, label %99, label %41
41: ; preds = %32
%42 = icmp sgt i32 %35, 0
br i1 %42, label %43, label %125
43: ; preds = %41
%44 = zext i32 %35 to i64
%45 = icmp ult i32 %35, 5
br i1 %45, label %46, label %66
46: ; preds = %80, %66, %43
%47 = phi i64 [ 0, %66 ], [ 0, %43 ], [ %79, %80 ]
%48 = sub nsw i64 %44, %47
%49 = xor i64 %47, -1
%50 = add nsw i64 %49, %44
%51 = and i64 %48, 3
%52 = icmp eq i64 %51, 0
br i1 %52, label %63, label %53
53: ; preds = %46, %53
%54 = phi i64 [ %60, %53 ], [ %47, %46 ]
%55 = phi i64 [ %61, %53 ], [ 0, %46 ]
%56 = shl nuw nsw i64 %54, 1
%57 = getelementptr inbounds double, double* %5, i64 %56
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %38, i64 %54
store double %58, double* %59
%60 = add nuw nsw i64 %54, 1
%61 = add i64 %55, 1
%62 = icmp eq i64 %61, %51
br i1 %62, label %63, label %53
63: ; preds = %53, %46
%64 = phi i64 [ %47, %46 ], [ %60, %53 ]
%65 = icmp ult i64 %50, 3
br i1 %65, label %125, label %102
66: ; preds = %43
%67 = getelementptr double, double* %38, i64 %44
%68 = shl nuw nsw i64 %44, 1
%69 = add nsw i64 %68, -1
%70 = getelementptr double, double* %5, i64 %69
%71 = bitcast double* %70 to i8*
%72 = icmp ult i8* %39, %71
%73 = icmp ugt double* %67, %5
%74 = and i1 %72, %73
br i1 %74, label %46, label %75
75: ; preds = %66
%76 = and i64 %44, 3
%77 = icmp eq i64 %76, 0
%78 = select i1 %77, i64 4, i64 %76
%79 = sub nsw i64 %44, %78
br label %80
80: ; preds = %80, %75
%81 = phi i64 [ 0, %75 ], [ %97, %80 ]
%82 = shl nuw nsw i64 %81, 1
%83 = shl i64 %81, 1
%84 = or i64 %83, 4
%85 = getelementptr inbounds double, double* %5, i64 %82
%86 = getelementptr inbounds double, double* %5, i64 %84
%87 = bitcast double* %85 to <4 x double>*
%88 = bitcast double* %86 to <4 x double>*
%89 = load <4 x double>, <4 x double>* %87
%90 = load <4 x double>, <4 x double>* %88
%91 = shufflevector <4 x double> %89, <4 x double> poison, <2 x i32> <i32 0, i32 2>
%92 = shufflevector <4 x double> %90, <4 x double> poison, <2 x i32> <i32 0, i32 2>
%93 = getelementptr inbounds double, double* %38, i64 %81
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> %91, <2 x double>* %94
%95 = getelementptr inbounds double, double* %93, i64 2
%96 = bitcast double* %95 to <2 x double>*
store <2 x double> %92, <2 x double>* %96
%97 = add nuw i64 %81, 4
%98 = icmp eq i64 %97, %79
br i1 %98, label %46, label %80
99: ; preds = %32
%100 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0))
%101 = call i32 @perror(i8* %9)
br label %129
102: ; preds = %63, %102
%103 = phi i64 [ %123, %102 ], [ %64, %63 ]
%104 = shl nuw nsw i64 %103, 1
%105 = getelementptr inbounds double, double* %5, i64 %104
%106 = load double, double* %105
%107 = getelementptr inbounds double, double* %38, i64 %103
store double %106, double* %107
%108 = add nuw nsw i64 %103, 1
%109 = shl nuw nsw i64 %108, 1
%110 = getelementptr inbounds double, double* %5, i64 %109
%111 = load double, double* %110
%112 = getelementptr inbounds double, double* %38, i64 %108
store double %111, double* %112
%113 = add nuw nsw i64 %103, 2
%114 = shl nuw nsw i64 %113, 1
%115 = getelementptr inbounds double, double* %5, i64 %114
%116 = load double, double* %115
%117 = getelementptr inbounds double, double* %38, i64 %113
store double %116, double* %117
%118 = add nuw nsw i64 %103, 3
%119 = shl nuw nsw i64 %118, 1
%120 = getelementptr inbounds double, double* %5, i64 %119
%121 = load double, double* %120
%122 = getelementptr inbounds double, double* %38, i64 %118
store double %121, double* %122
%123 = add nuw nsw i64 %103, 4
%124 = icmp eq i64 %123, %44
br i1 %124, label %125, label %102
125: ; preds = %63, %102, %41
%126 = call i32 @fwrite(double* %38, i32 8, i32 %35, i32* %27)
%127 = call i32 @free(double* %38)
%128 = call i32 @fclose(i32* %27)
br label %129
129: ; preds = %125, %99, %29, %14
ret void
}