#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int roll(short int x, int *bhealth, int *phealth, int *absorb, int *immune,
         int *weakened) {
  if (x == 99) {
    printf("Hero Finish! ");
    if (*immune) {
      printf("Unfortunately the boss was immune to your attack. :(\n");
    } else {
      *bhealth = 0;
      printf("Boss is instantly defeated!\n");
    }
  }
  if (x == 98) {
    printf("Death! Roll again, if doubles, no effect.\n");
    printf("Enter any character to roll (q to exit)...\n");
    if (getchar() == 'q') {
      printf("GOODBYE! :)\n");
      return 0;
    } else {
      while (getchar() != '\n')
        ;
    }
    int dice = rand() % 100;
    printf("You rolled a %02d.\n", dice);
    if (!(dice) || !(dice % 11)) {
      printf("Somehow the Death spell missed. You crudely smile and say "
             "\"CHECK OUT MY DOUBLES!\"\n");
    } else {
      printf("You died. GAME OVER.\n");
      return 1;
    }
  }
  if (x == 97) {
    *bhealth = 1000;
    printf("Revival! Boss fully heals to 1,000!\n");
  }
  if (x >= 91 && x <= 96) {
    *immune = 1;
    printf("Immunity! Boss is immune to all negative effects of the next roll "
           "(including Hero Finish).\n");
  }
  if (x >= 81 && x <= 90) {
    *absorb = 1;
    printf(
        "Damage Absorb! The damage value of your next roll heals the boss.\n");
  }
  if (x >= 71 && x <= 80) {
    printf("Limit Break! ");
    int damage = (rand() % 41) + 100;
    if (*weakened) {
      damage *= 2;
    }
    printf("You deal %d spell damage.\n", damage);
    if (*absorb) {
      *bhealth += damage;
      printf("The boss absorbed your attack and healed %d.\n", damage);
    } else if (*immune) {
      printf("Unfortunately the boss was immune to your attack. :(\n");
    } else {
      *bhealth -= damage;
    }
  }
  if (x >= 61 && x <= 70) {
    printf("Critical Hit! ");
    int damage = (rand() % 51) + 50;
    if (*weakened) {
      damage *= 2;
    }
    printf("You deal %d melee damage.\n", damage);
    if (*absorb) {
      *bhealth += damage;
      printf("The boss absorbed your attack and healed %d.\n", damage);
    } else if (*immune) {
      printf("Unfortunately the boss was immune to your attack. :(\n");
    } else {
      *bhealth -= damage;
    }
  }
  if (x >= 51 && x <= 60) {
    *weakened = 1;
    printf("Boss is weakened! Next two rolls do twice as much damage.\n");
  }
  if (x >= 41 && x <= 50) {
    int heal = (rand() % 21) + 70;
    *bhealth += heal;
    printf("Boss heals %d HP.\n", heal);
  }
  if (x >= 31 && x <= 40) {
    int damage = (rand() % 31) + 50;
    *phealth -= damage;
    printf("Boss deals %d damage.\n", damage);
  }
  if (x >= 21 && x <= 30) {
    int heal = (rand() % 21) + 30;
    *phealth += heal;
    printf("You heal %d HP.\n", heal);
  }
  if (x >= 11 && x <= 20) {
    int damage = (rand() % 41) + 50;
    if (*weakened) {
      damage *= 2;
    }
    printf("You deal %d spell damage.\n", damage);
    if (*absorb) {
      *bhealth += damage;
      printf("The boss absorbed your attack and healed %d.\n", damage);
    } else if (*immune) {
      printf("Unfortunately the boss was immune to your attack. :(\n");
    } else {
      *bhealth -= damage;
    }
  }
  if (x >= 0 && x <= 10) {
    int damage = (rand() % 41) + 20;
    if (*weakened) {
      damage *= 2;
    }
    printf("You deal %d melee damage.\n", damage);
    if (*absorb) {
      *bhealth += damage;
      printf("The boss absorbed your attack and healed %d.\n", damage);
    } else if (*immune) {
      printf("Unfortunately the boss was immune to your attack. :(\n");
    } else {
      *bhealth -= damage;
    }
  }
  if (*bhealth <= 0) {
    printf("Congratulations, you defeated the boss with %d HP left!\n",
           *phealth);
    return 1;
  }
  if (*phealth <= 0) {
    printf("You were killed by the boss. GAME OVER.\n");
    return 1;
  }
  printf("Hero HP: %d\t\tBoss HP: %d\n", *phealth, *bhealth);
  if (*absorb > 1) {
    *absorb = 0;
  } else if (*absorb) {
    *absorb += 1;
  }
  if (*immune > 1) {
    *immune = 0;
  } else if (*immune) {
    *immune += 1;
  }
  if (*weakened > 2) {
    *weakened = 0;
  } else {
    *weakened += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<roll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movswl -0x6(%rbp),%eax
cmp    $0x63,%eax
jne    11ab <roll+0x7b>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     118e <roll+0x5e>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a6 <roll+0x76>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <roll+0x7b>
movswl -0x6(%rbp),%eax
cmp    $0x62,%eax
jne    1296 <roll+0x166>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    1201 <roll+0xd1>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    184a <roll+0x71a>
jmp    1206 <roll+0xd6>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     121e <roll+0xee>
jmp    1206 <roll+0xd6>
jmp    1223 <roll+0xf3>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
je     1264 <roll+0x134>
mov    -0x34(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1277 <roll+0x147>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1291 <roll+0x161>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    184a <roll+0x71a>
jmp    1296 <roll+0x166>
movswl -0x6(%rbp),%eax
cmp    $0x61,%eax
jne    12bb <roll+0x18b>
mov    -0x10(%rbp),%rax
movl   $0x3e8,(%rax)
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x5b,%eax
jl     12ed <roll+0x1bd>
movswl -0x6(%rbp),%eax
cmp    $0x60,%eax
jg     12ed <roll+0x1bd>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x51,%eax
jl     131f <roll+0x1ef>
movswl -0x6(%rbp),%eax
cmp    $0x5a,%eax
jg     131f <roll+0x1ef>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x47,%eax
jl     13e8 <roll+0x2b8>
movswl -0x6(%rbp),%eax
cmp    $0x50,%eax
jg     13e8 <roll+0x2b8>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x29,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     1372 <roll+0x242>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     13b1 <roll+0x281>
mov    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13e3 <roll+0x2b3>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     13d1 <roll+0x2a1>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13de <roll+0x2ae>
mov    -0x38(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    13e3 <roll+0x2b3>
jmp    13e8 <roll+0x2b8>
movswl -0x6(%rbp),%eax
cmp    $0x3d,%eax
jl     14b1 <roll+0x381>
movswl -0x6(%rbp),%eax
cmp    $0x46,%eax
jg     14b1 <roll+0x381>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x33,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
mov    %edx,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     143b <roll+0x30b>
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     147a <roll+0x34a>
mov    -0x3c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x3c(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ac <roll+0x37c>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     149a <roll+0x36a>
lea    0xb80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14a7 <roll+0x377>
mov    -0x3c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    14ac <roll+0x37c>
jmp    14b1 <roll+0x381>
movswl -0x6(%rbp),%eax
cmp    $0x33,%eax
jl     14e3 <roll+0x3b3>
movswl -0x6(%rbp),%eax
cmp    $0x3c,%eax
jg     14e3 <roll+0x3b3>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x29,%eax
jl     152e <roll+0x3fe>
movswl -0x6(%rbp),%eax
cmp    $0x32,%eax
jg     152e <roll+0x3fe>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x15,%ecx
cltd
idiv   %ecx
add    $0x46,%edx
mov    %edx,-0x40(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x40(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x1f,%eax
jl     157b <roll+0x44b>
movswl -0x6(%rbp),%eax
cmp    $0x28,%eax
jg     157b <roll+0x44b>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1f,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
mov    %edx,-0x44(%rbp)
mov    -0x44(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x44(%rbp),%esi
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0x15,%eax
jl     15c6 <roll+0x496>
movswl -0x6(%rbp),%eax
cmp    $0x1e,%eax
jg     15c6 <roll+0x496>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x15,%ecx
cltd
idiv   %ecx
add    $0x1e,%edx
mov    %edx,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x48(%rbp),%esi
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x6(%rbp),%eax
cmp    $0xb,%eax
jl     1681 <roll+0x551>
movswl -0x6(%rbp),%eax
cmp    $0x14,%eax
jg     1681 <roll+0x551>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x29,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
mov    %edx,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     160b <roll+0x4db>
mov    -0x4c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     164a <roll+0x51a>
mov    -0x4c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x4c(%rbp),%esi
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    167c <roll+0x54c>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     166a <roll+0x53a>
lea    0x9b0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1677 <roll+0x547>
mov    -0x4c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    167c <roll+0x54c>
jmp    1681 <roll+0x551>
movswl -0x6(%rbp),%eax
cmp    $0x0,%eax
jl     173c <roll+0x60c>
movswl -0x6(%rbp),%eax
cmp    $0xa,%eax
jg     173c <roll+0x60c>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x29,%ecx
cltd
idiv   %ecx
add    $0x14,%edx
mov    %edx,-0x50(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     16c6 <roll+0x596>
mov    -0x50(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%esi
lea    0xb9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1705 <roll+0x5d5>
mov    -0x50(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x50(%rbp),%esi
lea    0xb36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1737 <roll+0x607>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     1725 <roll+0x5f5>
lea    0x8f5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1732 <roll+0x602>
mov    -0x50(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    1737 <roll+0x607>
jmp    173c <roll+0x60c>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1769 <roll+0x639>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    184a <roll+0x71a>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1790 <roll+0x660>
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    184a <roll+0x71a>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x1,(%rax)
jle    17c6 <roll+0x696>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    17e3 <roll+0x6b3>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     17de <roll+0x6ae>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    17e3 <roll+0x6b3>
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
jle    17ff <roll+0x6cf>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    181c <roll+0x6ec>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     1817 <roll+0x6e7>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    181c <roll+0x6ec>
mov    -0x30(%rbp),%rax
cmpl   $0x2,(%rax)
jle    1838 <roll+0x708>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
jmp    1843 <roll+0x713>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roll>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r13
mov    %rdx,%r12
mov    %rsi,%r15
mov    %edi,%ebp
cmp    $0x61,%bp
mov    %rcx,(%rsp)
je     1198 <roll+0x58>
cmp    $0x62,%bp
je     11ab <roll+0x6b>
cmp    $0x63,%bp
jne    1289 <roll+0x149>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x0(%r13)
je     1266 <roll+0x126>
lea    0x11a5(%rip),%rdi
jmp    12bd <roll+0x17d>
movl   $0x3e8,(%r15)
lea    0x108a(%rip),%rdi
jmp    12bd <roll+0x17d>
lea    0x10a2(%rip),%rdi
call   1030 <puts@plt>
lea    0x10c0(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x71,%al
jne    11e1 <roll+0xa1>
lea    0x1139(%rip),%rdi
call   1030 <puts@plt>
jmp    1343 <roll+0x203>
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11f0 <roll+0xb0>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r14
imul   $0x51eb851f,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r14d
lea    0xde8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     1276 <roll+0x136>
movsbl %r14b,%eax
imul   $0xffffffbb,%eax,%eax
shr    $0x8,%eax
add    %r14b,%al
mov    %eax,%ecx
shr    $0x7,%cl
sar    $0x3,%al
add    %cl,%al
movzbl %al,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
sub    %al,%r14b
je     1276 <roll+0x136>
lea    0x109a(%rip),%rdi
jmp    1339 <roll+0x1f9>
movl   $0x0,(%r15)
lea    0x10a8(%rip),%rdi
jmp    12bd <roll+0x17d>
lea    0x102c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%r14
mov    (%rsp),%rcx
lea    -0x5b(%rbp),%eax
cmp    $0x5,%ax
ja     12a3 <roll+0x163>
movl   $0x1,0x0(%r13)
lea    0xf34(%rip),%rdi
jmp    12bd <roll+0x17d>
lea    -0x51(%rbp),%eax
cmp    $0x9,%ax
ja     1354 <roll+0x214>
movl   $0x1,(%rcx)
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%edx
mov    (%r12),%esi
test   %edx,%edx
jle    1322 <roll+0x1e2>
test   %esi,%esi
jle    1332 <roll+0x1f2>
lea    0xe3f(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rcx
mov    (%rcx),%eax
cmp    $0x1,%eax
jg     12f5 <roll+0x1b5>
test   %eax,%eax
je     12f7 <roll+0x1b7>
add    $0x1,%eax
mov    %eax,%ebx
mov    %ebx,(%rcx)
mov    0x0(%r13),%eax
xor    %ecx,%ecx
cmp    $0x1,%eax
jg     130b <roll+0x1cb>
test   %eax,%eax
je     130f <roll+0x1cf>
add    $0x1,%eax
mov    %eax,%ecx
mov    %ecx,0x0(%r13)
mov    (%r14),%eax
lea    0x1(%rax),%ecx
xor    %ebx,%ebx
cmp    $0x3,%eax
cmovge %ebx,%ecx
mov    %ecx,(%r14)
jmp    1343 <roll+0x203>
lea    0xdb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    133e <roll+0x1fe>
lea    0xdf8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    -0x47(%rbp),%eax
cmp    $0x9,%ax
ja     13a8 <roll+0x268>
lea    0xcbe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x63e7063f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,8),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x64,%ebx
cmpl   $0x0,(%r14)
setne  %cl
shl    %cl,%ebx
lea    0xc8a(%rip),%rdi
jmp    13fe <roll+0x2be>
lea    -0x3d(%rbp),%eax
cmp    $0x9,%ax
ja     143b <roll+0x2fb>
lea    0xcbd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffffa0a0a0a1,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x33,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x32,%ebx
cmpl   $0x0,(%r14)
setne  %cl
shl    %cl,%ebx
lea    0xc8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rax
cmpl   $0x0,(%rax)
je     1428 <roll+0x2e8>
add    %ebx,(%r15)
lea    0xc31(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12c2 <roll+0x182>
cmpl   $0x0,0x0(%r13)
jne    118c <roll+0x4c>
sub    %ebx,(%r15)
jmp    12c2 <roll+0x182>
lea    -0x33(%rbp),%eax
cmp    $0x9,%ax
ja     1457 <roll+0x317>
movl   $0x1,(%r14)
lea    0xd07(%rip),%rdi
jmp    12bd <roll+0x17d>
lea    -0x29(%rbp),%eax
cmp    $0x9,%ax
ja     1497 <roll+0x357>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x30c30c31,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x46,%esi
add    %esi,(%r15)
lea    0xc0e(%rip),%rdi
jmp    141c <roll+0x2dc>
lea    -0x1f(%rbp),%eax
cmp    $0x9,%ax
ja     14dd <roll+0x39d>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffff84210843,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
sub    %edx,%ecx
lea    (%rax,%rcx,1),%esi
add    $0x32,%esi
sub    %esi,(%r12)
lea    0xbde(%rip),%rdi
jmp    141c <roll+0x2dc>
lea    -0x15(%rbp),%eax
cmp    $0x9,%ax
ja     1521 <roll+0x3e1>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x30c30c31,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x1e,%esi
add    %esi,(%r12)
lea    0xbb1(%rip),%rdi
jmp    141c <roll+0x2dc>
lea    -0xb(%rbp),%eax
cmp    $0x9,%ax
ja     155a <roll+0x41a>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x63e7063f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,8),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x32,%ebx
jmp    1396 <roll+0x256>
cmp    $0xa,%bp
ja     12c2 <roll+0x182>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x63e7063f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,8),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x14,%ebx
cmpl   $0x0,(%r14)
setne  %cl
shl    %cl,%ebx
lea    0xae9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rax
cmpl   $0x0,(%rax)
jne    1410 <roll+0x2d0>
cmpl   $0x0,0x0(%r13)
jne    118c <roll+0x4c>
mov    (%r15),%edx
sub    %ebx,%edx
mov    %edx,(%r15)
jmp    12c5 <roll+0x185>

LLVM IR (-O0):
@.str = [14 x i8] c"Hero Finish! \00"
@.str.1 = [54 x i8] c"Unfortunately the boss was immune to your attack. :(\0A\00"
@.str.2 = [29 x i8] c"Boss is instantly defeated!\0A\00"
@.str.3 = [43 x i8] c"Death! Roll again, if doubles, no effect.\0A\00"
@.str.4 = [44 x i8] c"Enter any character to roll (q to exit)...\0A\00"
@.str.5 = [13 x i8] c"GOODBYE! :)\0A\00"
@.str.6 = [20 x i8] c"You rolled a %02d.\0A\00"
@.str.7 = [83 x i8] c"Somehow the Death spell missed. You crudely smile and say \22CHECK OUT MY DOUBLES!\22\0A\00"
@.str.8 = [22 x i8] c"You died. GAME OVER.\0A\00"
@.str.9 = [37 x i8] c"Revival! Boss fully heals to 1,000!\0A\00"
@.str.10 = [92 x i8] c"Immunity! Boss is immune to all negative effects of the next roll (including Hero Finish).\0A\00"
@.str.11 = [67 x i8] c"Damage Absorb! The damage value of your next roll heals the boss.\0A\00"
@.str.12 = [14 x i8] c"Limit Break! \00"
@.str.13 = [27 x i8] c"You deal %d spell damage.\0A\00"
@.str.14 = [46 x i8] c"The boss absorbed your attack and healed %d.\0A\00"
@.str.15 = [15 x i8] c"Critical Hit! \00"
@.str.16 = [27 x i8] c"You deal %d melee damage.\0A\00"
@.str.17 = [59 x i8] c"Boss is weakened! Next two rolls do twice as much damage.\0A\00"
@.str.18 = [19 x i8] c"Boss heals %d HP.\0A\00"
@.str.19 = [23 x i8] c"Boss deals %d damage.\0A\00"
@.str.20 = [17 x i8] c"You heal %d HP.\0A\00"
@.str.21 = [57 x i8] c"Congratulations, you defeated the boss with %d HP left!\0A\00"
@.str.22 = [41 x i8] c"You were killed by the boss. GAME OVER.\0A\00"
@.str.23 = [26 x i8] c"Hero HP: %d\09\09Boss HP: %d\0A\00"
define i32 @roll(i16 signext %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i16
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i16 %0, i16* %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%22 = load i16, i16* %8
%23 = sext i16 %22 to i32
%24 = icmp eq i32 %23, 99
br i1 %24, label %25, label %36
25: ; preds = %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%27 = load i32*, i32** %12
%28 = load i32, i32* %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %35
32: ; preds = %25
%33 = load i32*, i32** %9
store i32 0, i32* %33
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %32, %30
br label %36
36: ; preds = %35, %6
%37 = load i16, i16* %8
%38 = sext i16 %37 to i32
%39 = icmp eq i32 %38, 98
br i1 %39, label %40, label %71
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%43 = call signext i8 (...) @getchar()
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 113
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %403
48: ; preds = %40
br label %49
49: ; preds = %53, %48
%50 = call signext i8 (...) @getchar()
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 10
br i1 %52, label %53, label %54
53: ; preds = %49
br label %49
54: ; preds = %49
br label %55
55: ; preds = %54
%56 = call i32 (...) @rand()
%57 = srem i32 %56, 100
store i32 %57, i32* %14
%58 = load i32, i32* %14
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %14
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %55
%63 = load i32, i32* %14
%64 = srem i32 %63, 11
%65 = icmp ne i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %62, %55
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.7, i64 0, i64 0))
br label %70
68: ; preds = %62
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %7
br label %403
70: ; preds = %66
br label %71
71: ; preds = %70, %36
%72 = load i16, i16* %8
%73 = sext i16 %72 to i32
%74 = icmp eq i32 %73, 97
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = load i32*, i32** %9
store i32 1000, i32* %76
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %78
78: ; preds = %75, %71
%79 = load i16, i16* %8
%80 = sext i16 %79 to i32
%81 = icmp sge i32 %80, 91
br i1 %81, label %82, label %89
82: ; preds = %78
%83 = load i16, i16* %8
%84 = sext i16 %83 to i32
%85 = icmp sle i32 %84, 96
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i32*, i32** %12
store i32 1, i32* %87
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
br label %89
89: ; preds = %86, %82, %78
%90 = load i16, i16* %8
%91 = sext i16 %90 to i32
%92 = icmp sge i32 %91, 81
br i1 %92, label %93, label %100
93: ; preds = %89
%94 = load i16, i16* %8
%95 = sext i16 %94 to i32
%96 = icmp sle i32 %95, 90
br i1 %96, label %97, label %100
97: ; preds = %93
%98 = load i32*, i32** %11
store i32 1, i32* %98
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.11, i64 0, i64 0))
br label %100
100: ; preds = %97, %93, %89
%101 = load i16, i16* %8
%102 = sext i16 %101 to i32
%103 = icmp sge i32 %102, 71
br i1 %103, label %104, label %145
104: ; preds = %100
%105 = load i16, i16* %8
%106 = sext i16 %105 to i32
%107 = icmp sle i32 %106, 80
br i1 %107, label %108, label %145
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%110 = call i32 (...) @rand()
%111 = srem i32 %110, 41
%112 = add nsw i32 %111, 100
store i32 %112, i32* %15
%113 = load i32*, i32** %13
%114 = load i32, i32* %113
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %108
%117 = load i32, i32* %15
%118 = mul nsw i32 %117, 2
store i32 %118, i32* %15
br label %119
119: ; preds = %116, %108
%120 = load i32, i32* %15
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i32 %120)
%122 = load i32*, i32** %11
%123 = load i32, i32* %122
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %132
125: ; preds = %119
%126 = load i32, i32* %15
%127 = load i32*, i32** %9
%128 = load i32, i32* %127
%129 = add nsw i32 %128, %126
store i32 %129, i32* %127
%130 = load i32, i32* %15
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %130)
br label %144
132: ; preds = %119
%133 = load i32*, i32** %12
%134 = load i32, i32* %133
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %132
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %143
138: ; preds = %132
%139 = load i32, i32* %15
%140 = load i32*, i32** %9
%141 = load i32, i32* %140
%142 = sub nsw i32 %141, %139
store i32 %142, i32* %140
br label %143
143: ; preds = %138, %136
br label %144
144: ; preds = %143, %125
br label %145
145: ; preds = %144, %104, %100
%146 = load i16, i16* %8
%147 = sext i16 %146 to i32
%148 = icmp sge i32 %147, 61
br i1 %148, label %149, label %190
149: ; preds = %145
%150 = load i16, i16* %8
%151 = sext i16 %150 to i32
%152 = icmp sle i32 %151, 70
br i1 %152, label %153, label %190
153: ; preds = %149
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%155 = call i32 (...) @rand()
%156 = srem i32 %155, 51
%157 = add nsw i32 %156, 50
store i32 %157, i32* %16
%158 = load i32*, i32** %13
%159 = load i32, i32* %158
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %164
161: ; preds = %153
%162 = load i32, i32* %16
%163 = mul nsw i32 %162, 2
store i32 %163, i32* %16
br label %164
164: ; preds = %161, %153
%165 = load i32, i32* %16
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %165)
%167 = load i32*, i32** %11
%168 = load i32, i32* %167
%169 = icmp ne i32 %168, 0
br i1 %169, label %170, label %177
170: ; preds = %164
%171 = load i32, i32* %16
%172 = load i32*, i32** %9
%173 = load i32, i32* %172
%174 = add nsw i32 %173, %171
store i32 %174, i32* %172
%175 = load i32, i32* %16
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %175)
br label %189
177: ; preds = %164
%178 = load i32*, i32** %12
%179 = load i32, i32* %178
%180 = icmp ne i32 %179, 0
br i1 %180, label %181, label %183
181: ; preds = %177
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %188
183: ; preds = %177
%184 = load i32, i32* %16
%185 = load i32*, i32** %9
%186 = load i32, i32* %185
%187 = sub nsw i32 %186, %184
store i32 %187, i32* %185
br label %188
188: ; preds = %183, %181
br label %189
189: ; preds = %188, %170
br label %190
190: ; preds = %189, %149, %145
%191 = load i16, i16* %8
%192 = sext i16 %191 to i32
%193 = icmp sge i32 %192, 51
br i1 %193, label %194, label %201
194: ; preds = %190
%195 = load i16, i16* %8
%196 = sext i16 %195 to i32
%197 = icmp sle i32 %196, 60
br i1 %197, label %198, label %201
198: ; preds = %194
%199 = load i32*, i32** %13
store i32 1, i32* %199
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.17, i64 0, i64 0))
br label %201
201: ; preds = %198, %194, %190
%202 = load i16, i16* %8
%203 = sext i16 %202 to i32
%204 = icmp sge i32 %203, 41
br i1 %204, label %205, label %219
205: ; preds = %201
%206 = load i16, i16* %8
%207 = sext i16 %206 to i32
%208 = icmp sle i32 %207, 50
br i1 %208, label %209, label %219
209: ; preds = %205
%210 = call i32 (...) @rand()
%211 = srem i32 %210, 21
%212 = add nsw i32 %211, 70
store i32 %212, i32* %17
%213 = load i32, i32* %17
%214 = load i32*, i32** %9
%215 = load i32, i32* %214
%216 = add nsw i32 %215, %213
store i32 %216, i32* %214
%217 = load i32, i32* %17
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i32 %217)
br label %219
219: ; preds = %209, %205, %201
%220 = load i16, i16* %8
%221 = sext i16 %220 to i32
%222 = icmp sge i32 %221, 31
br i1 %222, label %223, label %237
223: ; preds = %219
%224 = load i16, i16* %8
%225 = sext i16 %224 to i32
%226 = icmp sle i32 %225, 40
br i1 %226, label %227, label %237
227: ; preds = %223
%228 = call i32 (...) @rand()
%229 = srem i32 %228, 31
%230 = add nsw i32 %229, 50
store i32 %230, i32* %18
%231 = load i32, i32* %18
%232 = load i32*, i32** %10
%233 = load i32, i32* %232
%234 = sub nsw i32 %233, %231
store i32 %234, i32* %232
%235 = load i32, i32* %18
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0), i32 %235)
br label %237
237: ; preds = %227, %223, %219
%238 = load i16, i16* %8
%239 = sext i16 %238 to i32
%240 = icmp sge i32 %239, 21
br i1 %240, label %241, label %255
241: ; preds = %237
%242 = load i16, i16* %8
%243 = sext i16 %242 to i32
%244 = icmp sle i32 %243, 30
br i1 %244, label %245, label %255
245: ; preds = %241
%246 = call i32 (...) @rand()
%247 = srem i32 %246, 21
%248 = add nsw i32 %247, 30
store i32 %248, i32* %19
%249 = load i32, i32* %19
%250 = load i32*, i32** %10
%251 = load i32, i32* %250
%252 = add nsw i32 %251, %249
store i32 %252, i32* %250
%253 = load i32, i32* %19
%254 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %253)
br label %255
255: ; preds = %245, %241, %237
%256 = load i16, i16* %8
%257 = sext i16 %256 to i32
%258 = icmp sge i32 %257, 11
br i1 %258, label %259, label %299
259: ; preds = %255
%260 = load i16, i16* %8
%261 = sext i16 %260 to i32
%262 = icmp sle i32 %261, 20
br i1 %262, label %263, label %299
263: ; preds = %259
%264 = call i32 (...) @rand()
%265 = srem i32 %264, 41
%266 = add nsw i32 %265, 50
store i32 %266, i32* %20
%267 = load i32*, i32** %13
%268 = load i32, i32* %267
%269 = icmp ne i32 %268, 0
br i1 %269, label %270, label %273
270: ; preds = %263
%271 = load i32, i32* %20
%272 = mul nsw i32 %271, 2
store i32 %272, i32* %20
br label %273
273: ; preds = %270, %263
%274 = load i32, i32* %20
%275 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i32 %274)
%276 = load i32*, i32** %11
%277 = load i32, i32* %276
%278 = icmp ne i32 %277, 0
br i1 %278, label %279, label %286
279: ; preds = %273
%280 = load i32, i32* %20
%281 = load i32*, i32** %9
%282 = load i32, i32* %281
%283 = add nsw i32 %282, %280
store i32 %283, i32* %281
%284 = load i32, i32* %20
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %284)
br label %298
286: ; preds = %273
%287 = load i32*, i32** %12
%288 = load i32, i32* %287
%289 = icmp ne i32 %288, 0
br i1 %289, label %290, label %292
290: ; preds = %286
%291 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %297
292: ; preds = %286
%293 = load i32, i32* %20
%294 = load i32*, i32** %9
%295 = load i32, i32* %294
%296 = sub nsw i32 %295, %293
store i32 %296, i32* %294
br label %297
297: ; preds = %292, %290
br label %298
298: ; preds = %297, %279
br label %299
299: ; preds = %298, %259, %255
%300 = load i16, i16* %8
%301 = sext i16 %300 to i32
%302 = icmp sge i32 %301, 0
br i1 %302, label %303, label %343
303: ; preds = %299
%304 = load i16, i16* %8
%305 = sext i16 %304 to i32
%306 = icmp sle i32 %305, 10
br i1 %306, label %307, label %343
307: ; preds = %303
%308 = call i32 (...) @rand()
%309 = srem i32 %308, 41
%310 = add nsw i32 %309, 20
store i32 %310, i32* %21
%311 = load i32*, i32** %13
%312 = load i32, i32* %311
%313 = icmp ne i32 %312, 0
br i1 %313, label %314, label %317
314: ; preds = %307
%315 = load i32, i32* %21
%316 = mul nsw i32 %315, 2
store i32 %316, i32* %21
br label %317
317: ; preds = %314, %307
%318 = load i32, i32* %21
%319 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %318)
%320 = load i32*, i32** %11
%321 = load i32, i32* %320
%322 = icmp ne i32 %321, 0
br i1 %322, label %323, label %330
323: ; preds = %317
%324 = load i32, i32* %21
%325 = load i32*, i32** %9
%326 = load i32, i32* %325
%327 = add nsw i32 %326, %324
store i32 %327, i32* %325
%328 = load i32, i32* %21
%329 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %328)
br label %342
330: ; preds = %317
%331 = load i32*, i32** %12
%332 = load i32, i32* %331
%333 = icmp ne i32 %332, 0
br i1 %333, label %334, label %336
334: ; preds = %330
%335 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %341
336: ; preds = %330
%337 = load i32, i32* %21
%338 = load i32*, i32** %9
%339 = load i32, i32* %338
%340 = sub nsw i32 %339, %337
store i32 %340, i32* %338
br label %341
341: ; preds = %336, %334
br label %342
342: ; preds = %341, %323
br label %343
343: ; preds = %342, %303, %299
%344 = load i32*, i32** %9
%345 = load i32, i32* %344
%346 = icmp sle i32 %345, 0
br i1 %346, label %347, label %351
347: ; preds = %343
%348 = load i32*, i32** %10
%349 = load i32, i32* %348
%350 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.21, i64 0, i64 0), i32 %349)
store i32 1, i32* %7
br label %403
351: ; preds = %343
%352 = load i32*, i32** %10
%353 = load i32, i32* %352
%354 = icmp sle i32 %353, 0
br i1 %354, label %355, label %357
355: ; preds = %351
%356 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.22, i64 0, i64 0))
store i32 1, i32* %7
br label %403
357: ; preds = %351
%358 = load i32*, i32** %10
%359 = load i32, i32* %358
%360 = load i32*, i32** %9
%361 = load i32, i32* %360
%362 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.23, i64 0, i64 0), i32 %359, i32 %361)
%363 = load i32*, i32** %11
%364 = load i32, i32* %363
%365 = icmp sgt i32 %364, 1
br i1 %365, label %366, label %368
366: ; preds = %357
%367 = load i32*, i32** %11
store i32 0, i32* %367
br label %377
368: ; preds = %357
%369 = load i32*, i32** %11
%370 = load i32, i32* %369
%371 = icmp ne i32 %370, 0
br i1 %371, label %372, label %376
372: ; preds = %368
%373 = load i32*, i32** %11
%374 = load i32, i32* %373
%375 = add nsw i32 %374, 1
store i32 %375, i32* %373
br label %376
376: ; preds = %372, %368
br label %377
377: ; preds = %376, %366
%378 = load i32*, i32** %12
%379 = load i32, i32* %378
%380 = icmp sgt i32 %379, 1
br i1 %380, label %381, label %383
381: ; preds = %377
%382 = load i32*, i32** %12
store i32 0, i32* %382
br label %392
383: ; preds = %377
%384 = load i32*, i32** %12
%385 = load i32, i32* %384
%386 = icmp ne i32 %385, 0
br i1 %386, label %387, label %391
387: ; preds = %383
%388 = load i32*, i32** %12
%389 = load i32, i32* %388
%390 = add nsw i32 %389, 1
store i32 %390, i32* %388
br label %391
391: ; preds = %387, %383
br label %392
392: ; preds = %391, %381
%393 = load i32*, i32** %13
%394 = load i32, i32* %393
%395 = icmp sgt i32 %394, 2
br i1 %395, label %396, label %398
396: ; preds = %392
%397 = load i32*, i32** %13
store i32 0, i32* %397
br label %402
398: ; preds = %392
%399 = load i32*, i32** %13
%400 = load i32, i32* %399
%401 = add nsw i32 %400, 1
store i32 %401, i32* %399
br label %402
402: ; preds = %398, %396
store i32 0, i32* %7
br label %403
403: ; preds = %402, %355, %347, %68, %46
%404 = load i32, i32* %7
ret i32 %404
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hero Finish! \00"
@.str.6 = [20 x i8] c"You rolled a %02d.\0A\00"
@.str.12 = [14 x i8] c"Limit Break! \00"
@.str.13 = [27 x i8] c"You deal %d spell damage.\0A\00"
@.str.14 = [46 x i8] c"The boss absorbed your attack and healed %d.\0A\00"
@.str.15 = [15 x i8] c"Critical Hit! \00"
@.str.16 = [27 x i8] c"You deal %d melee damage.\0A\00"
@.str.18 = [19 x i8] c"Boss heals %d HP.\0A\00"
@.str.19 = [23 x i8] c"Boss deals %d damage.\0A\00"
@.str.20 = [17 x i8] c"You heal %d HP.\0A\00"
@.str.21 = [57 x i8] c"Congratulations, you defeated the boss with %d HP left!\0A\00"
@.str.23 = [26 x i8] c"Hero HP: %d\09\09Boss HP: %d\0A\00"
@str = [40 x i8] c"You were killed by the boss. GAME OVER.\00"
@str.26 = [58 x i8] c"Boss is weakened! Next two rolls do twice as much damage.\00"
@str.29 = [66 x i8] c"Damage Absorb! The damage value of your next roll heals the boss.\00"
@str.30 = [91 x i8] c"Immunity! Boss is immune to all negative effects of the next roll (including Hero Finish).\00"
@str.31 = [36 x i8] c"Revival! Boss fully heals to 1,000!\00"
@str.32 = [42 x i8] c"Death! Roll again, if doubles, no effect.\00"
@str.33 = [43 x i8] c"Enter any character to roll (q to exit)...\00"
@str.34 = [82 x i8] c"Somehow the Death spell missed. You crudely smile and say \22CHECK OUT MY DOUBLES!\22\00"
@str.35 = [21 x i8] c"You died. GAME OVER.\00"
@str.36 = [12 x i8] c"GOODBYE! :)\00"
@str.37 = [28 x i8] c"Boss is instantly defeated!\00"
@str.38 = [53 x i8] c"Unfortunately the boss was immune to your attack. :(\00"
define i32 @roll(i16 signext %0, i32* %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture %4, i32* nocapture %5) {
switch i16 %0, label %40 [
i16 99, label %7
i16 98, label %15
i16 97, label %38
]
7: ; preds = %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.38, i64 0, i64 0))
br label %190
13: ; preds = %7
store i32 0, i32* %1
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.37, i64 0, i64 0))
br label %190
15: ; preds = %6
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.32, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.33, i64 0, i64 0))
%18 = tail call signext i8 (...) @getchar()
%19 = icmp eq i8 %18, 113
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.36, i64 0, i64 0))
br label %226
22: ; preds = %15, %22
%23 = tail call signext i8 (...) @getchar()
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %22
25: ; preds = %22
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 100
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %27)
%29 = icmp eq i32 %27, 0
%30 = trunc i32 %27 to i8
%31 = srem i8 %30, 11
%32 = icmp eq i8 %31, 0
%33 = or i1 %29, %32
br i1 %33, label %36, label %34
34: ; preds = %25
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.35, i64 0, i64 0))
br label %226
36: ; preds = %25
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.34, i64 0, i64 0))
br label %40
38: ; preds = %6
store i32 1000, i32* %1
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.31, i64 0, i64 0))
br label %190
40: ; preds = %36, %6
%41 = add i16 %0, -91
%42 = icmp ult i16 %41, 6
br i1 %42, label %43, label %45
43: ; preds = %40
store i32 1, i32* %4
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.30, i64 0, i64 0))
br label %190
45: ; preds = %40
%46 = add i16 %0, -81
%47 = icmp ult i16 %46, 10
br i1 %47, label %48, label %50
48: ; preds = %45
store i32 1, i32* %3
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.29, i64 0, i64 0))
br label %190
50: ; preds = %45
%51 = add i16 %0, -71
%52 = icmp ult i16 %51, 10
br i1 %52, label %53, label %77
53: ; preds = %50
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%55 = tail call i32 (...) @rand()
%56 = srem i32 %55, 41
%57 = add nsw i32 %56, 100
%58 = load i32, i32* %5
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i32
%61 = shl nuw nsw i32 %57, %60
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %3
%64 = icmp eq i32 %63, 0
br i1 %64, label %69, label %65
65: ; preds = %53
%66 = load i32, i32* %1
%67 = add nsw i32 %66, %61
store i32 %67, i32* %1
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %61)
br label %190
69: ; preds = %53
%70 = load i32, i32* %4
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.38, i64 0, i64 0))
br label %190
74: ; preds = %69
%75 = load i32, i32* %1
%76 = sub nsw i32 %75, %61
store i32 %76, i32* %1
br label %190
77: ; preds = %50
%78 = add i16 %0, -61
%79 = icmp ult i16 %78, 10
br i1 %79, label %80, label %104
80: ; preds = %77
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%82 = tail call i32 (...) @rand()
%83 = srem i32 %82, 51
%84 = add nsw i32 %83, 50
%85 = load i32, i32* %5
%86 = icmp ne i32 %85, 0
%87 = zext i1 %86 to i32
%88 = shl nuw nsw i32 %84, %87
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %88)
%90 = load i32, i32* %3
%91 = icmp eq i32 %90, 0
br i1 %91, label %96, label %92
92: ; preds = %80
%93 = load i32, i32* %1
%94 = add nsw i32 %93, %88
store i32 %94, i32* %1
%95 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %88)
br label %190
96: ; preds = %80
%97 = load i32, i32* %4
%98 = icmp eq i32 %97, 0
br i1 %98, label %101, label %99
99: ; preds = %96
%100 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.38, i64 0, i64 0))
br label %190
101: ; preds = %96
%102 = load i32, i32* %1
%103 = sub nsw i32 %102, %88
store i32 %103, i32* %1
br label %190
104: ; preds = %77
%105 = add i16 %0, -51
%106 = icmp ult i16 %105, 10
br i1 %106, label %107, label %109
107: ; preds = %104
store i32 1, i32* %5
%108 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.26, i64 0, i64 0))
br label %190
109: ; preds = %104
%110 = add i16 %0, -41
%111 = icmp ult i16 %110, 10
br i1 %111, label %112, label %119
112: ; preds = %109
%113 = tail call i32 (...) @rand()
%114 = srem i32 %113, 21
%115 = add nsw i32 %114, 70
%116 = load i32, i32* %1
%117 = add nsw i32 %115, %116
store i32 %117, i32* %1
%118 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i32 %115)
br label %190
119: ; preds = %109
%120 = add i16 %0, -31
%121 = icmp ult i16 %120, 10
br i1 %121, label %122, label %129
122: ; preds = %119
%123 = tail call i32 (...) @rand()
%124 = srem i32 %123, 31
%125 = add nsw i32 %124, 50
%126 = load i32, i32* %2
%127 = sub nsw i32 %126, %125
store i32 %127, i32* %2
%128 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0), i32 %125)
br label %190
129: ; preds = %119
%130 = add i16 %0, -21
%131 = icmp ult i16 %130, 10
br i1 %131, label %132, label %139
132: ; preds = %129
%133 = tail call i32 (...) @rand()
%134 = srem i32 %133, 21
%135 = add nsw i32 %134, 30
%136 = load i32, i32* %2
%137 = add nsw i32 %135, %136
store i32 %137, i32* %2
%138 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %135)
br label %190
139: ; preds = %129
%140 = add i16 %0, -11
%141 = icmp ult i16 %140, 10
br i1 %141, label %142, label %165
142: ; preds = %139
%143 = tail call i32 (...) @rand()
%144 = srem i32 %143, 41
%145 = add nsw i32 %144, 50
%146 = load i32, i32* %5
%147 = icmp ne i32 %146, 0
%148 = zext i1 %147 to i32
%149 = shl nuw nsw i32 %145, %148
%150 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i32 %149)
%151 = load i32, i32* %3
%152 = icmp eq i32 %151, 0
br i1 %152, label %157, label %153
153: ; preds = %142
%154 = load i32, i32* %1
%155 = add nsw i32 %154, %149
store i32 %155, i32* %1
%156 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %149)
br label %190
157: ; preds = %142
%158 = load i32, i32* %4
%159 = icmp eq i32 %158, 0
br i1 %159, label %162, label %160
160: ; preds = %157
%161 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.38, i64 0, i64 0))
br label %190
162: ; preds = %157
%163 = load i32, i32* %1
%164 = sub nsw i32 %163, %149
store i32 %164, i32* %1
br label %190
165: ; preds = %139
%166 = icmp ult i16 %0, 11
br i1 %166, label %167, label %190
167: ; preds = %165
%168 = tail call i32 (...) @rand()
%169 = srem i32 %168, 41
%170 = add nsw i32 %169, 20
%171 = load i32, i32* %5
%172 = icmp ne i32 %171, 0
%173 = zext i1 %172 to i32
%174 = shl nsw i32 %170, %173
%175 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %174)
%176 = load i32, i32* %3
%177 = icmp eq i32 %176, 0
br i1 %177, label %182, label %178
178: ; preds = %167
%179 = load i32, i32* %1
%180 = add nsw i32 %179, %174
store i32 %180, i32* %1
%181 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %174)
br label %190
182: ; preds = %167
%183 = load i32, i32* %4
%184 = icmp eq i32 %183, 0
br i1 %184, label %187, label %185
185: ; preds = %182
%186 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.38, i64 0, i64 0))
br label %190
187: ; preds = %182
%188 = load i32, i32* %1
%189 = sub nsw i32 %188, %174
store i32 %189, i32* %1
br label %192
190: ; preds = %38, %11, %13, %43, %48, %72, %74, %65, %99, %101, %92, %107, %112, %122, %132, %160, %162, %153, %165, %185, %178
%191 = load i32, i32* %1
br label %192
192: ; preds = %190, %187
%193 = phi i32 [ %191, %190 ], [ %189, %187 ]
%194 = icmp slt i32 %193, 1
%195 = load i32, i32* %2
br i1 %194, label %196, label %198
196: ; preds = %192
%197 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.21, i64 0, i64 0), i32 %195)
br label %226
198: ; preds = %192
%199 = icmp slt i32 %195, 1
br i1 %199, label %200, label %202
200: ; preds = %198
%201 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %226
202: ; preds = %198
%203 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.23, i64 0, i64 0), i32 %195, i32 %193)
%204 = load i32, i32* %3
%205 = icmp sgt i32 %204, 1
br i1 %205, label %210, label %206
206: ; preds = %202
%207 = icmp eq i32 %204, 0
br i1 %207, label %212, label %208
208: ; preds = %206
%209 = add nsw i32 %204, 1
br label %210
210: ; preds = %202, %208
%211 = phi i32 [ %209, %208 ], [ 0, %202 ]
store i32 %211, i32* %3
br label %212
212: ; preds = %210, %206
%213 = load i32, i32* %4
%214 = icmp sgt i32 %213, 1
br i1 %214, label %219, label %215
215: ; preds = %212
%216 = icmp eq i32 %213, 0
br i1 %216, label %221, label %217
217: ; preds = %215
%218 = add nsw i32 %213, 1
br label %219
219: ; preds = %212, %217
%220 = phi i32 [ %218, %217 ], [ 0, %212 ]
store i32 %220, i32* %4
br label %221
221: ; preds = %219, %215
%222 = load i32, i32* %5
%223 = icmp sgt i32 %222, 2
%224 = add nsw i32 %222, 1
%225 = select i1 %223, i32 0, i32 %224
store i32 %225, i32* %5
br label %226
226: ; preds = %34, %221, %200, %196, %20
%227 = phi i32 [ 0, %20 ], [ 1, %34 ], [ 1, %196 ], [ 1, %200 ], [ 0, %221 ]
ret i32 %227
}