#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*/ exchange(int *, int *, int *, int *, int *, int *, int *,
                            int *, int *, int *, int *, int *, int *, int *,
                            int);
int /*<<< orphan*/ getint(int *);
int magiccount(int *, int *);
int /*<<< orphan*/ nameitem(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stealingspirit(int *, int *, int *, int *, int *, int *,
                                  int *, int *, int *, int *, int *, int *,
                                  int *, int *, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void trade(int *hpmax, int *hpnow, int *aces, int *inv, int *future, int *slave,
           int *map, int *loot, int *vision, int *end, int *pos, int *floor,
           int *start, int *antimag, int type) {
  int i;
  if ((type == 1) && (*(loot + *pos) > 13) && (*(loot + *pos) < 23)) {
    printf("'I'm sorry, but I have already sold my goods.'\n");
    if (magiccount(aces, inv) > 5) {
      printf("Do you want to use a StealingSpirit spell?\n[0]: No\n[1]: Yes\n");
      getint(&i);
      if (i == 1) {
        stealingspirit(hpmax, hpnow, aces, inv, slave, future, map, loot,
                       vision, end, pos, floor, start, antimag, NULL, NULL,
                       NULL);
        if (type == 0) {
          printf("The merchant disappears!\n");
        }
      }
    }
    *(loot + *pos) = -1;
    *(vision + *pos) = 2;
    return;
  }
  if ((type == 0) && (*(loot + *pos) % 13 == 0)) {
    printf("'I'm sorry, but I don't want to trade my artifact.'\n");
    *(loot + *pos) = -1;
    *(vision + *pos) = 2;
    return;
  }
  if ((*(loot + *pos) % 13 == 11) && (*(loot + *pos) > 25)) {
    printf("'I don't think you are interest in a black priestess...'\n");
    *(loot + *pos) = -1;
    *(vision + *pos) = 2;
    return;
  }
  char s[20];
  nameitem(s, *(loot + *pos));
  do {
    printf("'Are you interested in my %s?'\n", s);
    if (*(loot + *pos) % 13 == 0) {
      if (((*(loot + *pos) == 0) && (*aces == 1)) ||
          ((*(loot + *pos) == 13) && (*(aces + 1) == 1)) ||
          ((*(loot + *pos) == 26) && (*(aces + 2) == 1)) ||
          ((*(loot + *pos) == 39) && (*(aces + 3) == 1))) {
        printf("You see it's only a pathetic imitation...\n");
        *(loot + *pos) = -1;
        *(vision + *pos) = 2;
        return;
      }
    }
    printf("[0]: No\n[1]: Yes\n");
    getint(&i);
    if (i == 0) {
      *(loot + *pos) = -1;
      *(vision + *pos) = 2;
      return;
    }
    if (i == 1) {
      exchange(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end,
               pos, floor, start, antimag, type);
      *(vision + *pos) = 2;
      *(loot + *pos) = -1;
      return;
    } else {
      i = -1;
      printf("'What?'\n");
    }
  } while (i = -1);
}


x86 assembly (clang, -O0):
<trade>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    0x50(%rbp),%eax
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)
cmpl   $0x1,0x50(%rbp)
jne    12fc <trade+0x19c>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0xd,(%rax,%rcx,4)
jle    12fc <trade+0x19c>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0x17,(%rax,%rcx,4)
jge    12fc <trade+0x19c>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1050 <magiccount@plt>
cmp    $0x5,%eax
jle    12d3 <trade+0x173>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5c(%rbp),%rdi
call   1040 <getint@plt>
cmpl   $0x1,-0x5c(%rbp)
jne    12ce <trade+0x16e>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    0x28(%rbp),%r14
mov    0x30(%rbp),%rbx
mov    0x38(%rbp),%r11
mov    0x40(%rbp),%r10
mov    0x48(%rbp),%rax
mov    %rax,-0x78(%rbp)
xor    %eax,%eax
mov    -0x78(%rbp),%rax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
movq   $0x0,0x40(%rsp)
movq   $0x0,0x48(%rsp)
movq   $0x0,0x50(%rsp)
call   1080 <stealingspirit@plt>
cmpl   $0x0,0x50(%rbp)
jne    12c9 <trade+0x169>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ce <trade+0x16e>
jmp    12d3 <trade+0x173>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
cmpl   $0x0,0x50(%rbp)
jne    135c <trade+0x1fc>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    135c <trade+0x1fc>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xb,%edx
jne    13c7 <trade+0x267>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0x19,(%rax,%rcx,4)
jle    13c7 <trade+0x267>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
lea    -0x70(%rbp),%rdi
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <nameitem@plt>
lea    -0x70(%rbp),%rsi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    14d6 <trade+0x376>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1431 <trade+0x2d1>
mov    -0x40(%rbp),%rax
cmpl   $0x1,(%rax)
je     149a <trade+0x33a>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0xd,(%rax,%rcx,4)
jne    1454 <trade+0x2f4>
mov    -0x40(%rbp),%rax
cmpl   $0x1,0x4(%rax)
je     149a <trade+0x33a>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0x1a,(%rax,%rcx,4)
jne    1477 <trade+0x317>
mov    -0x40(%rbp),%rax
cmpl   $0x1,0x8(%rax)
je     149a <trade+0x33a>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0x27,(%rax,%rcx,4)
jne    14d1 <trade+0x371>
mov    -0x40(%rbp),%rax
cmpl   $0x1,0xc(%rax)
jne    14d1 <trade+0x371>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
jmp    14d6 <trade+0x376>
lea    0xb7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5c(%rbp),%rdi
call   1040 <getint@plt>
cmpl   $0x0,-0x5c(%rbp)
jne    1520 <trade+0x3c0>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
cmpl   $0x1,-0x5c(%rbp)
jne    15d2 <trade+0x472>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x18(%rbp),%r13
mov    0x20(%rbp),%r12
mov    0x28(%rbp),%r15
mov    0x30(%rbp),%r14
mov    0x38(%rbp),%rbx
mov    0x40(%rbp),%r11
mov    0x48(%rbp),%r10
mov    0x50(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,(%rsp)
mov    -0x7c(%rbp),%eax
mov    %r13,0x8(%rsp)
mov    %r12,0x10(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14,0x20(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r11,0x30(%rsp)
mov    %r10,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1070 <exchange@plt>
mov    0x20(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    15fd <trade+0x49d>
movl   $0xffffffff,-0x5c(%rbp)
lea    0xb61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    15ec <trade+0x48c>
movl   $0xffffffff,-0x5c(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    13de <trade+0x27e>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<trade>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r13
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbx
mov    0xd0(%rsp),%eax
mov    0xb0(%rsp),%rbp
mov    0xa0(%rsp),%r14
test   %eax,%eax
je     12a7 <trade+0x137>
cmp    $0x1,%eax
jne    12d1 <trade+0x161>
movslq 0x0(%rbp),%rax
mov    0x98(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
lea    -0xe(%rsi),%eax
cmp    $0x8,%eax
ja     12e0 <trade+0x170>
mov    %rdi,0x18(%rsp)
lea    0xf81(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1060 <magiccount@plt>
cmp    $0x6,%eax
jl     1315 <trade+0x1a5>
lea    0xf8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdi
call   1050 <getint@plt>
cmpl   $0x1,0xc(%rsp)
jne    1315 <trade+0x1a5>
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x40(%rsp)
mov    0x128(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x120(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x118(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    %rbp,0x20(%rsp)
mov    0x108(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %r14,0x10(%rsp)
mov    0xf8(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0xf0(%rsp),%rax
mov    %rax,(%rsp)
movq   $0x0,0x50(%rsp)
mov    0x78(%rsp),%rdi
mov    %rbx,%rsi
mov    0x70(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r15,%r9
call   1090 <stealingspirit@plt>
add    $0x60,%rsp
jmp    1315 <trade+0x1a5>
movslq 0x0(%rbp),%rax
mov    0x98(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
imul   $0xc4ec4ec5,%esi,%eax
add    $0x9d89d89,%eax
cmp    $0x13b13b12,%eax
ja     12e0 <trade+0x170>
lea    0xe5c(%rip),%rdi
jmp    1310 <trade+0x1a0>
movslq 0x0(%rbp),%rax
mov    0x98(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
cmp    $0x1a,%esi
jl     1339 <trade+0x1c9>
movslq %esi,%rax
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
cmp    $0xb,%eax
jne    1339 <trade+0x1c9>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
movslq 0x0(%rbp),%rax
mov    0x98(%rsp),%rcx
movl   $0xffffffff,(%rcx,%rax,4)
movslq 0x0(%rbp),%rax
movl   $0x2,(%r14,%rax,4)
jmp    14f2 <trade+0x382>
mov    %rdi,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r12,0x28(%rsp)
mov    %r13,0x30(%rsp)
mov    %r15,0x38(%rsp)
mov    %rbp,%rbx
lea    0x40(%rsp),%r14
mov    %r14,%rdi
call   1070 <nameitem@plt>
lea    0xd37(%rip),%r15
lea    0xe49(%rip),%r13
lea    0xc(%rsp),%rbp
lea    0xd44(%rip),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq (%rbx),%rax
mov    0x98(%rsp),%rcx
mov    (%rcx,%rax,4),%eax
imul   $0xc4ec4ec5,%eax,%ecx
add    $0x9d89d89,%ecx
cmp    $0x13b13b12,%ecx
jbe    13f0 <trade+0x280>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <getint@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1448 <trade+0x2d8>
cmp    $0x1,%eax
je     1467 <trade+0x2f7>
movl   $0xffffffff,0xc(%rsp)
ff
mov    %r12,%rdi
call   1030 <puts@plt>
movl   $0xffffffff,0xc(%rsp)
ff
jmp    1380 <trade+0x210>
xchg   %ax,%ax
cmp    $0x27,%eax
ja     13af <trade+0x23f>
mov    %eax,%eax
lea    0xc02(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x10(%rsp),%rax
cmpl   $0x1,(%rax)
jne    13af <trade+0x23f>
jmp    143c <trade+0x2cc>
mov    0x10(%rsp),%rax
cmpl   $0x1,0x4(%rax)
jne    13af <trade+0x23f>
jmp    143c <trade+0x2cc>
mov    0x10(%rsp),%rax
cmpl   $0x1,0x8(%rax)
jne    13af <trade+0x23f>
jmp    143c <trade+0x2cc>
mov    0x10(%rsp),%rax
cmpl   $0x1,0xc(%rax)
jne    13af <trade+0x23f>
lea    0xc85(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
mov    $0xffffffff,%ecx
mov    0x98(%rsp),%rdx
mov    0xa0(%rsp),%rdi
mov    %rbx,%rbp
jmp    14e4 <trade+0x374>
sub    $0x8,%rsp
mov    0x20(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    0x30(%rsp),%rcx
mov    0x38(%rsp),%r8
mov    0x40(%rsp),%r9
mov    0xd8(%rsp),%eax
push   %rax
push   0xd8(%rsp)
push   0xd8(%rsp)
push   0xd8(%rsp)
mov    %rbx,%rbp
push   %rbx
push   0xd8(%rsp)
mov    0xd8(%rsp),%rbx
push   %rbx
mov    0xd8(%rsp),%r14
push   %r14
push   0xd8(%rsp)
call   1080 <exchange@plt>
add    $0x50,%rsp
mov    $0xffffffff,%eax
mov    $0x2,%ecx
mov    %rbx,%rdx
mov    %r14,%rdi
movslq 0x0(%rbp),%rsi
mov    %ecx,(%rdx,%rsi,4)
movslq 0x0(%rbp),%rcx
mov    %eax,(%rdi,%rcx,4)
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"'I'm sorry, but I have already sold my goods.'\0A\00"
@.str.1 = [61 x i8] c"Do you want to use a StealingSpirit spell?\0A[0]: No\0A[1]: Yes\0A\00"
@.str.2 = [26 x i8] c"The merchant disappears!\0A\00"
@.str.3 = [53 x i8] c"'I'm sorry, but I don't want to trade my artifact.'\0A\00"
@.str.4 = [58 x i8] c"'I don't think you are interest in a black priestess...'\0A\00"
@.str.5 = [32 x i8] c"'Are you interested in my %s?'\0A\00"
@.str.6 = [43 x i8] c"You see it's only a pathetic imitation...\0A\00"
@.str.7 = [18 x i8] c"[0]: No\0A[1]: Yes\0A\00"
@.str.8 = [9 x i8] c"'What?'\0A\00"
define void @trade(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) {
%16 = alloca i32*
%17 = alloca i32*
%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 [20 x i8]
store i32* %0, i32** %16
store i32* %1, i32** %17
store i32* %2, i32** %18
store i32* %3, i32** %19
store i32* %4, i32** %20
store i32* %5, i32** %21
store i32* %6, i32** %22
store i32* %7, i32** %23
store i32* %8, i32** %24
store i32* %9, i32** %25
store i32* %10, i32** %26
store i32* %11, i32** %27
store i32* %12, i32** %28
store i32* %13, i32** %29
store i32 %14, i32* %30
%33 = load i32, i32* %30
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %95
35: ; preds = %15
%36 = load i32*, i32** %23
%37 = load i32*, i32** %26
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %36, i64 %39
%41 = load i32, i32* %40
%42 = icmp sgt i32 %41, 13
br i1 %42, label %43, label %95
43: ; preds = %35
%44 = load i32*, i32** %23
%45 = load i32*, i32** %26
%46 = load i32, i32* %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %44, i64 %47
%49 = load i32, i32* %48
%50 = icmp slt i32 %49, 23
br i1 %50, label %51, label %95
51: ; preds = %43
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%53 = load i32*, i32** %18
%54 = load i32*, i32** %19
%55 = call i32 @magiccount(i32* %53, i32* %54)
%56 = icmp sgt i32 %55, 5
br i1 %56, label %57, label %84
57: ; preds = %51
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%59 = call i32 @getint(i32* %31)
%60 = load i32, i32* %31
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %83
62: ; preds = %57
%63 = load i32*, i32** %16
%64 = load i32*, i32** %17
%65 = load i32*, i32** %18
%66 = load i32*, i32** %19
%67 = load i32*, i32** %21
%68 = load i32*, i32** %20
%69 = load i32*, i32** %22
%70 = load i32*, i32** %23
%71 = load i32*, i32** %24
%72 = load i32*, i32** %25
%73 = load i32*, i32** %26
%74 = load i32*, i32** %27
%75 = load i32*, i32** %28
%76 = load i32*, i32** %29
%77 = call i32 @stealingspirit(i32* %63, i32* %64, i32* %65, i32* %66, i32* %67, i32* %68, i32* %69, i32* %70, i32* %71, i32* %72, i32* %73, i32* %74, i32* %75, i32* %76, i32* null, i32* null, i32* null)
%78 = load i32, i32* %30
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %62
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %82
82: ; preds = %80, %62
br label %83
83: ; preds = %82, %57
br label %84
84: ; preds = %83, %51
%85 = load i32*, i32** %23
%86 = load i32*, i32** %26
%87 = load i32, i32* %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %85, i64 %88
store i32 -1, i32* %89
%90 = load i32*, i32** %24
%91 = load i32*, i32** %26
%92 = load i32, i32* %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %90, i64 %93
store i32 2, i32* %94
br label %282
95: ; preds = %43, %35, %15
%96 = load i32, i32* %30
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %119
98: ; preds = %95
%99 = load i32*, i32** %23
%100 = load i32*, i32** %26
%101 = load i32, i32* %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %99, i64 %102
%104 = load i32, i32* %103
%105 = srem i32 %104, 13
%106 = icmp eq i32 %105, 0
br i1 %106, label %107, label %119
107: ; preds = %98
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%109 = load i32*, i32** %23
%110 = load i32*, i32** %26
%111 = load i32, i32* %110
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i32, i32* %109, i64 %112
store i32 -1, i32* %113
%114 = load i32*, i32** %24
%115 = load i32*, i32** %26
%116 = load i32, i32* %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i32, i32* %114, i64 %117
store i32 2, i32* %118
br label %282
119: ; preds = %98, %95
%120 = load i32*, i32** %23
%121 = load i32*, i32** %26
%122 = load i32, i32* %121
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %120, i64 %123
%125 = load i32, i32* %124
%126 = srem i32 %125, 13
%127 = icmp eq i32 %126, 11
br i1 %127, label %128, label %148
128: ; preds = %119
%129 = load i32*, i32** %23
%130 = load i32*, i32** %26
%131 = load i32, i32* %130
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32, i32* %129, i64 %132
%134 = load i32, i32* %133
%135 = icmp sgt i32 %134, 25
br i1 %135, label %136, label %148
136: ; preds = %128
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
%138 = load i32*, i32** %23
%139 = load i32*, i32** %26
%140 = load i32, i32* %139
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i32, i32* %138, i64 %141
store i32 -1, i32* %142
%143 = load i32*, i32** %24
%144 = load i32*, i32** %26
%145 = load i32, i32* %144
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i32, i32* %143, i64 %146
store i32 2, i32* %147
br label %282
148: ; preds = %128, %119
%149 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%150 = load i32*, i32** %23
%151 = load i32*, i32** %26
%152 = load i32, i32* %151
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %150, i64 %153
%155 = load i32, i32* %154
%156 = call i32 @nameitem(i8* %149, i32 %155)
br label %157
157: ; preds = %281, %148
%158 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %158)
%160 = load i32*, i32** %23
%161 = load i32*, i32** %26
%162 = load i32, i32* %161
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i32, i32* %160, i64 %163
%165 = load i32, i32* %164
%166 = srem i32 %165, 13
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %232
168: ; preds = %157
%169 = load i32*, i32** %23
%170 = load i32*, i32** %26
%171 = load i32, i32* %170
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i32, i32* %169, i64 %172
%174 = load i32, i32* %173
%175 = icmp eq i32 %174, 0
br i1 %175, label %176, label %180
176: ; preds = %168
%177 = load i32*, i32** %18
%178 = load i32, i32* %177
%179 = icmp eq i32 %178, 1
br i1 %179, label %219, label %180
180: ; preds = %176, %168
%181 = load i32*, i32** %23
%182 = load i32*, i32** %26
%183 = load i32, i32* %182
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds i32, i32* %181, i64 %184
%186 = load i32, i32* %185
%187 = icmp eq i32 %186, 13
br i1 %187, label %188, label %193
188: ; preds = %180
%189 = load i32*, i32** %18
%190 = getelementptr inbounds i32, i32* %189, i64 1
%191 = load i32, i32* %190
%192 = icmp eq i32 %191, 1
br i1 %192, label %219, label %193
193: ; preds = %188, %180
%194 = load i32*, i32** %23
%195 = load i32*, i32** %26
%196 = load i32, i32* %195
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds i32, i32* %194, i64 %197
%199 = load i32, i32* %198
%200 = icmp eq i32 %199, 26
br i1 %200, label %201, label %206
201: ; preds = %193
%202 = load i32*, i32** %18
%203 = getelementptr inbounds i32, i32* %202, i64 2
%204 = load i32, i32* %203
%205 = icmp eq i32 %204, 1
br i1 %205, label %219, label %206
206: ; preds = %201, %193
%207 = load i32*, i32** %23
%208 = load i32*, i32** %26
%209 = load i32, i32* %208
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i32, i32* %207, i64 %210
%212 = load i32, i32* %211
%213 = icmp eq i32 %212, 39
br i1 %213, label %214, label %231
214: ; preds = %206
%215 = load i32*, i32** %18
%216 = getelementptr inbounds i32, i32* %215, i64 3
%217 = load i32, i32* %216
%218 = icmp eq i32 %217, 1
br i1 %218, label %219, label %231
219: ; preds = %214, %201, %188, %176
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%221 = load i32*, i32** %23
%222 = load i32*, i32** %26
%223 = load i32, i32* %222
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds i32, i32* %221, i64 %224
store i32 -1, i32* %225
%226 = load i32*, i32** %24
%227 = load i32*, i32** %26
%228 = load i32, i32* %227
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds i32, i32* %226, i64 %229
store i32 2, i32* %230
br label %282
231: ; preds = %214, %206
br label %232
232: ; preds = %231, %157
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%234 = call i32 @getint(i32* %31)
%235 = load i32, i32* %31
%236 = icmp eq i32 %235, 0
br i1 %236, label %237, label %248
237: ; preds = %232
%238 = load i32*, i32** %23
%239 = load i32*, i32** %26
%240 = load i32, i32* %239
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i32, i32* %238, i64 %241
store i32 -1, i32* %242
%243 = load i32*, i32** %24
%244 = load i32*, i32** %26
%245 = load i32, i32* %244
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds i32, i32* %243, i64 %246
store i32 2, i32* %247
br label %282
248: ; preds = %232
%249 = load i32, i32* %31
%250 = icmp eq i32 %249, 1
br i1 %250, label %251, label %278
251: ; preds = %248
%252 = load i32*, i32** %16
%253 = load i32*, i32** %17
%254 = load i32*, i32** %18
%255 = load i32*, i32** %19
%256 = load i32*, i32** %21
%257 = load i32*, i32** %20
%258 = load i32*, i32** %22
%259 = load i32*, i32** %23
%260 = load i32*, i32** %24
%261 = load i32*, i32** %25
%262 = load i32*, i32** %26
%263 = load i32*, i32** %27
%264 = load i32*, i32** %28
%265 = load i32*, i32** %29
%266 = load i32, i32* %30
%267 = call i32 @exchange(i32* %252, i32* %253, i32* %254, i32* %255, i32* %256, i32* %257, i32* %258, i32* %259, i32* %260, i32* %261, i32* %262, i32* %263, i32* %264, i32* %265, i32 %266)
%268 = load i32*, i32** %24
%269 = load i32*, i32** %26
%270 = load i32, i32* %269
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds i32, i32* %268, i64 %271
store i32 2, i32* %272
%273 = load i32*, i32** %23
%274 = load i32*, i32** %26
%275 = load i32, i32* %274
%276 = sext i32 %275 to i64
%277 = getelementptr inbounds i32, i32* %273, i64 %276
store i32 -1, i32* %277
br label %282
278: ; preds = %248
store i32 -1, i32* %31
%279 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %280
280: ; preds = %278
br label %281
281: ; preds = %280
store i32 -1, i32* %31
br i1 true, label %157, label %282
282: ; preds = %84, %107, %136, %219, %237, %251, %281
ret void
}

LLVM IR (-O2):
@.str.5 = [32 x i8] c"'Are you interested in my %s?'\0A\00"
@str = [17 x i8] c"[0]: No\0A[1]: Yes\00"
@str.9 = [8 x i8] c"'What?'\00"
@str.10 = [42 x i8] c"You see it's only a pathetic imitation...\00"
@str.11 = [57 x i8] c"'I don't think you are interest in a black priestess...'\00"
@str.12 = [52 x i8] c"'I'm sorry, but I don't want to trade my artifact.'\00"
@str.13 = [47 x i8] c"'I'm sorry, but I have already sold my goods.'\00"
@str.14 = [60 x i8] c"Do you want to use a StealingSpirit spell?\0A[0]: No\0A[1]: Yes\00"
define void @trade(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) {
%16 = alloca i32
%17 = alloca [20 x i8]
%18 = bitcast i32* %16 to i8*
switch i32 %14, label %19 [
i32 1, label %24
i32 0, label %49
]
19: ; preds = %15
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %7, i64 %21
%23 = load i32, i32* %22
br label %64
24: ; preds = %15
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %7, i64 %26
%28 = load i32, i32* %27
%29 = add i32 %28, -14
%30 = icmp ult i32 %29, 9
br i1 %30, label %31, label %64
31: ; preds = %24
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.13, i64 0, i64 0))
%33 = tail call i32 @magiccount(i32* %2, i32* %3)
%34 = icmp sgt i32 %33, 5
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.14, i64 0, i64 0))
%37 = call i32 @getint(i32* %16)
%38 = load i32, i32* %16
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @stealingspirit(i32* %0, i32* %1, i32* %2, i32* %3, i32* %5, i32* %4, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* null, i32* null, i32* null)
br label %42
42: ; preds = %40, %35, %31
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %7, i64 %44
store i32 -1, i32* %45
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %8, i64 %47
store i32 2, i32* %48
br label %126
49: ; preds = %15
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %7, i64 %51
%53 = load i32, i32* %52
%54 = srem i32 %53, 13
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %49
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.12, i64 0, i64 0))
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %7, i64 %59
store i32 -1, i32* %60
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %8, i64 %62
store i32 2, i32* %63
br label %126
64: ; preds = %19, %24, %49
%65 = phi i32 [ %23, %19 ], [ %28, %24 ], [ %53, %49 ]
%66 = srem i32 %65, 13
%67 = icmp eq i32 %66, 11
%68 = icmp sgt i32 %65, 25
%69 = and i1 %68, %67
br i1 %69, label %70, label %78
70: ; preds = %64
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.11, i64 0, i64 0))
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %7, i64 %73
store i32 -1, i32* %74
%75 = load i32, i32* %10
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %8, i64 %76
store i32 2, i32* %77
br label %126
78: ; preds = %64
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%80 = call i32 @nameitem(i8* %79, i32 %65)
%81 = getelementptr inbounds i32, i32* %2, i64 3
%82 = getelementptr inbounds i32, i32* %2, i64 2
%83 = getelementptr inbounds i32, i32* %2, i64 1
br label %84
84: ; preds = %113, %78
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %79)
%86 = load i32, i32* %10
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %7, i64 %87
%89 = load i32, i32* %88
%90 = srem i32 %89, 13
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %107
92: ; preds = %84
switch i32 %89, label %107 [
i32 0, label %93
i32 13, label %96
i32 26, label %99
i32 39, label %102
]
93: ; preds = %92
%94 = load i32, i32* %2
%95 = icmp eq i32 %94, 1
br i1 %95, label %105, label %107
96: ; preds = %92
%97 = load i32, i32* %83
%98 = icmp eq i32 %97, 1
br i1 %98, label %105, label %107
99: ; preds = %92
%100 = load i32, i32* %82
%101 = icmp eq i32 %100, 1
br i1 %101, label %105, label %107
102: ; preds = %92
%103 = load i32, i32* %81
%104 = icmp eq i32 %103, 1
br i1 %104, label %105, label %107
105: ; preds = %102, %99, %96, %93
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.10, i64 0, i64 0))
br label %115
107: ; preds = %92, %93, %96, %99, %102, %84
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%109 = call i32 @getint(i32* %16)
%110 = load i32, i32* %16
switch i32 %110, label %113 [
i32 0, label %115
i32 1, label %111
]
111: ; preds = %107
%112 = call i32 @exchange(i32* %0, i32* %1, i32* %2, i32* %3, i32* %5, i32* %4, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32 %14)
br label %115
113: ; preds = %107
store i32 -1, i32* %16
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
store i32 -1, i32* %16
br label %84
115: ; preds = %107, %111, %105
%116 = phi i32* [ %8, %111 ], [ %7, %105 ], [ %7, %107 ]
%117 = phi i32 [ 2, %111 ], [ -1, %105 ], [ -1, %107 ]
%118 = phi i32* [ %7, %111 ], [ %8, %105 ], [ %8, %107 ]
%119 = phi i32 [ -1, %111 ], [ 2, %105 ], [ 2, %107 ]
%120 = load i32, i32* %10
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %116, i64 %121
store i32 %117, i32* %122
%123 = load i32, i32* %10
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i32, i32* %118, i64 %124
store i32 %119, i32* %125
br label %126
126: ; preds = %115, %70, %56, %42
ret void
}