#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fill_random(unsigned long long *, int const, int const,
                               int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ generate_table_big(unsigned long long, unsigned long long *);
int /*<<< orphan*/ generate_table_normal(unsigned long long,
                                         unsigned long long *);
int /*<<< orphan*/ generate_table_small(unsigned long long,
                                        unsigned long long *);
int one_step_big(unsigned long long *, int *, int *, int *, int, int);
int one_step_normal(unsigned long long *, int *, int *, int *, int, int);
int one_step_small(unsigned long long *, int *, int *, int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
float return_attack(int, int *, int *, int *, int const, int const, float const,
                    float const);
int /*<<< orphan*/ stderr;
scalar_t__ time(int /*<<< orphan*/ *);
void simulate_average(const int table_size, unsigned long long *const MID,
                      float *const MP, const int num_attacks, const int width,
                      const int hight, const int LS, const int isStrong,
                      const float line, const float way) {
  const int combo_length = 100;
  const int rank = 100;
  int i, j;
  float average_power[rank];
  float min_power[rank];
  float average_combo[rank];
  int min_combo[rank];
  unsigned long long tableID;
  unsigned long long color_table[6];
#pragma omp parallel private(i, j, tableID, color_table)
  {
    int seed = 98503 + (unsigned)time(NULL);
#pragma omp for
    for (i = 0; i < rank; i++) {
      tableID = MID[i];
      float pave = 0.0;
      float cave = 0.0;
      float pmin = 1000000000.0;
      int cmin = combo_length;
      for (j = 0; j < 10000; j++) {
        int color_combo[combo_length];
        int num_drops_combo[combo_length];
        int isLine_combo[combo_length];
        int num_c;
        for (num_c = 0; num_c < 6; num_c++) {
          color_table[num_c] = 0;
        }
        switch (table_size) {
        case 0:
          generate_table_small(tableID, color_table);
          break;
        case 1:
          generate_table_normal(tableID, color_table);
          break;
        case 2:
          generate_table_big(tableID, color_table);
          break;
        default:
          fprintf(stderr, "unknown table size\n");
          exit(1);
        }
        int combo_counter = 0;
        int returned_combo_counter = 0;
        do {
          combo_counter = returned_combo_counter;
          switch (table_size) {
          case 0:
            returned_combo_counter =
                one_step_small(color_table, color_combo, num_drops_combo,
                               isLine_combo, combo_counter, 6);
            break;
          case 1:
            returned_combo_counter =
                one_step_normal(color_table, color_combo, num_drops_combo,
                                isLine_combo, combo_counter, 6);
            break;
          case 2:
            returned_combo_counter =
                one_step_big(color_table, color_combo, num_drops_combo,
                             isLine_combo, combo_counter, 6);
            break;
          }
          fill_random(color_table, width, hight, &seed);
        } while (returned_combo_counter != combo_counter);
        float power = return_attack(combo_counter, color_combo, num_drops_combo,
                                    isLine_combo, LS, isStrong, line, way);
        if (power < pmin) {
          pmin = power;
        }
        if (combo_counter < cmin) {
          cmin = combo_counter;
        }
        pave += power;
        cave += combo_counter;
      }
      average_combo[i] = cave / 10000.0;
      average_power[i] = pave / 10000.0;
      min_combo[i] = cmin;
      min_power[i] = pmin;
    }
  }
  printf("rank,tableID      ,power     ,ave power ,min power ,ave combo ,min "
         "combo\n");
  for (i = 0; i < rank; i++) {
    printf("%4d,%13lld,%10.3f,%10.3f,%10.3f,%10.3f,%6d\n", i, MID[i], MP[i],
           average_power[i], min_power[i], average_combo[i], min_combo[i]);
  }
}


x86 assembly (clang, -O0):
<simulate_average>:
push   %rbp
mov    %rsp,%rbp
sub    $0x710,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movss  %xmm0,-0x28(%rbp)
movss  %xmm1,-0x2c(%rbp)
movl   $0x64,-0x30(%rbp)
movl   $0x64,-0x34(%rbp)
mov    %rsp,%rax
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
add    $0x180c7,%eax
mov    %eax,-0x84(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x64,-0x38(%rbp)
jge    1602 <simulate_average+0x442>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  0xda7(%rip),%xmm0
movss  %xmm0,-0x90(%rbp)
ff
movl   $0x64,-0x94(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2710,-0x3c(%rbp)
jge    157c <simulate_average+0x3bc>
mov    %rsp,%rax
mov    %rax,-0xa0(%rbp)
mov    %rsp,%rax
add    $0xfffffffffffffe70,%rax
mov    %rax,-0x708(%rbp)
mov    %rax,%rsp
mov    %rsp,%rax
add    $0xfffffffffffffe70,%rax
mov    %rax,-0x700(%rbp)
mov    %rax,%rsp
mov    %rsp,%rax
add    $0xfffffffffffffe70,%rax
mov    %rax,-0x6f8(%rbp)
mov    %rax,%rsp
movl   $0x0,-0xa4(%rbp)
cmpl   $0x6,-0xa4(%rbp)
jge    12fd <simulate_average+0x13d>
movslq -0xa4(%rbp),%rax
movq   $0x0,-0x80(%rbp,%rax,8)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    12cc <simulate_average+0x10c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x70c(%rbp)
test   %eax,%eax
je     133b <simulate_average+0x17b>
jmp    1313 <simulate_average+0x153>
mov    -0x70c(%rbp),%eax
sub    $0x1,%eax
je     134d <simulate_average+0x18d>
jmp    1327 <simulate_average+0x167>
mov    -0x70c(%rbp),%eax
sub    $0x2,%eax
je     135f <simulate_average+0x19f>
jmp    1371 <simulate_average+0x1b1>
mov    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1070 <generate_table_small@plt>
jmp    1390 <simulate_average+0x1d0>
mov    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10e0 <generate_table_normal@plt>
jmp    1390 <simulate_average+0x1d0>
mov    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10b0 <generate_table_big@plt>
jmp    1390 <simulate_average+0x1d0>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
lea    0xc8f(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x710(%rbp)
test   %eax,%eax
je     13ee <simulate_average+0x22e>
jmp    13c6 <simulate_average+0x206>
mov    -0x710(%rbp),%eax
sub    $0x1,%eax
je     1424 <simulate_average+0x264>
jmp    13da <simulate_average+0x21a>
mov    -0x710(%rbp),%eax
sub    $0x2,%eax
je     145a <simulate_average+0x29a>
jmp    148b <simulate_average+0x2cb>
mov    -0x6f8(%rbp),%rcx
mov    -0x700(%rbp),%rdx
mov    -0x708(%rbp),%rsi
lea    -0x80(%rbp),%rdi
mov    -0xa8(%rbp),%r8d
mov    $0x6,%r9d
call   10c0 <one_step_small@plt>
mov    %eax,-0xac(%rbp)
jmp    148b <simulate_average+0x2cb>
mov    -0x6f8(%rbp),%rcx
mov    -0x700(%rbp),%rdx
mov    -0x708(%rbp),%rsi
lea    -0x80(%rbp),%rdi
mov    -0xa8(%rbp),%r8d
mov    $0x6,%r9d
call   1060 <one_step_normal@plt>
mov    %eax,-0xac(%rbp)
jmp    148b <simulate_average+0x2cb>
mov    -0x6f8(%rbp),%rcx
mov    -0x700(%rbp),%rdx
mov    -0x708(%rbp),%rsi
lea    -0x80(%rbp),%rdi
mov    -0xa8(%rbp),%r8d
mov    $0x6,%r9d
call   10a0 <one_step_big@plt>
mov    %eax,-0xac(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    -0x84(%rbp),%rcx
call   1030 <fill_random@plt>
mov    -0xac(%rbp),%eax
cmp    -0xa8(%rbp),%eax
jne    13a4 <simulate_average+0x1e4>
mov    -0x6f8(%rbp),%rcx
mov    -0x700(%rbp),%rdx
mov    -0x708(%rbp),%rsi
mov    -0xa8(%rbp),%edi
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9d
movss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
call   1040 <return_attack@plt>
movss  %xmm0,-0xb0(%rbp)
ff
movss  -0xb0(%rbp),%xmm1
ff
movss  -0x90(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jbe    1516 <simulate_average+0x356>
movss  -0xb0(%rbp),%xmm0
ff
movss  %xmm0,-0x90(%rbp)
ff
mov    -0xa8(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    1534 <simulate_average+0x374>
mov    -0xa8(%rbp),%eax
mov    %eax,-0x94(%rbp)
movss  -0xb0(%rbp),%xmm0
ff
addss  -0x88(%rbp),%xmm0
ff
movss  %xmm0,-0x88(%rbp)
ff
cvtsi2ssl -0xa8(%rbp),%xmm0
ff
addss  -0x8c(%rbp),%xmm0
ff
movss  %xmm0,-0x8c(%rbp)
ff
mov    -0xa0(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1272 <simulate_average+0xb2>
movss  -0x8c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xa78(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x38(%rbp),%rax
movss  %xmm0,-0x560(%rbp,%rax,4)
ff ff
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xa4f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x38(%rbp),%rax
movss  %xmm0,-0x240(%rbp,%rax,4)
ff ff
mov    -0x94(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x6f0(%rbp,%rax,4)
movss  -0x90(%rbp),%xmm0
ff
movslq -0x38(%rbp),%rax
movss  %xmm0,-0x3d0(%rbp,%rax,4)
ff ff
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1221 <simulate_average+0x61>
lea    0xa1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x64,-0x38(%rbp)
jge    169b <simulate_average+0x4db>
mov    -0x38(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movslq -0x38(%rbp),%rax
movss  -0x240(%rbp,%rax,4),%xmm1
ff ff
cvtss2sd %xmm1,%xmm1
movslq -0x38(%rbp),%rax
movss  -0x3d0(%rbp,%rax,4),%xmm2
ff ff
cvtss2sd %xmm2,%xmm2
movslq -0x38(%rbp),%rax
movss  -0x560(%rbp,%rax,4),%xmm3
ff ff
cvtss2sd %xmm3,%xmm3
movslq -0x38(%rbp),%rax
mov    -0x6f0(%rbp,%rax,4),%ecx
lea    0x9e8(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1617 <simulate_average+0x457>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simulate_average>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6d8,%rsp
movss  %xmm1,-0x58(%rbp)
movss  %xmm0,-0x54(%rbp)
mov    %r9d,-0x30(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %rdx,-0x78(%rbp)
mov    %rsi,%r12
mov    %edi,%ebx
xor    %r14d,%r14d
xor    %edi,%edi
call   10a0 <time@plt>
add    $0x180c7,%eax
mov    %eax,-0x34(%rbp)
lea    -0xc0(%rbp),%rsi
mov    %r12,-0x80(%rbp)
jmp    126f <simulate_average+0x9f>
xchg   %ax,%ax
movss  0xddc(%rip),%xmm1
divss  %xmm1,%xmm2
mov    -0x88(%rbp),%r14
movss  %xmm2,-0x3e0(%rbp,%r14,4)
fc ff ff
divss  %xmm1,%xmm3
movss  %xmm3,-0x700(%rbp,%r14,4)
f9 ff ff
mov    %eax,-0x250(%rbp,%r14,4)
ff
movss  %xmm0,-0x570(%rbp,%r14,4)
fa ff ff
add    $0x1,%r14
cmp    $0x64,%r14
mov    -0x80(%rbp),%r12
je     1478 <simulate_average+0x2a8>
mov    %r14,-0x88(%rbp)
mov    (%r12,%r14,8),%rax
mov    %rax,-0x50(%rbp)
xorps  %xmm2,%xmm2
mov    $0x64,%eax
xor    %ecx,%ecx
movss  0xd70(%rip),%xmm1
xorps  %xmm3,%xmm3
jmp    1323 <simulate_average+0x153>
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    -0x34(%rbp),%rcx
call   1040 <fill_random@plt>
xor    %r15d,%r15d
mov    %r15d,%edi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9d
movss  -0x54(%rbp),%xmm0
movss  -0x58(%rbp),%xmm1
call   1050 <return_attack@plt>
mov    -0x6c(%rbp),%eax
cmp    %eax,%r15d
cmovl  %r15d,%eax
movss  -0x64(%rbp),%xmm3
addss  %xmm0,%xmm3
minss  -0x5c(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %r15d,%xmm1
movss  -0x68(%rbp),%xmm2
addss  %xmm1,%xmm2
mov    -0x90(%rbp),%rsp
mov    -0x60(%rbp),%ecx
add    $0x1,%ecx
movaps %xmm0,%xmm1
cmp    $0x2710,%ecx
lea    -0xc0(%rbp),%rsi
je     1220 <simulate_average+0x50>
mov    %rsp,%rdx
mov    %rsp,%rdi
add    $0xfffffffffffffe70,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rsp,%rdi
add    $0xfffffffffffffe70,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rsp,%r13
add    $0xfffffffffffffe70,%r13
mov    %r13,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xc0(%rbp)
cmp    $0x2,%ebx
mov    %eax,-0x6c(%rbp)
movss  %xmm2,-0x68(%rbp)
movss  %xmm3,-0x64(%rbp)
mov    %ecx,-0x60(%rbp)
movss  %xmm1,-0x5c(%rbp)
mov    %rdx,-0x90(%rbp)
je     13b0 <simulate_average+0x1e0>
cmp    $0x1,%ebx
je     13c0 <simulate_average+0x1f0>
test   %ebx,%ebx
jne    1501 <simulate_average+0x331>
mov    -0x50(%rbp),%rdi
call   1080 <generate_table_small@plt>
jmp    13c9 <simulate_average+0x1f9>
cs nopw 0x0(%rax,%rax,1)
mov    -0x50(%rbp),%rdi
call   10c0 <generate_table_big@plt>
jmp    13c9 <simulate_average+0x1f9>
nopl   0x0(%rax,%rax,1)
mov    -0x50(%rbp),%rdi
call   10f0 <generate_table_normal@plt>
xor    %r14d,%r14d
jmp    140a <simulate_average+0x23a>
xchg   %ax,%ax
mov    %rdi,%r12
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
mov    %r15d,%r8d
mov    $0x6,%r9d
call   1070 <one_step_normal@plt>
mov    %eax,%r14d
mov    %r12,%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    -0x34(%rbp),%rcx
call   1040 <fill_random@plt>
cmp    %r15d,%r14d
je     12b2 <simulate_average+0xe2>
mov    %r14d,%r15d
test   %ebx,%ebx
je     1450 <simulate_average+0x280>
cmp    $0x1,%ebx
lea    -0xc0(%rbp),%rdi
je     13d0 <simulate_average+0x200>
cmp    $0x2,%ebx
jne    12a0 <simulate_average+0xd0>
mov    %rdi,%r12
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
mov    %r15d,%r8d
mov    $0x6,%r9d
call   10b0 <one_step_big@plt>
jmp    13ec <simulate_average+0x21c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0xc0(%rbp),%r12
mov    %r12,%rdi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    %r13,%rcx
mov    %r15d,%r8d
mov    $0x6,%r9d
call   10d0 <one_step_small@plt>
jmp    13ec <simulate_average+0x21c>
lea    0xbc9(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
lea    0xb8f(%rip),%r14
mov    -0x78(%rbp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,8),%rdx
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x700(%rbp,%rbx,4),%xmm1
ff ff
cvtss2sd %xmm1,%xmm1
movss  -0x570(%rbp,%rbx,4),%xmm2
ff ff
cvtss2sd %xmm2,%xmm2
movss  -0x3e0(%rbp,%rbx,4),%xmm3
ff ff
cvtss2sd %xmm3,%xmm3
mov    -0x250(%rbp,%rbx,4),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%al
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    14a0 <simulate_average+0x2d0>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
lea    0xaf7(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"unknown table size\0A\00"
@.str.1 = [74 x i8] c"rank,tableID ,power ,ave power ,min power ,ave combo ,min combo\0A\00"
@.str.2 = [44 x i8] c"%4d,%13lld,%10.3f,%10.3f,%10.3f,%10.3f,%6d\0A\00"
define void @simulate_average(i32 %0, i64* %1, float* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, float %8, float %9) {
%11 = alloca i32
%12 = alloca i64*
%13 = alloca float*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca float
%20 = alloca float
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i64
%27 = alloca [6 x i64]
%28 = alloca i32
%29 = alloca float
%30 = alloca float
%31 = alloca float
%32 = alloca i32
%33 = alloca i8*
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32
%37 = alloca float
store i32 %0, i32* %11
store i64* %1, i64** %12
store float* %2, float** %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store float %8, float* %19
store float %9, float* %20
store i32 100, i32* %21
store i32 100, i32* %22
%38 = call i8* @llvm.stacksave()
store i8* %38, i8** %25
%39 = alloca float, i64 100
%40 = alloca float, i64 100
%41 = alloca float, i64 100
%42 = alloca i32, i64 100
%43 = call i64 @time(i32* null)
%44 = trunc i64 %43 to i32
%45 = add i32 98503, %44
store i32 %45, i32* %28
store i32 0, i32* %23
br label %46
46: ; preds = %169, %10
%47 = load i32, i32* %23
%48 = icmp slt i32 %47, 100
br i1 %48, label %49, label %172
49: ; preds = %46
%50 = load i64*, i64** %12
%51 = load i32, i32* %23
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i64, i64* %50, i64 %52
%54 = load i64, i64* %53
store i64 %54, i64* %26
store float 0.000000e+00, float* %29
store float 0.000000e+00, float* %30
store float 1.000000e+09, float* %31
store i32 100, i32* %32
store i32 0, i32* %24
br label %55
55: ; preds = %143, %49
%56 = load i32, i32* %24
%57 = icmp slt i32 %56, 10000
br i1 %57, label %58, label %146
58: ; preds = %55
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %33
%60 = alloca i32, i64 100
%61 = alloca i32, i64 100
%62 = alloca i32, i64 100
store i32 0, i32* %34
br label %63
63: ; preds = %70, %58
%64 = load i32, i32* %34
%65 = icmp slt i32 %64, 6
br i1 %65, label %66, label %73
66: ; preds = %63
%67 = load i32, i32* %34
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 %68
store i64 0, i64* %69
br label %70
70: ; preds = %66
%71 = load i32, i32* %34
%72 = add nsw i32 %71, 1
store i32 %72, i32* %34
br label %63
73: ; preds = %63
%74 = load i32, i32* %11
switch i32 %74, label %87 [
i32 0, label %75
i32 1, label %79
i32 2, label %83
]
75: ; preds = %73
%76 = load i64, i64* %26
%77 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%78 = call i32 @generate_table_small(i64 %76, i64* %77)
br label %91
79: ; preds = %73
%80 = load i64, i64* %26
%81 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%82 = call i32 @generate_table_normal(i64 %80, i64* %81)
br label %91
83: ; preds = %73
%84 = load i64, i64* %26
%85 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%86 = call i32 @generate_table_big(i64 %84, i64* %85)
br label %91
87: ; preds = %73
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %83, %79, %75
store i32 0, i32* %35
store i32 0, i32* %36
br label %92
92: ; preds = %112, %91
%93 = load i32, i32* %36
store i32 %93, i32* %35
%94 = load i32, i32* %11
switch i32 %94, label %107 [
i32 0, label %95
i32 1, label %99
i32 2, label %103
]
95: ; preds = %92
%96 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%97 = load i32, i32* %35
%98 = call i32 @one_step_small(i64* %96, i32* %60, i32* %61, i32* %62, i32 %97, i32 6)
store i32 %98, i32* %36
br label %107
99: ; preds = %92
%100 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%101 = load i32, i32* %35
%102 = call i32 @one_step_normal(i64* %100, i32* %60, i32* %61, i32* %62, i32 %101, i32 6)
store i32 %102, i32* %36
br label %107
103: ; preds = %92
%104 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%105 = load i32, i32* %35
%106 = call i32 @one_step_big(i64* %104, i32* %60, i32* %61, i32* %62, i32 %105, i32 6)
store i32 %106, i32* %36
br label %107
107: ; preds = %92, %103, %99, %95
%108 = getelementptr inbounds [6 x i64], [6 x i64]* %27, i64 0, i64 0
%109 = load i32, i32* %15
%110 = load i32, i32* %16
%111 = call i32 @fill_random(i64* %108, i32 %109, i32 %110, i32* %28)
br label %112
112: ; preds = %107
%113 = load i32, i32* %36
%114 = load i32, i32* %35
%115 = icmp ne i32 %113, %114
br i1 %115, label %92, label %116
116: ; preds = %112
%117 = load i32, i32* %35
%118 = load i32, i32* %17
%119 = load i32, i32* %18
%120 = load float, float* %19
%121 = load float, float* %20
%122 = call float @return_attack(i32 %117, i32* %60, i32* %61, i32* %62, i32 %118, i32 %119, float %120, float %121)
store float %122, float* %37
%123 = load float, float* %37
%124 = load float, float* %31
%125 = fcmp olt float %123, %124
br i1 %125, label %126, label %128
126: ; preds = %116
%127 = load float, float* %37
store float %127, float* %31
br label %128
128: ; preds = %126, %116
%129 = load i32, i32* %35
%130 = load i32, i32* %32
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %134
132: ; preds = %128
%133 = load i32, i32* %35
store i32 %133, i32* %32
br label %134
134: ; preds = %132, %128
%135 = load float, float* %37
%136 = load float, float* %29
%137 = fadd float %136, %135
store float %137, float* %29
%138 = load i32, i32* %35
%139 = sitofp i32 %138 to float
%140 = load float, float* %30
%141 = fadd float %140, %139
store float %141, float* %30
%142 = load i8*, i8** %33
br label %143
143: ; preds = %134
%144 = load i32, i32* %24
%145 = add nsw i32 %144, 1
store i32 %145, i32* %24
br label %55
146: ; preds = %55
%147 = load float, float* %30
%148 = fpext float %147 to double
%149 = fdiv double %148, 1.000000e+04
%150 = fptrunc double %149 to float
%151 = load i32, i32* %23
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds float, float* %41, i64 %152
store float %150, float* %153
%154 = load float, float* %29
%155 = fpext float %154 to double
%156 = fdiv double %155, 1.000000e+04
%157 = fptrunc double %156 to float
%158 = load i32, i32* %23
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds float, float* %39, i64 %159
store float %157, float* %160
%161 = load i32, i32* %32
%162 = load i32, i32* %23
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i32, i32* %42, i64 %163
store i32 %161, i32* %164
%165 = load float, float* %31
%166 = load i32, i32* %23
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds float, float* %40, i64 %167
store float %165, float* %168
br label %169
169: ; preds = %146
%170 = load i32, i32* %23
%171 = add nsw i32 %170, 1
store i32 %171, i32* %23
br label %46
172: ; preds = %46
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %23
br label %174
174: ; preds = %210, %172
%175 = load i32, i32* %23
%176 = icmp slt i32 %175, 100
br i1 %176, label %177, label %213
177: ; preds = %174
%178 = load i32, i32* %23
%179 = load i64*, i64** %12
%180 = load i32, i32* %23
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds i64, i64* %179, i64 %181
%183 = load i64, i64* %182
%184 = load float*, float** %13
%185 = load i32, i32* %23
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds float, float* %184, i64 %186
%188 = load float, float* %187
%189 = fpext float %188 to double
%190 = load i32, i32* %23
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds float, float* %39, i64 %191
%193 = load float, float* %192
%194 = fpext float %193 to double
%195 = load i32, i32* %23
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds float, float* %40, i64 %196
%198 = load float, float* %197
%199 = fpext float %198 to double
%200 = load i32, i32* %23
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds float, float* %41, i64 %201
%203 = load float, float* %202
%204 = fpext float %203 to double
%205 = load i32, i32* %23
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i32, i32* %42, i64 %206
%208 = load i32, i32* %207
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %178, i64 %183, double %189, double %194, double %199, double %204, i32 %208)
br label %210
210: ; preds = %177
%211 = load i32, i32* %23
%212 = add nsw i32 %211, 1
store i32 %212, i32* %23
br label %174
213: ; preds = %174
%214 = load i8*, i8** %25
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"unknown table size\0A\00"
@.str.2 = [44 x i8] c"%4d,%13lld,%10.3f,%10.3f,%10.3f,%10.3f,%6d\0A\00"
@str = [73 x i8] c"rank,tableID ,power ,ave power ,min power ,ave combo ,min combo\00"
define void @simulate_average(i32 %0, i64* nocapture %1, float* nocapture %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, float %8, float %9) {
%11 = alloca [6 x i64]
%12 = bitcast [6 x i64]* %11 to i8*
%13 = alloca i32
%14 = alloca [100 x float]
%15 = alloca [100 x float]
%16 = alloca [100 x float]
%17 = alloca [100 x i32]
%18 = bitcast i32* %13 to i8*
%19 = tail call i64 @time(i32* null)
%20 = trunc i64 %19 to i32
%21 = add i32 %20, 98503
store i32 %21, i32* %13
%22 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i64 0, i64 0
br label %23
23: ; preds = %10, %77
%24 = phi i64 [ 0, %10 ], [ %84, %77 ]
%25 = getelementptr inbounds i64, i64* %1, i64 %24
%26 = load i64, i64* %25
br label %27
27: ; preds = %23, %65
%28 = phi i32 [ 0, %23 ], [ %75, %65 ]
%29 = phi i32 [ 100, %23 ], [ %71, %65 ]
%30 = phi float [ 1.000000e+09, %23 ], [ %69, %65 ]
%31 = phi float [ 0.000000e+00, %23 ], [ %74, %65 ]
%32 = phi float [ 0.000000e+00, %23 ], [ %72, %65 ]
%33 = call i8* @llvm.stacksave()
%34 = alloca [100 x i32]
%35 = alloca [100 x i32]
%36 = alloca [100 x i32]
%37 = getelementptr inbounds [100 x i32], [100 x i32]* %35, i64 0, i64 0
%38 = getelementptr inbounds [100 x i32], [100 x i32]* %36, i64 0, i64 0
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %34, i64 0, i64 0
switch i32 %0, label %47 [
i32 0, label %40
i32 1, label %43
i32 2, label %45
]
40: ; preds = %27
%41 = call i32 @generate_table_small(i64 %26, i64* %22)
br label %42
42: ; preds = %45, %43, %40
br label %51
43: ; preds = %27
%44 = call i32 @generate_table_normal(i64 %26, i64* %22)
br label %42
45: ; preds = %27
%46 = call i32 @generate_table_big(i64 %26, i64* %22)
br label %42
47: ; preds = %27
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %42, %61
%52 = phi i32 [ %62, %61 ], [ 0, %42 ]
switch i32 %0, label %53 [
i32 0, label %55
i32 1, label %57
i32 2, label %59
]
53: ; preds = %51
%54 = call i32 @fill_random(i64* %22, i32 %4, i32 %5, i32* %13)
br label %65
55: ; preds = %51
%56 = call i32 @one_step_small(i64* %22, i32* %39, i32* %37, i32* %38, i32 %52, i32 6)
br label %61
57: ; preds = %51
%58 = call i32 @one_step_normal(i64* %22, i32* %39, i32* %37, i32* %38, i32 %52, i32 6)
br label %61
59: ; preds = %51
%60 = call i32 @one_step_big(i64* %22, i32* %39, i32* %37, i32* %38, i32 %52, i32 6)
br label %61
61: ; preds = %59, %57, %55
%62 = phi i32 [ %60, %59 ], [ %58, %57 ], [ %56, %55 ]
%63 = call i32 @fill_random(i64* %22, i32 %4, i32 %5, i32* %13)
%64 = icmp eq i32 %62, %52
br i1 %64, label %65, label %51
65: ; preds = %61, %53
%66 = phi i32 [ 0, %53 ], [ %52, %61 ]
%67 = call float @return_attack(i32 %66, i32* %39, i32* %37, i32* %38, i32 %6, i32 %7, float %8, float %9)
%68 = fcmp olt float %67, %30
%69 = select i1 %68, float %67, float %30
%70 = icmp slt i32 %66, %29
%71 = select i1 %70, i32 %66, i32 %29
%72 = fadd float %32, %67
%73 = sitofp i32 %66 to float
%74 = fadd float %31, %73
%75 = add nuw nsw i32 %28, 1
%76 = icmp eq i32 %75, 10000
br i1 %76, label %77, label %27
77: ; preds = %65
%78 = fdiv float %74, 1.000000e+04
%79 = getelementptr inbounds [100 x float], [100 x float]* %16, i64 0, i64 %24
store float %78, float* %79
%80 = fdiv float %72, 1.000000e+04
%81 = getelementptr inbounds [100 x float], [100 x float]* %14, i64 0, i64 %24
store float %80, float* %81
%82 = getelementptr inbounds [100 x i32], [100 x i32]* %17, i64 0, i64 %24
store i32 %71, i32* %82
%83 = getelementptr inbounds [100 x float], [100 x float]* %15, i64 0, i64 %24
store float %69, float* %83
%84 = add nuw nsw i64 %24, 1
%85 = icmp eq i64 %84, 100
br i1 %85, label %86, label %23
86: ; preds = %77
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str, i64 0, i64 0))
br label %88
88: ; preds = %86, %88
%89 = phi i64 [ 0, %86 ], [ %108, %88 ]
%90 = getelementptr inbounds i64, i64* %1, i64 %89
%91 = load i64, i64* %90
%92 = getelementptr inbounds float, float* %2, i64 %89
%93 = load float, float* %92
%94 = fpext float %93 to double
%95 = getelementptr inbounds [100 x float], [100 x float]* %14, i64 0, i64 %89
%96 = load float, float* %95
%97 = fpext float %96 to double
%98 = getelementptr inbounds [100 x float], [100 x float]* %15, i64 0, i64 %89
%99 = load float, float* %98
%100 = fpext float %99 to double
%101 = getelementptr inbounds [100 x float], [100 x float]* %16, i64 0, i64 %89
%102 = load float, float* %101
%103 = fpext float %102 to double
%104 = getelementptr inbounds [100 x i32], [100 x i32]* %17, i64 0, i64 %89
%105 = load i32, i32* %104
%106 = trunc i64 %89 to i32
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %106, i64 %91, double %94, double %97, double %100, double %103, i32 %105)
%108 = add nuw nsw i64 %89, 1
%109 = icmp eq i64 %108, 100
br i1 %109, label %110, label %88
110: ; preds = %88
ret void
}