#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*/ getint(int *);
int hit(int *);
int /*<<< orphan*/ magic(int *, int *, int *, int *, int *, int *, int *, int *,
                         int *, int *, int *, int *, int *, int *, int *, int,
                         int *, int *, int *, int *, int *, int *, char *);
int max(int, int /*<<< orphan*/);
int /*<<< orphan*/ nameenemy(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ treasure(int *, int *, int *, int *, int *, int *, int *,
                            int *, int *, int *, int *, int *,
                            int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ useitemcombat(int *, int *, int *, int *, int *, int *);
int combat(int *hpmax, int *hpnow, int *aces, int *inv, int *slave, int *future,
           int *map, int *loot, int *vision, int *end, int *pos, int *floor,
           int *start, int *antimag, int *checkcurse, int *nomag, int enemy) {
  char s[10];
  nameenemy(s, enemy);
  int hpenemy = enemy % 13 + 1;
  if (enemy == 0)
    hpenemy = 10;
  if (*checkcurse) {
    int a = hpenemy % 2;
    hpenemy = hpenemy / 2 + a;
  }
  printf("An enemy %s appears! It has %d HP!\n", s, hpenemy);
  int e = 0;
  int k;
  int control = 1;
  int bonusnext = 0;
  int bonuscomb = 0;
  int bonusaces = 0;
  int modenemy = 1;
  if ((*antimag == 1) && (enemy > 26) && (enemy < 36))
    modenemy = 0;
  int contator = 0;
  int datt = 0;
  int modatt = 1;
  if (*nomag == 2)
    *nomag = 1;
  if (*(aces + 3))
    bonusaces = 3;
  do {
    printf("What do you want to do?\n[0]: Attack\n[1]: Magic\n[2]: Items\n");
    getint(&k);
    if (k == 0) {
      k = hit(future) * modatt + bonusnext + bonuscomb + bonusaces;
      hpenemy -= k;
      hpenemy = max(hpenemy, 0);
      printf("You strike the %s for %d damage! It has %d HP!\n", s, k, hpenemy);
      if (datt == 1) {
        k = hit(future) + bonusnext + bonuscomb + bonusaces;
        hpenemy -= k;
        hpenemy = max(hpenemy, 0);
        datt = 0;
        printf("You perform a second attack and strike the %s for %d damage! "
               "It has %d HP!\n",
               s, k, hpenemy);
      }
      if (hpenemy == 0) {
        e = 1;
        treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end,
                 pos, antimag, 0, 1, 0);
      } else {
        k = hpenemy * modenemy;
        *hpnow = *hpnow - k;
        *hpnow = max(*hpnow, 0);
        if (contator > 0) {
          printf("The %s is paralysed!\n", s);
        } else if ((*antimag == 1) && (enemy > 26) && (enemy < 36)) {
          printf("The attack of the %s is blocked by the antimagic field!\n",
                 s);
        } else {
          printf("The %s strikes you for %d damage! You have %d HP!\n", s, k,
                 *hpnow);
        }
        if (*hpnow <= 0)
          e = 1;
      }
    } else if (k == 1) {
      magic(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
            floor, start, antimag, checkcurse, 1, &control, &contator,
            &modenemy, &datt, &modatt, nomag, s);
    } else if (k == 2) {
      useitemcombat(hpmax, hpnow, inv, slave, &bonusnext, &bonuscomb);
    } else {
      printf("What do you want to do?! It is really an uneasy moment...\n");
    }
    if (*start == 1)
      e = 1;
    if (contator > 0) {
      contator--;
      if (contator == 0)
        modenemy = 1;
    }
  } while (e == 0);
  if (*nomag != 2)
    *nomag = 0;
  return control;
}


x86 assembly (clang, -O0):
<combat>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    0x60(%rbp),%eax
mov    0x58(%rbp),%rax
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%rbp)
lea    -0x62(%rbp),%rdi
mov    0x60(%rbp),%esi
call   10a0 <nameenemy@plt>
mov    0x60(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x68(%rbp)
cmpl   $0x0,0x60(%rbp)
jne    1205 <combat+0x85>
movl   $0xa,-0x68(%rbp)
mov    0x50(%rbp),%rax
cmpl   $0x0,(%rax)
je     1231 <combat+0xb1>
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x6c(%rbp),%eax
mov    %eax,-0x68(%rbp)
lea    -0x62(%rbp),%rsi
mov    -0x68(%rbp),%edx
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x70(%rbp)
movl   $0x1,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x1,-0x88(%rbp)
mov    0x48(%rbp),%rax
cmpl   $0x1,(%rax)
jne    12a1 <combat+0x121>
cmpl   $0x1a,0x60(%rbp)
jle    12a1 <combat+0x121>
cmpl   $0x24,0x60(%rbp)
jge    12a1 <combat+0x121>
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
movl   $0x1,-0x94(%rbp)
mov    0x58(%rbp),%rax
cmpl   $0x2,(%rax)
jne    12d6 <combat+0x156>
mov    0x58(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x40(%rbp),%rax
cmpl   $0x0,0xc(%rax)
je     12ee <combat+0x16e>
movl   $0x3,-0x84(%rbp)
jmp    12f3 <combat+0x173>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x74(%rbp),%rdi
call   1080 <getint@plt>
cmpl   $0x0,-0x74(%rbp)
jne    1510 <combat+0x390>
mov    -0x58(%rbp),%rdi
call   1090 <hit@plt>
imul   -0x94(%rbp),%eax
add    -0x7c(%rbp),%eax
add    -0x80(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%ecx
mov    -0x68(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%edi
xor    %esi,%esi
call   1070 <max@plt>
mov    %eax,-0x68(%rbp)
lea    -0x62(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    -0x68(%rbp),%ecx
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x90(%rbp)
jne    13c2 <combat+0x242>
mov    -0x58(%rbp),%rdi
call   1090 <hit@plt>
add    -0x7c(%rbp),%eax
add    -0x80(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%ecx
mov    -0x68(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%edi
xor    %esi,%esi
call   1070 <max@plt>
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x90(%rbp)
lea    -0x62(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    -0x68(%rbp),%ecx
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x68(%rbp)
jne    1445 <combat+0x2c5>
movl   $0x1,-0x70(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%r15
mov    0x18(%rbp),%r14
mov    0x20(%rbp),%rbx
mov    0x28(%rbp),%r11
mov    0x30(%rbp),%r10
mov    0x48(%rbp),%rax
xor    %r12d,%r12d
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
movl   $0x0,0x30(%rsp)
movl   $0x1,0x38(%rsp)
movl   $0x0,0x40(%rsp)
call   1030 <treasure@plt>
jmp    150b <combat+0x38b>
mov    -0x68(%rbp),%eax
imul   -0x88(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
sub    -0x74(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <max@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x8c(%rbp)
jle    149a <combat+0x31a>
lea    -0x62(%rbp),%rsi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14f2 <combat+0x372>
mov    0x48(%rbp),%rax
cmpl   $0x1,(%rax)
jne    14d2 <combat+0x352>
cmpl   $0x1a,0x60(%rbp)
jle    14d2 <combat+0x352>
cmpl   $0x24,0x60(%rbp)
jge    14d2 <combat+0x352>
lea    -0x62(%rbp),%rsi
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ed <combat+0x36d>
lea    -0x62(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
lea    0xc44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14f2 <combat+0x372>
mov    -0x38(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1506 <combat+0x386>
movl   $0x1,-0x70(%rbp)
jmp    150b <combat+0x38b>
jmp    1696 <combat+0x516>
cmpl   $0x1,-0x74(%rbp)
jne    1652 <combat+0x4d2>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    0x10(%rbp),%rax
mov    0x18(%rbp),%r10
mov    %r10,-0xd8(%rbp)
mov    0x20(%rbp),%r10
mov    %r10,-0xd0(%rbp)
mov    0x28(%rbp),%r10
mov    %r10,-0xc8(%rbp)
mov    0x30(%rbp),%r10
mov    %r10,-0xc0(%rbp)
mov    0x38(%rbp),%r10
mov    %r10,-0xb8(%rbp)
mov    0x40(%rbp),%r10
mov    %r10,-0xb0(%rbp)
mov    0x48(%rbp),%r10
mov    %r10,-0xa8(%rbp)
mov    0x50(%rbp),%r13
mov    0x58(%rbp),%r10
lea    -0x62(%rbp),%r11
mov    %r11,-0xa0(%rbp)
lea    -0x78(%rbp),%r12
lea    -0x8c(%rbp),%r15
lea    -0x88(%rbp),%r14
lea    -0x90(%rbp),%rbx
lea    -0x94(%rbp),%r11
mov    %rax,(%rsp)
mov    -0xd8(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0xd0(%rbp),%rax
mov    %rax,0x10(%rsp)
mov    -0xc8(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    -0xc0(%rbp),%rax
mov    %rax,0x20(%rsp)
mov    -0xb8(%rbp),%rax
mov    %rax,0x28(%rsp)
mov    -0xb0(%rbp),%rax
mov    %rax,0x30(%rsp)
mov    -0xa8(%rbp),%rax
mov    %rax,0x38(%rsp)
mov    -0xa0(%rbp),%rax
mov    %r13,0x40(%rsp)
movl   $0x1,0x48(%rsp)
mov    %r12,0x50(%rsp)
mov    %r15,0x58(%rsp)
mov    %r14,0x60(%rsp)
mov    %rbx,0x68(%rsp)
mov    %r11,0x70(%rsp)
mov    %r10,0x78(%rsp)
mov    %rax,0x80(%rsp)
call   1040 <magic@plt>
jmp    1691 <combat+0x511>
cmpl   $0x2,-0x74(%rbp)
jne    167e <combat+0x4fe>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    -0x7c(%rbp),%r8
lea    -0x80(%rbp),%r9
call   1060 <useitemcombat@plt>
jmp    168c <combat+0x50c>
lea    0xad8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1691 <combat+0x511>
jmp    1696 <combat+0x516>
mov    0x40(%rbp),%rax
cmpl   $0x1,(%rax)
jne    16aa <combat+0x52a>
movl   $0x1,-0x70(%rbp)
cmpl   $0x0,-0x8c(%rbp)
jle    16e2 <combat+0x562>
mov    -0x8c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
jne    16dd <combat+0x55d>
movl   $0x1,-0x88(%rbp)
jmp    16e2 <combat+0x562>
jmp    16e7 <combat+0x567>
cmpl   $0x0,-0x70(%rbp)
je     12f3 <combat+0x173>
mov    0x58(%rbp),%rax
cmpl   $0x2,(%rax)
je     1708 <combat+0x588>
mov    0x58(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x78(%rbp),%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<combat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r13
mov    %r8,0x48(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rdx,0x30(%rsp)
mov    %rsi,%rbx
mov    %rdi,0x38(%rsp)
movslq 0xe0(%rsp),%rbp
mov    0xd8(%rsp),%r14
mov    0xd0(%rsp),%r15
lea    0x1a(%rsp),%rdi
mov    %ebp,%esi
call   10b0 <nameenemy@plt>
imul   $0x4ec4ec4f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%eax
neg    %eax
test   %rbp,%rbp
lea    0x1(%rbp,%rax,1),%eax
mov    $0xa,%r12d
cmovne %eax,%r12d
cmpl   $0x0,(%r15)
je     1229 <combat+0x99>
mov    %r12d,%eax
shr    $0x7,%al
add    %r12b,%al
mov    %eax,%ecx
and    $0xfe,%cl
sub    %cl,%r12b
sar    %al
add    %r12b,%al
movsbl %al,%r12d
lea    0xdd0(%rip),%rdi
lea    0x1a(%rsp),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0x1,0x2c(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
mov    0xc8(%rsp),%rax
cmpl   $0x1,(%rax)
setne  %al
lea    -0x1b(%rbp),%ecx
mov    %ecx,0x54(%rsp)
cmp    $0x9,%ecx
setae  %cl
or     %al,%cl
movzbl %cl,%eax
mov    %eax,0xc(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x1,0x28(%rsp)
cmpl   $0x2,(%r14)
jne    12a0 <combat+0x110>
movl   $0x1,(%r14)
mov    0xc0(%rsp),%rbp
xor    %eax,%eax
mov    0x30(%rsp),%rcx
cmpl   $0x0,0xc(%rcx)
setne  %al
lea    (%rax,%rax,2),%eax
mov    %eax,0x24(%rsp)
lea    0xe5e(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1090 <getint@plt>
mov    (%rsp),%eax
cmp    $0x2,%eax
je     13d0 <combat+0x240>
cmp    $0x1,%eax
je     1400 <combat+0x270>
test   %eax,%eax
jne    14a0 <combat+0x310>
mov    %r13,%rdi
call   10a0 <hit@plt>
imul   0x28(%rsp),%eax
mov    0x14(%rsp),%ecx
add    0x24(%rsp),%ecx
add    %eax,%ecx
add    0x10(%rsp),%ecx
mov    %ecx,(%rsp)
sub    %ecx,%r12d
mov    %r12d,%edi
xor    %esi,%esi
call   1080 <max@plt>
mov    %eax,%r12d
mov    (%rsp),%edx
lea    0xcef(%rip),%rdi
lea    0x1a(%rsp),%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x1,0x8(%rsp)
jne    1391 <combat+0x201>
mov    %r13,%rdi
call   10a0 <hit@plt>
add    0x24(%rsp),%eax
add    0x14(%rsp),%eax
add    0x10(%rsp),%eax
mov    %eax,(%rsp)
sub    %eax,%r12d
mov    %r12d,%edi
xor    %esi,%esi
call   1080 <max@plt>
mov    %eax,%r12d
movl   $0x0,0x8(%rsp)
mov    (%rsp),%edx
lea    0xcd1(%rip),%rdi
lea    0x1a(%rsp),%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12d,%r12d
je     14e0 <combat+0x350>
mov    0xc(%rsp),%eax
imul   %r12d,%eax
mov    %eax,(%rsp)
mov    (%rbx),%edi
sub    %eax,%edi
mov    %edi,(%rbx)
xor    %esi,%esi
call   1080 <max@plt>
mov    %eax,(%rbx)
cmpl   $0x0,0x4(%rsp)
jle    1544 <combat+0x3b4>
lea    0xcda(%rip),%rdi
jmp    155f <combat+0x3cf>
nopl   0x0(%rax,%rax,1)
mov    0x38(%rsp),%rdi
mov    %rbx,%rsi
mov    0x40(%rsp),%rdx
mov    0x48(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
call   1070 <useitemcombat@plt>
jmp    14ac <combat+0x31c>
cs nopw 0x0(%rax,%rax,1)
sub    $0x8,%rsp
mov    0x40(%rsp),%rdi
mov    %rbx,%rsi
mov    0x38(%rsp),%rdx
mov    0x48(%rsp),%rcx
mov    0x50(%rsp),%r8
mov    %r13,%r9
lea    0x22(%rsp),%rax
push   %rax
push   0xe8(%rsp)
lea    0x40(%rsp),%rax
push   %rax
lea    0x28(%rsp),%rax
push   %rax
lea    0x34(%rsp),%rax
push   %rax
lea    0x34(%rsp),%rax
push   %rax
lea    0x64(%rsp),%rax
push   %rax
push   $0x1
push   0x118(%rsp)
push   0x118(%rsp)
push   %rbp
push   0x118(%rsp)
push   0x118(%rsp)
push   0x118(%rsp)
push   0x118(%rsp)
push   0x118(%rsp)
push   0x118(%rsp)
call   1040 <magic@plt>
add    $0x90,%rsp
jmp    14ac <combat+0x31c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xcb5(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
mov    0x0(%rbp),%ecx
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    14ca <combat+0x33a>
add    $0xffffffff,%edx
mov    %edx,0x4(%rsp)
jne    14ca <combat+0x33a>
movl   $0x1,0xc(%rsp)
cmp    $0x1,%ecx
je     1592 <combat+0x402>
test   %eax,%eax
je     12d0 <combat+0x140>
jmp    1592 <combat+0x402>
sub    $0x8,%rsp
mov    0x40(%rsp),%rdi
mov    %rbx,%rsi
mov    0x38(%rsp),%rdx
mov    0x48(%rsp),%rcx
mov    0x50(%rsp),%r8
mov    %r13,%r9
push   $0x0
push   $0x1
push   $0x0
push   0xe8(%rsp)
push   0xd8(%rsp)
push   0xd8(%rsp)
push   0xd8(%rsp)
push   0xd8(%rsp)
push   0xd8(%rsp)
call   1030 <treasure@plt>
add    $0x50,%rsp
mov    $0x1,%eax
xor    %r12d,%r12d
jmp    14ae <combat+0x31e>
cmpl   $0x8,0x54(%rsp)
ja     1578 <combat+0x3e8>
mov    0xc8(%rsp),%rcx
cmpl   $0x1,(%rcx)
jne    1578 <combat+0x3e8>
lea    0xb57(%rip),%rdi
lea    0x1a(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,(%rbx)
setle  %al
jmp    14ae <combat+0x31e>
mov    (%rsp),%edx
lea    0xb6d(%rip),%rdi
lea    0x1a(%rsp),%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    156b <combat+0x3db>
mov    0xd8(%rsp),%rax
cmpl   $0x2,(%rax)
je     15a5 <combat+0x415>
movl   $0x0,(%rax)
mov    0x2c(%rsp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"An enemy %s appears! It has %d HP!\0A\00"
@.str.1 = [59 x i8] c"What do you want to do?\0A[0]: Attack\0A[1]: Magic\0A[2]: Items\0A\00"
@.str.2 = [48 x i8] c"You strike the %s for %d damage! It has %d HP!\0A\00"
@.str.3 = [76 x i8] c"You perform a second attack and strike the %s for %d damage! It has %d HP!\0A\00"
@.str.4 = [22 x i8] c"The %s is paralysed!\0A\00"
@.str.5 = [57 x i8] c"The attack of the %s is blocked by the antimagic field!\0A\00"
@.str.6 = [51 x i8] c"The %s strikes you for %d damage! You have %d HP!\0A\00"
@.str.7 = [59 x i8] c"What do you want to do?! It is really an uneasy moment...\0A\00"
define i32 @combat(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32 %16) {
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32*
%29 = alloca i32*
%30 = alloca i32*
%31 = alloca i32*
%32 = alloca i32*
%33 = alloca i32*
%34 = alloca i32
%35 = alloca [10 x i8]
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
%41 = alloca i32
%42 = alloca i32
%43 = alloca i32
%44 = alloca i32
%45 = alloca i32
%46 = alloca i32
%47 = alloca i32
store i32* %0, i32** %18
store i32* %1, i32** %19
store i32* %2, i32** %20
store i32* %3, i32** %21
store i32* %4, i32** %22
store i32* %5, i32** %23
store i32* %6, i32** %24
store i32* %7, i32** %25
store i32* %8, i32** %26
store i32* %9, i32** %27
store i32* %10, i32** %28
store i32* %11, i32** %29
store i32* %12, i32** %30
store i32* %13, i32** %31
store i32* %14, i32** %32
store i32* %15, i32** %33
store i32 %16, i32* %34
%48 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%49 = load i32, i32* %34
%50 = call i32 @nameenemy(i8* %48, i32 %49)
%51 = load i32, i32* %34
%52 = srem i32 %51, 13
%53 = add nsw i32 %52, 1
store i32 %53, i32* %36
%54 = load i32, i32* %34
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %17
store i32 10, i32* %36
br label %57
57: ; preds = %56, %17
%58 = load i32*, i32** %32
%59 = load i32, i32* %58
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = load i32, i32* %36
%63 = srem i32 %62, 2
store i32 %63, i32* %37
%64 = load i32, i32* %36
%65 = sdiv i32 %64, 2
%66 = load i32, i32* %37
%67 = add nsw i32 %65, %66
store i32 %67, i32* %36
br label %68
68: ; preds = %61, %57
%69 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%70 = load i32, i32* %36
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %69, i32 %70)
store i32 0, i32* %38
store i32 1, i32* %40
store i32 0, i32* %41
store i32 0, i32* %42
store i32 0, i32* %43
store i32 1, i32* %44
%72 = load i32*, i32** %31
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, 1
br i1 %74, label %75, label %82
75: ; preds = %68
%76 = load i32, i32* %34
%77 = icmp sgt i32 %76, 26
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = load i32, i32* %34
%80 = icmp slt i32 %79, 36
br i1 %80, label %81, label %82
81: ; preds = %78
store i32 0, i32* %44
br label %82
82: ; preds = %81, %78, %75, %68
store i32 0, i32* %45
store i32 0, i32* %46
store i32 1, i32* %47
%83 = load i32*, i32** %33
%84 = load i32, i32* %83
%85 = icmp eq i32 %84, 2
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = load i32*, i32** %33
store i32 1, i32* %87
br label %88
88: ; preds = %86, %82
%89 = load i32*, i32** %20
%90 = getelementptr inbounds i32, i32* %89, i64 3
%91 = load i32, i32* %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %88
store i32 3, i32* %43
br label %94
94: ; preds = %93, %88
br label %95
95: ; preds = %253, %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%97 = call i32 @getint(i32* %39)
%98 = load i32, i32* %39
%99 = icmp eq i32 %98, 0
br i1 %99, label %100, label %202
100: ; preds = %95
%101 = load i32*, i32** %23
%102 = call i32 @hit(i32* %101)
%103 = load i32, i32* %47
%104 = mul nsw i32 %102, %103
%105 = load i32, i32* %41
%106 = add nsw i32 %104, %105
%107 = load i32, i32* %42
%108 = add nsw i32 %106, %107
%109 = load i32, i32* %43
%110 = add nsw i32 %108, %109
store i32 %110, i32* %39
%111 = load i32, i32* %39
%112 = load i32, i32* %36
%113 = sub nsw i32 %112, %111
store i32 %113, i32* %36
%114 = load i32, i32* %36
%115 = call i32 @max(i32 %114, i32 0)
store i32 %115, i32* %36
%116 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%117 = load i32, i32* %39
%118 = load i32, i32* %36
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %116, i32 %117, i32 %118)
%120 = load i32, i32* %46
%121 = icmp eq i32 %120, 1
br i1 %121, label %122, label %140
122: ; preds = %100
%123 = load i32*, i32** %23
%124 = call i32 @hit(i32* %123)
%125 = load i32, i32* %41
%126 = add nsw i32 %124, %125
%127 = load i32, i32* %42
%128 = add nsw i32 %126, %127
%129 = load i32, i32* %43
%130 = add nsw i32 %128, %129
store i32 %130, i32* %39
%131 = load i32, i32* %39
%132 = load i32, i32* %36
%133 = sub nsw i32 %132, %131
store i32 %133, i32* %36
%134 = load i32, i32* %36
%135 = call i32 @max(i32 %134, i32 0)
store i32 %135, i32* %36
store i32 0, i32* %46
%136 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%137 = load i32, i32* %39
%138 = load i32, i32* %36
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0), i8* %136, i32 %137, i32 %138)
br label %140
140: ; preds = %122, %100
%141 = load i32, i32* %36
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %157
143: ; preds = %140
store i32 1, i32* %38
%144 = load i32*, i32** %18
%145 = load i32*, i32** %19
%146 = load i32*, i32** %20
%147 = load i32*, i32** %21
%148 = load i32*, i32** %22
%149 = load i32*, i32** %23
%150 = load i32*, i32** %24
%151 = load i32*, i32** %25
%152 = load i32*, i32** %26
%153 = load i32*, i32** %27
%154 = load i32*, i32** %28
%155 = load i32*, i32** %31
%156 = call i32 @treasure(i32* %144, i32* %145, i32* %146, i32* %147, i32* %148, i32* %149, i32* %150, i32* %151, i32* %152, i32* %153, i32* %154, i32* %155, i32 0, i32 1, i32 0)
br label %201
157: ; preds = %140
%158 = load i32, i32* %36
%159 = load i32, i32* %44
%160 = mul nsw i32 %158, %159
store i32 %160, i32* %39
%161 = load i32*, i32** %19
%162 = load i32, i32* %161
%163 = load i32, i32* %39
%164 = sub nsw i32 %162, %163
%165 = load i32*, i32** %19
store i32 %164, i32* %165
%166 = load i32*, i32** %19
%167 = load i32, i32* %166
%168 = call i32 @max(i32 %167, i32 0)
%169 = load i32*, i32** %19
store i32 %168, i32* %169
%170 = load i32, i32* %45
%171 = icmp sgt i32 %170, 0
br i1 %171, label %172, label %175
172: ; preds = %157
%173 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %173)
br label %195
175: ; preds = %157
%176 = load i32*, i32** %31
%177 = load i32, i32* %176
%178 = icmp eq i32 %177, 1
br i1 %178, label %179, label %188
179: ; preds = %175
%180 = load i32, i32* %34
%181 = icmp sgt i32 %180, 26
br i1 %181, label %182, label %188
182: ; preds = %179
%183 = load i32, i32* %34
%184 = icmp slt i32 %183, 36
br i1 %184, label %185, label %188
185: ; preds = %182
%186 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* %186)
br label %194
188: ; preds = %182, %179, %175
%189 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%190 = load i32, i32* %39
%191 = load i32*, i32** %19
%192 = load i32, i32* %191
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %189, i32 %190, i32 %192)
br label %194
194: ; preds = %188, %185
br label %195
195: ; preds = %194, %172
%196 = load i32*, i32** %19
%197 = load i32, i32* %196
%198 = icmp sle i32 %197, 0
br i1 %198, label %199, label %200
199: ; preds = %195
store i32 1, i32* %38
br label %200
200: ; preds = %199, %195
br label %201
201: ; preds = %200, %143
br label %237
202: ; preds = %95
%203 = load i32, i32* %39
%204 = icmp eq i32 %203, 1
br i1 %204, label %205, label %224
205: ; preds = %202
%206 = load i32*, i32** %18
%207 = load i32*, i32** %19
%208 = load i32*, i32** %20
%209 = load i32*, i32** %21
%210 = load i32*, i32** %22
%211 = load i32*, i32** %23
%212 = load i32*, i32** %24
%213 = load i32*, i32** %25
%214 = load i32*, i32** %26
%215 = load i32*, i32** %27
%216 = load i32*, i32** %28
%217 = load i32*, i32** %29
%218 = load i32*, i32** %30
%219 = load i32*, i32** %31
%220 = load i32*, i32** %32
%221 = load i32*, i32** %33
%222 = getelementptr inbounds [10 x i8], [10 x i8]* %35, i64 0, i64 0
%223 = call i32 @magic(i32* %206, i32* %207, i32* %208, i32* %209, i32* %210, i32* %211, i32* %212, i32* %213, i32* %214, i32* %215, i32* %216, i32* %217, i32* %218, i32* %219, i32* %220, i32 1, i32* %40, i32* %45, i32* %44, i32* %46, i32* %47, i32* %221, i8* %222)
br label %236
224: ; preds = %202
%225 = load i32, i32* %39
%226 = icmp eq i32 %225, 2
br i1 %226, label %227, label %233
227: ; preds = %224
%228 = load i32*, i32** %18
%229 = load i32*, i32** %19
%230 = load i32*, i32** %21
%231 = load i32*, i32** %22
%232 = call i32 @useitemcombat(i32* %228, i32* %229, i32* %230, i32* %231, i32* %41, i32* %42)
br label %235
233: ; preds = %224
%234 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0))
br label %235
235: ; preds = %233, %227
br label %236
236: ; preds = %235, %205
br label %237
237: ; preds = %236, %201
%238 = load i32*, i32** %30
%239 = load i32, i32* %238
%240 = icmp eq i32 %239, 1
br i1 %240, label %241, label %242
241: ; preds = %237
store i32 1, i32* %38
br label %242
242: ; preds = %241, %237
%243 = load i32, i32* %45
%244 = icmp sgt i32 %243, 0
br i1 %244, label %245, label %252
245: ; preds = %242
%246 = load i32, i32* %45
%247 = add nsw i32 %246, -1
store i32 %247, i32* %45
%248 = load i32, i32* %45
%249 = icmp eq i32 %248, 0
br i1 %249, label %250, label %251
250: ; preds = %245
store i32 1, i32* %44
br label %251
251: ; preds = %250, %245
br label %252
252: ; preds = %251, %242
br label %253
253: ; preds = %252
%254 = load i32, i32* %38
%255 = icmp eq i32 %254, 0
br i1 %255, label %95, label %256
256: ; preds = %253
%257 = load i32*, i32** %33
%258 = load i32, i32* %257
%259 = icmp ne i32 %258, 2
br i1 %259, label %260, label %262
260: ; preds = %256
%261 = load i32*, i32** %33
store i32 0, i32* %261
br label %262
262: ; preds = %260, %256
%263 = load i32, i32* %40
ret i32 %263
}

LLVM IR (-O2):
@.str = [36 x i8] c"An enemy %s appears! It has %d HP!\0A\00"
@.str.2 = [48 x i8] c"You strike the %s for %d damage! It has %d HP!\0A\00"
@.str.3 = [76 x i8] c"You perform a second attack and strike the %s for %d damage! It has %d HP!\0A\00"
@.str.4 = [22 x i8] c"The %s is paralysed!\0A\00"
@.str.5 = [57 x i8] c"The attack of the %s is blocked by the antimagic field!\0A\00"
@.str.6 = [51 x i8] c"The %s strikes you for %d damage! You have %d HP!\0A\00"
@str = [58 x i8] c"What do you want to do?\0A[0]: Attack\0A[1]: Magic\0A[2]: Items\00"
@str.8 = [58 x i8] c"What do you want to do?! It is really an uneasy moment...\00"
define i32 @combat(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32 %16) {
%18 = alloca [10 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %18, i64 0, i64 0
%28 = call i32 @nameenemy(i8* %27, i32 %16)
%29 = srem i32 %16, 13
%30 = add nsw i32 %29, 1
%31 = icmp eq i32 %16, 0
%32 = select i1 %31, i32 10, i32 %30
%33 = load i32, i32* %14
%34 = icmp eq i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %17
%36 = trunc i32 %32 to i8
%37 = srem i8 %36, 2
%38 = sdiv i8 %36, 2
%39 = add nsw i8 %38, %37
%40 = sext i8 %39 to i32
br label %41
41: ; preds = %35, %17
%42 = phi i32 [ %40, %35 ], [ %32, %17 ]
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %42)
%44 = bitcast i32* %19 to i8*
%45 = bitcast i32* %20 to i8*
store i32 1, i32* %20
%46 = bitcast i32* %21 to i8*
store i32 0, i32* %21
%47 = bitcast i32* %22 to i8*
store i32 0, i32* %22
%48 = bitcast i32* %23 to i8*
%49 = load i32, i32* %13
%50 = icmp eq i32 %49, 1
%51 = add i32 %16, -27
%52 = icmp ult i32 %51, 9
%53 = and i1 %52, %50
%54 = xor i1 %53, true
%55 = zext i1 %54 to i32
store i32 %55, i32* %23
%56 = bitcast i32* %24 to i8*
store i32 0, i32* %24
%57 = bitcast i32* %25 to i8*
store i32 0, i32* %25
%58 = bitcast i32* %26 to i8*
store i32 1, i32* %26
%59 = load i32, i32* %15
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %62
61: ; preds = %41
store i32 1, i32* %15
br label %62
62: ; preds = %61, %41
%63 = getelementptr inbounds i32, i32* %2, i64 3
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 0
%66 = select i1 %65, i32 0, i32 3
br label %67
67: ; preds = %143, %62
%68 = phi i32 [ %42, %62 ], [ %133, %143 ]
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%70 = call i32 @getint(i32* %19)
%71 = load i32, i32* %19
switch i32 %71, label %130 [
i32 0, label %72
i32 1, label %126
i32 2, label %128
]
72: ; preds = %67
%73 = call i32 @hit(i32* %5)
%74 = load i32, i32* %26
%75 = mul nsw i32 %74, %73
%76 = load i32, i32* %21
%77 = load i32, i32* %22
%78 = add i32 %76, %66
%79 = add i32 %78, %75
%80 = add i32 %79, %77
store i32 %80, i32* %19
%81 = sub nsw i32 %68, %80
%82 = call i32 @max(i32 %81, i32 0)
%83 = load i32, i32* %19
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %27, i32 %83, i32 %82)
%85 = load i32, i32* %25
%86 = icmp eq i32 %85, 1
br i1 %86, label %87, label %98
87: ; preds = %72
%88 = call i32 @hit(i32* %5)
%89 = load i32, i32* %21
%90 = load i32, i32* %22
%91 = add i32 %88, %66
%92 = add i32 %91, %89
%93 = add i32 %92, %90
store i32 %93, i32* %19
%94 = sub nsw i32 %82, %93
%95 = call i32 @max(i32 %94, i32 0)
store i32 0, i32* %25
%96 = load i32, i32* %19
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0), i8* %27, i32 %96, i32 %95)
br label %98
98: ; preds = %87, %72
%99 = phi i32 [ %95, %87 ], [ %82, %72 ]
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %98
%102 = call i32 @treasure(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %13, i32 0, i32 1, i32 0)
br label %132
103: ; preds = %98
%104 = load i32, i32* %23
%105 = mul nsw i32 %104, %99
store i32 %105, i32* %19
%106 = load i32, i32* %1
%107 = sub nsw i32 %106, %105
store i32 %107, i32* %1
%108 = call i32 @max(i32 %107, i32 0)
store i32 %108, i32* %1
%109 = load i32, i32* %24
%110 = icmp sgt i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %103
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %122
113: ; preds = %103
%114 = load i32, i32* %13
%115 = icmp eq i32 %114, 1
%116 = and i1 %52, %115
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* %27)
br label %122
119: ; preds = %113
%120 = load i32, i32* %19
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %27, i32 %120, i32 %108)
br label %122
122: ; preds = %117, %119, %111
%123 = load i32, i32* %1
%124 = icmp slt i32 %123, 1
%125 = zext i1 %124 to i32
br label %132
126: ; preds = %67
%127 = call i32 @magic(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32 1, i32* %20, i32* %24, i32* %23, i32* %25, i32* %26, i32* %15, i8* %27)
br label %132
128: ; preds = %67
%129 = call i32 @useitemcombat(i32* %0, i32* %1, i32* %3, i32* %4, i32* %21, i32* %22)
br label %132
130: ; preds = %67
%131 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.8, i64 0, i64 0))
br label %132
132: ; preds = %122, %126, %130, %128, %101
%133 = phi i32 [ 0, %101 ], [ %68, %126 ], [ %68, %128 ], [ %68, %130 ], [ %99, %122 ]
%134 = phi i32 [ 1, %101 ], [ 0, %126 ], [ 0, %128 ], [ 0, %130 ], [ %125, %122 ]
%135 = load i32, i32* %12
%136 = icmp ne i32 %135, 1
%137 = load i32, i32* %24
%138 = icmp sgt i32 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %132
%140 = add nsw i32 %137, -1
store i32 %140, i32* %24
%141 = icmp eq i32 %140, 0
br i1 %141, label %142, label %143
142: ; preds = %139
store i32 1, i32* %23
br label %143
143: ; preds = %132, %142, %139
%144 = icmp eq i32 %134, 0
%145 = select i1 %136, i1 %144, i1 false
br i1 %145, label %67, label %146
146: ; preds = %143
%147 = load i32, i32* %15
%148 = icmp eq i32 %147, 2
br i1 %148, label %150, label %149
149: ; preds = %146
store i32 0, i32* %15
br label %150
150: ; preds = %149, %146
%151 = load i32, i32* %20
ret i32 %151
}