#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*/ errhandler(int, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *);
void write_vtkHeader(FILE *fp, int imax, int jmax, int kmax, double dx,
                     double dy, double dz) {
  if (fp == NULL) {
    char szBuff[80];
    sprintf(szBuff, "Null pointer in write_vtkHeader");
    errhandler(121,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/"
               "master/Backup/FinalProjectPresentation/visual.c",
               szBuff);
    return;
  }
  fprintf(fp, "# vtk DataFile Version 2.0\n");
  fprintf(fp, "generated by CFD-lab course output \n");
  fprintf(fp, "ASCII\n");
  fprintf(fp, "\n");
  fprintf(fp, "DATASET STRUCTURED_GRID\n");
  fprintf(fp, "DIMENSIONS  %i %i %i \n", imax + 1, jmax + 1, kmax + 1);
  fprintf(fp, "POINTS %i float\n", (imax + 1) * (jmax + 1) * (kmax + 1));
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<write_vtkHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118c <write_vtkHeader+0x5c>
lea    -0x80(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rdx
mov    $0x79,%edi
lea    0xe9e(%rip),%rsi
call   1030 <errhandler@plt>
jmp    1248 <write_vtkHeader+0x118>
mov    -0x8(%rbp),%rdi
lea    0xf2c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf36(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf49(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf2c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    -0x14(%rbp),%r8d
add    $0x1,%r8d
lea    0xf1f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edx
lea    0xf0c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xef8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_vtkHeader>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
test   %rdi,%rdi
je     1225 <write_vtkHeader+0xe5>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xf5e(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xf61(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xf6d(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
lea    0xf4e(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
add    $0x1,%r15d
add    $0x1,%ebp
add    $0x1,%r14d
lea    0xf43(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
imul   %r15d,%ebp
imul   %r14d,%ebp
lea    0xf39(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>
movups 0xde4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xdc8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xddd(%rip),%rsi
mov    %rsp,%rdx
mov    $0x79,%edi
call   1030 <errhandler@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Null pointer in write_vtkHeader\00"
@.str.1 = [163 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProjectPresentation/visual.c\00"
@.str.2 = [28 x i8] c"# vtk DataFile Version 2.0\0A\00"
@.str.3 = [37 x i8] c"generated by CFD-lab course output \0A\00"
@.str.4 = [7 x i8] c"ASCII\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [25 x i8] c"DATASET STRUCTURED_GRID\0A\00"
@.str.7 = [23 x i8] c"DIMENSIONS %i %i %i \0A\00"
@.str.8 = [17 x i8] c"POINTS %i float\0A\00"
define void @write_vtkHeader(i32* %0, i32 %1, i32 %2, i32 %3, double %4, double %5, double %6) {
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca [80 x i8]
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%16 = load i32*, i32** %8
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %7
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%22 = call i32 @errhandler(i32 121, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %54
23: ; preds = %7
%24 = load i32*, i32** %8
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** %8
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32*, i32** %8
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32*, i32** %8
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32*, i32** %8
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%34 = load i32*, i32** %8
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %36, i32 %38, i32 %40)
%42 = load i32*, i32** %8
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
%47 = mul nsw i32 %44, %46
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
%50 = mul nsw i32 %47, %49
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %50)
%52 = load i32*, i32** %8
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %23, %18
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Null pointer in write_vtkHeader\00"
@.str.1 = [163 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProjectPresentation/visual.c\00"
@.str.2 = [28 x i8] c"# vtk DataFile Version 2.0\0A\00"
@.str.3 = [37 x i8] c"generated by CFD-lab course output \0A\00"
@.str.4 = [7 x i8] c"ASCII\0A\00"
@.str.6 = [25 x i8] c"DATASET STRUCTURED_GRID\0A\00"
@.str.7 = [23 x i8] c"DIMENSIONS %i %i %i \0A\00"
@.str.8 = [17 x i8] c"POINTS %i float\0A\00"
define void @write_vtkHeader(i32* %0, i32 %1, i32 %2, i32 %3, double %4, double %5, double %6) {
%8 = alloca [80 x i8]
%9 = icmp eq i32* %0, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%12 = call i32 @errhandler(i32 121, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %27
13: ; preds = %7
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i64 27, i64 1, i32* %0)
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i64 36, i64 1, i32* %0)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i64 1, i32* %0)
%17 = tail call i32 @fputc(i32 10, i32* %0)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i64 24, i64 1, i32* %0)
%19 = add nsw i32 %1, 1
%20 = add nsw i32 %2, 1
%21 = add nsw i32 %3, 1
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
%23 = mul nsw i32 %20, %19
%24 = mul nsw i32 %23, %21
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %24)
%26 = tail call i32 @fputc(i32 10, i32* %0)
br label %27
27: ; preds = %13, %10
ret void
}