#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*/ abort();
int /*<<< orphan*/ dump_lattice_to_file(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ hpp_simulation(int, double, double, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main(void) {
  FILE *fout;
  int dim = 256;
  double r0 = 30, r1 = 40;
  int nsteps;
  for (nsteps = 1; nsteps <= 32; nsteps *= 2)
    do {
      char filename[128];
      snprintf(filename, sizeof filename, "res_%03d", nsteps);
      fout = fopen(filename, "w");
      if (fout == NULL) {
        perror("fopen()");
        abort();
      }
      dump_lattice_to_file(fout, hpp_simulation(dim, r0, r1, nsteps), dim);
      fclose(fout);
    } while (0);
  for (nsteps = 40; nsteps < 200; nsteps += 10)
    do {
      char filename[128];
      snprintf(filename, sizeof filename, "res_%03d", nsteps);
      fout = fopen(filename, "w");
      if (fout == NULL) {
        perror("fopen()");
        abort();
      }
      dump_lattice_to_file(fout, hpp_simulation(dim, r0, r1, nsteps), dim);
      fclose(fout);
    } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100,-0x14(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jg     1256 <main+0xe6>
jmp    11b9 <main+0x49>
lea    -0xb0(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%esi
lea    0xe41(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1209 <main+0x99>
lea    0xe1e(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
call   1070 <hpp_simulation@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%esi
mov    -0x14(%rbp),%edx
call   1060 <dump_lattice_to_file@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1248 <main+0xd8>
mov    -0x2c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11aa <main+0x3a>
movl   $0x28,-0x2c(%rbp)
cmpl   $0xc8,-0x2c(%rbp)
jge    130c <main+0x19c>
jmp    126f <main+0xff>
lea    -0x130(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x80,%esi
lea    0xd8b(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x130(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12bf <main+0x14f>
lea    0xd68(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
call   1070 <hpp_simulation@plt>
mov    -0x140(%rbp),%rdi
mov    %eax,%esi
mov    -0x14(%rbp),%edx
call   1060 <dump_lattice_to_file@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12fe <main+0x18e>
mov    -0x2c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x2c(%rbp)
jmp    125d <main+0xed>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xe8a(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x1,%ecx
call   1050 <snprintf@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xe42(%rip),%xmm0
movsd  0xe42(%rip),%xmm1
mov    $0x100,%edi
mov    $0x1,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe1d(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x2,%ecx
call   1050 <snprintf@plt>
lea    0xe0a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xdd5(%rip),%xmm0
movsd  0xdd5(%rip),%xmm1
mov    $0x100,%edi
mov    $0x2,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdb0(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x4,%ecx
call   1050 <snprintf@plt>
lea    0xd9d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xd68(%rip),%xmm0
movsd  0xd68(%rip),%xmm1
mov    $0x100,%edi
mov    $0x4,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd43(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x8,%ecx
call   1050 <snprintf@plt>
lea    0xd30(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xcfb(%rip),%xmm0
movsd  0xcfb(%rip),%xmm1
mov    $0x100,%edi
mov    $0x8,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xcd6(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x10,%ecx
call   1050 <snprintf@plt>
lea    0xcc3(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xc8e(%rip),%xmm0
movsd  0xc8e(%rip),%xmm1
mov    $0x100,%edi
mov    $0x10,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xc69(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    $0x20,%ecx
call   1050 <snprintf@plt>
lea    0xc56(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
movsd  0xc21(%rip),%xmm0
movsd  0xc21(%rip),%xmm1
mov    $0x100,%edi
mov    $0x20,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1e,%ebp
lea    0xbf7(%rip),%r14
mov    %rsp,%r15
lea    0xbf6(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xa,%ebp
mov    %r15,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1050 <snprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a5 <main+0x335>
mov    %rax,%rbx
mov    $0x100,%edi
movsd  0xb9b(%rip),%xmm0
movsd  0xb9b(%rip),%xmm1
mov    %ebp,%esi
call   1070 <hpp_simulation@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1060 <dump_lattice_to_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
cmp    $0xbe,%ebp
jb     1430 <main+0x2c0>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb6f(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"res_%03d\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"fopen()\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
store i32 0, i32* %1
store i32 256, i32* %3
store double 3.000000e+01, double* %4
store double 4.000000e+01, double* %5
store i32 1, i32* %6
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 32
br i1 %11, label %12, label %39
12: ; preds = %9
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = load i32, i32* %6
%16 = call i32 @snprintf(i8* %14, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %2
%19 = load i32*, i32** %2
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %13
%25 = load i32*, i32** %2
%26 = load i32, i32* %3
%27 = load double, double* %4
%28 = load double, double* %5
%29 = load i32, i32* %6
%30 = call i32 @hpp_simulation(i32 %26, double %27, double %28, i32 %29)
%31 = load i32, i32* %3
%32 = call i32 @dump_lattice_to_file(i32* %25, i32 %30, i32 %31)
%33 = load i32*, i32** %2
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = mul nsw i32 %37, 2
store i32 %38, i32* %6
br label %9
39: ; preds = %9
store i32 40, i32* %6
br label %40
40: ; preds = %67, %39
%41 = load i32, i32* %6
%42 = icmp slt i32 %41, 200
br i1 %42, label %43, label %70
43: ; preds = %40
br label %44
44: ; preds = %43
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%46 = load i32, i32* %6
%47 = call i32 @snprintf(i8* %45, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %49, i32** %2
%50 = load i32*, i32** %2
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 (...) @abort()
unreachable
55: ; preds = %44
%56 = load i32*, i32** %2
%57 = load i32, i32* %3
%58 = load double, double* %4
%59 = load double, double* %5
%60 = load i32, i32* %6
%61 = call i32 @hpp_simulation(i32 %57, double %58, double %59, i32 %60)
%62 = load i32, i32* %3
%63 = call i32 @dump_lattice_to_file(i32* %56, i32 %61, i32 %62)
%64 = load i32*, i32** %2
%65 = call i32 @fclose(i32* %64)
br label %66
66: ; preds = %55
br label %67
67: ; preds = %66
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 10
store i32 %69, i32* %6
br label %40
70: ; preds = %40
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"res_%03d\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"fopen()\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%5 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %38, %31, %24, %17, %10, %0
%8 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 1)
%12 = call i32 @dump_lattice_to_file(i32* %5, i32 %11, i32 256)
%13 = call i32 @fclose(i32* %5)
%14 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %7, label %17
17: ; preds = %10
%18 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 2)
%19 = call i32 @dump_lattice_to_file(i32* %15, i32 %18, i32 256)
%20 = call i32 @fclose(i32* %15)
%21 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 4)
%22 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %7, label %24
24: ; preds = %17
%25 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 4)
%26 = call i32 @dump_lattice_to_file(i32* %22, i32 %25, i32 256)
%27 = call i32 @fclose(i32* %22)
%28 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%29 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %7, label %31
31: ; preds = %24
%32 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 8)
%33 = call i32 @dump_lattice_to_file(i32* %29, i32 %32, i32 256)
%34 = call i32 @fclose(i32* %29)
%35 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 16)
%36 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %7, label %38
38: ; preds = %31
%39 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 16)
%40 = call i32 @dump_lattice_to_file(i32* %36, i32 %39, i32 256)
%41 = call i32 @fclose(i32* %36)
%42 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 32)
%43 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %7, label %45
45: ; preds = %38
%46 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 32)
%47 = call i32 @dump_lattice_to_file(i32* %43, i32 %46, i32 256)
%48 = call i32 @fclose(i32* %43)
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
br label %50
50: ; preds = %45, %58
%51 = phi i32 [ 40, %45 ], [ %62, %58 ]
%52 = call i32 @snprintf(i8* %49, i32 128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 (...) @abort()
unreachable
58: ; preds = %50
%59 = call i32 @hpp_simulation(i32 256, double 3.000000e+01, double 4.000000e+01, i32 %51)
%60 = call i32 @dump_lattice_to_file(i32* %53, i32 %59, i32 256)
%61 = call i32 @fclose(i32* %53)
%62 = add nuw nsw i32 %51, 10
%63 = icmp ult i32 %51, 190
br i1 %63, label %50, label %64
64: ; preds = %58
ret i32 0
}