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


x86 assembly (clang, -O0):
<write_vtkHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1181 <write_vtkHeader+0x51>
lea    -0x70(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdx
mov    $0x59,%edi
lea    0xea9(%rip),%rsi
call   1030 <errhandler@plt>
jmp    122c <write_vtkHeader+0xfc>
mov    -0x8(%rbp),%rdi
lea    0xf47(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf51(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf7f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf6b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf62(%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
lea    0xf5d(%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
lea    0xf52(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf08(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_vtkHeader>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
test   %rdi,%rdi
je     1213 <write_vtkHeader+0xd3>
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xf73(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xf76(%rip),%rdi
mov    $0x3f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xf9d(%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    0xf7e(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
add    $0x1,%r14d
add    $0x1,%ebp
lea    0xf77(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
imul   %r14d,%ebp
lea    0xf73(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fputc@plt>
movups 0xdf6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xdda(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xdef(%rip),%rsi
mov    %rsp,%rdx
mov    $0x59,%edi
call   1030 <errhandler@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Null pointer in write_vtkHeader\00"
@.str.1 = [179 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/project/ns_sim_serial/visual.c\00"
@.str.2 = [28 x i8] c"# vtk DataFile Version 2.0\0A\00"
@.str.3 = [64 x i8] c"generated by CFD-lab course output (written by Tobias Neckel) \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 = [22 x i8] c"DIMENSIONS %i %i 1 \0A\00"
@.str.8 = [17 x i8] c"POINTS %i float\0A\00"
define void @write_vtkHeader(i32* %0, i32 %1, i32 %2, double %3, double %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca [80 x i8]
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double %3, double* %9
store double %4, double* %10
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %5
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%18 = call i32 @errhandler(i32 89, i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %45
19: ; preds = %5
%20 = load i32*, i32** %6
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %6
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %6
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32*, i32** %6
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32*, i32** %6
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%30 = load i32*, i32** %6
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %34)
%36 = load i32*, i32** %6
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
%41 = mul nsw i32 %38, %40
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %41)
%43 = load i32*, i32** %6
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %19, %14
ret void
}

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