#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 /*<<< orphan*/ nameitem(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 valueitem(int);
void gemoffer(int *hpmax, int *hpnow, int *aces, int *inv, int *slave,
              int *future, int *map, int *loot, int *vision, int *end, int *pos,
              int *antimag) {
  int value = 0;
  int k;
  int offgem[10];
  for (k = 0; k < 10; k++) {
    offgem[k] = 0;
  }
  char s[20];
  int p = -1;
  do {
    printf("'What gem do you want to offer?'\n");
    getint(&k);
    if ((k < 0) || (k >= 10) || (*(inv + k) == 0)) {
      printf("'Are you kidding me? Do you want to abort the trade?'\n[0]: "
             "No\n[1]: Yes\n");
      getint(&k);
      if (k == 1)
        return;
    } else if ((*(inv + k) > 22) || (*(inv + k) < 14)) {
      printf("'That's not a gem! Do you want to abort the trade?'\n[0]: "
             "No\n[1]: Yes\n");
      getint(&k);
      if (k == 1) {
        printf("You aborted the trade.\n");
        return;
      }
    } else {
      value += *(inv + k) % 13;
      p++;
      offgem[p] = *(inv + k);
    }
    if (value < valueitem(*(loot + *pos)))
      printf("'My item is valued %d gems and you offer is worth %d gems.'\n",
             valueitem(*(loot + *pos)), value);
    else {
      printf("'I'm satisfied with your offer of %d gems:", value);
      for (k = 0; k <= p; k++) {
        nameitem(s, offgem[k]);
        if (k == p) {
          printf(" %s gems.'\n", s);
        } else {
          printf(" %s gems,", s);
        }
      }
      k = -1;
      do {
        printf("'Do you accept the trade?'\n[0]: No\n[1]: Yes\n");
        getint(&k);
        if (k == 0) {
          printf("'Do you want to abort the trade?'\n[0]: No\n[1]: Yes\n");
          getint(&k);
          if (k == 1) {
            printf("You aborted the trade.\n");
            return;
          }
          printf(
              "'Do you want to propose another offer?'\n[0]: No\n[1]: Yes\n");
          if (k == 0) {
            printf("You aborted the trade.\n");
            return;
          }
          for (k = 0; k < 10; k++) {
            offgem[k] = 0;
          }
          p = -1;
        } else if (k == 1) {
          for (k = 0; k <= p; k++) {
            *(inv + offgem[k]) = 0;
          }
          treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision,
                   end, pos, antimag, 0, 1, 0);
        }
      } while (k < 0);
    }
  } while (value < valueitem(*(loot + *pos)));
}


x86 assembly (clang, -O0):
<gemoffer>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
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,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %r8,-0x48(%rbp)
mov    %r9,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0xa,-0x58(%rbp)
jge    11c4 <gemoffer+0x74>
movslq -0x58(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11a0 <gemoffer+0x50>
movl   $0xffffffff,-0xa4(%rbp)
ff ff ff
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x58(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x0,-0x58(%rbp)
jl     120b <gemoffer+0xbb>
cmpl   $0xa,-0x58(%rbp)
jge    120b <gemoffer+0xbb>
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1236 <gemoffer+0xe6>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x58(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x1,-0x58(%rbp)
jne    1231 <gemoffer+0xe1>
jmp    1573 <gemoffer+0x423>
jmp    12d6 <gemoffer+0x186>
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
cmpl   $0x16,(%rax,%rcx,4)
jg     125a <gemoffer+0x10a>
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
cmpl   $0xe,(%rax,%rcx,4)
jge    1293 <gemoffer+0x143>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x58(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x1,-0x58(%rbp)
jne    128e <gemoffer+0x13e>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1573 <gemoffer+0x423>
jmp    12d1 <gemoffer+0x181>
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
add    -0x54(%rbp),%edx
mov    %edx,-0x54(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0xa4(%rbp),%rax
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    12d6 <gemoffer+0x186>
mov    -0x54(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   1070 <valueitem@plt>
mov    %eax,%ecx
mov    -0xa8(%rbp),%eax
cmp    %ecx,%eax
jge    132d <gemoffer+0x1dd>
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   1070 <valueitem@plt>
mov    %eax,%esi
mov    -0x54(%rbp),%edx
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1542 <gemoffer+0x3f2>
mov    -0x54(%rbp),%esi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jg     13b9 <gemoffer+0x269>
lea    -0xa0(%rbp),%rdi
movslq -0x58(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
call   1060 <nameitem@plt>
mov    -0x58(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jne    1391 <gemoffer+0x241>
lea    -0xa0(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a6 <gemoffer+0x256>
lea    -0xa0(%rbp),%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13ab <gemoffer+0x25b>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1345 <gemoffer+0x1f5>
movl   $0xffffffff,-0x58(%rbp)
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x58(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x0,-0x58(%rbp)
jne    147a <gemoffer+0x32a>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x58(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x1,-0x58(%rbp)
jne    1415 <gemoffer+0x2c5>
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1573 <gemoffer+0x423>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x58(%rbp)
jne    1440 <gemoffer+0x2f0>
lea    0xc7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1573 <gemoffer+0x423>
movl   $0x0,-0x58(%rbp)
cmpl   $0xa,-0x58(%rbp)
jge    146b <gemoffer+0x31b>
movslq -0x58(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1447 <gemoffer+0x2f7>
movl   $0xffffffff,-0xa4(%rbp)
ff ff ff
jmp    152e <gemoffer+0x3de>
cmpl   $0x1,-0x58(%rbp)
jne    1529 <gemoffer+0x3d9>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jg     14bc <gemoffer+0x36c>
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
movslq -0x80(%rbp,%rcx,4),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    148b <gemoffer+0x33b>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    0x10(%rbp),%r15
mov    0x18(%rbp),%r14
mov    0x20(%rbp),%rbx
mov    0x28(%rbp),%r11
mov    0x30(%rbp),%r10
mov    0x38(%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    152e <gemoffer+0x3de>
jmp    1533 <gemoffer+0x3e3>
cmpl   $0x0,-0x58(%rbp)
jl     13c0 <gemoffer+0x270>
jmp    1542 <gemoffer+0x3f2>
jmp    1547 <gemoffer+0x3f7>
mov    -0x54(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    0x18(%rbp),%rax
mov    0x30(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   1070 <valueitem@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
jl     11ce <gemoffer+0x7e>
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<gemoffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,0x68(%rsp)
mov    %r8,0x60(%rsp)
mov    %rcx,%rbx
mov    %rdx,0x58(%rsp)
mov    %rsi,0x50(%rsp)
mov    %rdi,0x48(%rsp)
mov    0xe0(%rsp),%r13
mov    0xc8(%rsp),%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
movl   $0xa,0x8(%rsp)
mov    $0xffffffff,%r12d
lea    0x70(%rsp),%rbp
movl   $0x0,0xc(%rsp)
jmp    1206 <gemoffer+0xa6>
movslq 0x0(%r13),%rax
mov    (%r14,%rax,4),%edi
call   1080 <valueitem@plt>
lea    0xe1c(%rip),%rdi
mov    %eax,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x0(%r13),%rax
mov    (%r14,%rax,4),%edi
call   1080 <valueitem@plt>
cmp    %eax,%r15d
jge    1504 <gemoffer+0x3a4>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <getint@plt>
mov    0x8(%rsp),%eax
cmp    $0x9,%rax
ja     1260 <gemoffer+0x100>
mov    (%rbx,%rax,4),%eax
test   %eax,%eax
je     1260 <gemoffer+0x100>
lea    -0x17(%rax),%ecx
cmp    $0xfffffff6,%ecx
ja     14d0 <gemoffer+0x370>
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <getint@plt>
cmpl   $0x1,0x8(%rsp)
jne    1281 <gemoffer+0x121>
jmp    14f8 <gemoffer+0x398>
nopl   0x0(%rax,%rax,1)
lea    0xf2c(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <getint@plt>
cmpl   $0x1,0x8(%rsp)
je     1504 <gemoffer+0x3a4>
movslq 0x0(%r13),%rax
mov    (%r14,%rax,4),%edi
call   1080 <valueitem@plt>
mov    0xc(%rsp),%r15d
cmp    %eax,%r15d
jl     11d0 <gemoffer+0x70>
lea    0xd9a(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x0,0x8(%rsp)
test   %r12d,%r12d
lea    0xda9(%rip),%r14
lea    0xdae(%rip),%r15
js     1304 <gemoffer+0x1a4>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
cltq
mov    0x10(%rsp,%rax,4),%esi
mov    %rbp,%rdi
call   1070 <nameitem@plt>
cmp    %r12d,0x8(%rsp)
mov    %r15,%rdi
cmove  %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0x8(%rsp)
cmp    %r12d,%ecx
jl     12d0 <gemoffer+0x170>
movl   $0xffffffff,0x8(%rsp)
ff
lea    0x1(%r12),%r15d
lea    -0x1(%r15),%rax
mov    %rax,0x40(%rsp)
mov    %r15d,%r13d
and    $0x3,%r13d
mov    %r15d,%r14d
and    $0xfffffffc,%r14d
jmp    1340 <gemoffer+0x1e0>
nopw   0x0(%rax,%rax,1)
test   %eax,%eax
je     1462 <gemoffer+0x302>
test   %eax,%eax
jns    1450 <gemoffer+0x2f0>
lea    0xd58(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <getint@plt>
mov    0x8(%rsp),%eax
cmp    $0x1,%eax
jne    1330 <gemoffer+0x1d0>
test   %r12d,%r12d
js     1370 <gemoffer+0x210>
cmpq   $0x3,0x40(%rsp)
jae    1374 <gemoffer+0x214>
xor    %eax,%eax
jmp    13b9 <gemoffer+0x259>
xor    %ecx,%ecx
jmp    13e7 <gemoffer+0x287>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movslq 0x10(%rsp,%rax,4),%rcx
movl   $0x0,(%rbx,%rcx,4)
movslq 0x14(%rsp,%rax,4),%rcx
movl   $0x0,(%rbx,%rcx,4)
movslq 0x18(%rsp,%rax,4),%rcx
movl   $0x0,(%rbx,%rcx,4)
movslq 0x1c(%rsp,%rax,4),%rcx
movl   $0x0,(%rbx,%rcx,4)
add    $0x4,%rax
cmp    %rax,%r14
jne    1380 <gemoffer+0x220>
mov    %r15d,%ecx
test   %r13,%r13
je     13e7 <gemoffer+0x287>
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movslq (%rax,%rcx,4),%rdx
movl   $0x0,(%rbx,%rdx,4)
add    $0x1,%rcx
cmp    %rcx,%r13
jne    13d0 <gemoffer+0x270>
mov    %r15d,%ecx
mov    %ecx,0x8(%rsp)
sub    $0x8,%rsp
mov    0x50(%rsp),%rdi
mov    0x58(%rsp),%rsi
mov    0x60(%rsp),%rdx
mov    %rbx,%rcx
mov    0x68(%rsp),%r8
mov    0x70(%rsp),%r9
push   $0x0
push   $0x1
push   $0x0
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
call   1030 <treasure@plt>
add    $0x50,%rsp
mov    0x8(%rsp),%eax
test   %eax,%eax
js     1340 <gemoffer+0x1e0>
mov    0xe0(%rsp),%r13
mov    0xc8(%rsp),%r14
jmp    14c6 <gemoffer+0x366>
lea    0xc62(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <getint@plt>
cmpl   $0x1,0x8(%rsp)
mov    0xe0(%rsp),%r13
mov    0xc8(%rsp),%r14
je     14f8 <gemoffer+0x398>
lea    0xc68(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x8(%rsp)
je     14f8 <gemoffer+0x398>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
movl   $0xa,0x8(%rsp)
mov    $0xffffffff,%r12d
mov    0xc(%rsp),%r15d
jmp    11f0 <gemoffer+0x90>
movzbl %al,%ecx
imul   $0x4f,%ecx,%edx
shr    $0xa,%edx
lea    (%rdx,%rdx,2),%esi
lea    (%rdx,%rsi,4),%edx
sub    %dl,%cl
movzbl %cl,%ecx
add    %ecx,0xc(%rsp)
movslq %r12d,%rcx
add    $0x1,%r12d
mov    %eax,0x14(%rsp,%rcx,4)
jmp    1281 <gemoffer+0x121>
lea    0xc7d(%rip),%rdi
call   1040 <puts@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"'What gem do you want to offer?'\0A\00"
@.str.1 = [72 x i8] c"'Are you kidding me? Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\0A\00"
@.str.2 = [70 x i8] c"'That's not a gem! Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\0A\00"
@.str.3 = [24 x i8] c"You aborted the trade.\0A\00"
@.str.4 = [61 x i8] c"'My item is valued %d gems and you offer is worth %d gems.'\0A\00"
@.str.5 = [43 x i8] c"'I'm satisfied with your offer of %d gems:\00"
@.str.6 = [12 x i8] c" %s gems.'\0A\00"
@.str.7 = [10 x i8] c" %s gems,\00"
@.str.8 = [45 x i8] c"'Do you accept the trade?'\0A[0]: No\0A[1]: Yes\0A\00"
@.str.9 = [52 x i8] c"'Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\0A\00"
@.str.10 = [58 x i8] c"'Do you want to propose another offer?'\0A[0]: No\0A[1]: Yes\0A\00"
define void @gemoffer(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11) {
%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*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32
%26 = alloca i32
%27 = alloca [10 x i32]
%28 = alloca [20 x i8]
%29 = alloca i32
store i32* %0, i32** %13
store i32* %1, i32** %14
store i32* %2, i32** %15
store i32* %3, i32** %16
store i32* %4, i32** %17
store i32* %5, i32** %18
store i32* %6, i32** %19
store i32* %7, i32** %20
store i32* %8, i32** %21
store i32* %9, i32** %22
store i32* %10, i32** %23
store i32* %11, i32** %24
store i32 0, i32* %25
store i32 0, i32* %26
br label %30
30: ; preds = %37, %12
%31 = load i32, i32* %26
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* %26
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %35
store i32 0, i32* %36
br label %37
37: ; preds = %33
%38 = load i32, i32* %26
%39 = add nsw i32 %38, 1
store i32 %39, i32* %26
br label %30
40: ; preds = %30
store i32 -1, i32* %29
br label %41
41: ; preds = %223, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%43 = call i32 @getint(i32* %26)
%44 = load i32, i32* %26
%45 = icmp slt i32 %44, 0
br i1 %45, label %56, label %46
46: ; preds = %41
%47 = load i32, i32* %26
%48 = icmp sge i32 %47, 10
br i1 %48, label %56, label %49
49: ; preds = %46
%50 = load i32*, i32** %16
%51 = load i32, i32* %26
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = load i32, i32* %53
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %49, %46, %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
%58 = call i32 @getint(i32* %26)
%59 = load i32, i32* %26
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %62
61: ; preds = %56
br label %233
62: ; preds = %56
br label %105
63: ; preds = %49
%64 = load i32*, i32** %16
%65 = load i32, i32* %26
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = icmp sgt i32 %68, 22
br i1 %69, label %77, label %70
70: ; preds = %63
%71 = load i32*, i32** %16
%72 = load i32, i32* %26
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
%75 = load i32, i32* %74
%76 = icmp slt i32 %75, 14
br i1 %76, label %77, label %85
77: ; preds = %70, %63
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%79 = call i32 @getint(i32* %26)
%80 = load i32, i32* %26
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %233
84: ; preds = %77
br label %104
85: ; preds = %70
%86 = load i32*, i32** %16
%87 = load i32, i32* %26
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %86, i64 %88
%90 = load i32, i32* %89
%91 = srem i32 %90, 13
%92 = load i32, i32* %25
%93 = add nsw i32 %92, %91
store i32 %93, i32* %25
%94 = load i32, i32* %29
%95 = add nsw i32 %94, 1
store i32 %95, i32* %29
%96 = load i32*, i32** %16
%97 = load i32, i32* %26
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %96, i64 %98
%100 = load i32, i32* %99
%101 = load i32, i32* %29
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %102
store i32 %100, i32* %103
br label %104
104: ; preds = %85, %84
br label %105
105: ; preds = %104, %62
%106 = load i32, i32* %25
%107 = load i32*, i32** %20
%108 = load i32*, i32** %23
%109 = load i32, i32* %108
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %107, i64 %110
%112 = load i32, i32* %111
%113 = call i32 @valueitem(i32 %112)
%114 = icmp slt i32 %106, %113
br i1 %114, label %115, label %125
115: ; preds = %105
%116 = load i32*, i32** %20
%117 = load i32*, i32** %23
%118 = load i32, i32* %117
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i32, i32* %116, i64 %119
%121 = load i32, i32* %120
%122 = call i32 @valueitem(i32 %121)
%123 = load i32, i32* %25
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i32 %122, i32 %123)
br label %222
125: ; preds = %105
%126 = load i32, i32* %25
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %126)
store i32 0, i32* %26
br label %128
128: ; preds = %149, %125
%129 = load i32, i32* %26
%130 = load i32, i32* %29
%131 = icmp sle i32 %129, %130
br i1 %131, label %132, label %152
132: ; preds = %128
%133 = getelementptr inbounds [20 x i8], [20 x i8]* %28, i64 0, i64 0
%134 = load i32, i32* %26
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %135
%137 = load i32, i32* %136
%138 = call i32 @nameitem(i8* %133, i32 %137)
%139 = load i32, i32* %26
%140 = load i32, i32* %29
%141 = icmp eq i32 %139, %140
br i1 %141, label %142, label %145
142: ; preds = %132
%143 = getelementptr inbounds [20 x i8], [20 x i8]* %28, i64 0, i64 0
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %143)
br label %148
145: ; preds = %132
%146 = getelementptr inbounds [20 x i8], [20 x i8]* %28, i64 0, i64 0
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %146)
br label %148
148: ; preds = %145, %142
br label %149
149: ; preds = %148
%150 = load i32, i32* %26
%151 = add nsw i32 %150, 1
store i32 %151, i32* %26
br label %128
152: ; preds = %128
store i32 -1, i32* %26
br label %153
153: ; preds = %218, %152
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%155 = call i32 @getint(i32* %26)
%156 = load i32, i32* %26
%157 = icmp eq i32 %156, 0
br i1 %157, label %158, label %183
158: ; preds = %153
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0))
%160 = call i32 @getint(i32* %26)
%161 = load i32, i32* %26
%162 = icmp eq i32 %161, 1
br i1 %162, label %163, label %165
163: ; preds = %158
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %233
165: ; preds = %158
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.10, i64 0, i64 0))
%167 = load i32, i32* %26
%168 = icmp eq i32 %167, 0
br i1 %168, label %169, label %171
169: ; preds = %165
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %233
171: ; preds = %165
store i32 0, i32* %26
br label %172
172: ; preds = %179, %171
%173 = load i32, i32* %26
%174 = icmp slt i32 %173, 10
br i1 %174, label %175, label %182
175: ; preds = %172
%176 = load i32, i32* %26
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %177
store i32 0, i32* %178
br label %179
179: ; preds = %175
%180 = load i32, i32* %26
%181 = add nsw i32 %180, 1
store i32 %181, i32* %26
br label %172
182: ; preds = %172
store i32 -1, i32* %29
br label %217
183: ; preds = %153
%184 = load i32, i32* %26
%185 = icmp eq i32 %184, 1
br i1 %185, label %186, label %216
186: ; preds = %183
store i32 0, i32* %26
br label %187
187: ; preds = %199, %186
%188 = load i32, i32* %26
%189 = load i32, i32* %29
%190 = icmp sle i32 %188, %189
br i1 %190, label %191, label %202
191: ; preds = %187
%192 = load i32*, i32** %16
%193 = load i32, i32* %26
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [10 x i32], [10 x i32]* %27, i64 0, i64 %194
%196 = load i32, i32* %195
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds i32, i32* %192, i64 %197
store i32 0, i32* %198
br label %199
199: ; preds = %191
%200 = load i32, i32* %26
%201 = add nsw i32 %200, 1
store i32 %201, i32* %26
br label %187
202: ; preds = %187
%203 = load i32*, i32** %13
%204 = load i32*, i32** %14
%205 = load i32*, i32** %15
%206 = load i32*, i32** %16
%207 = load i32*, i32** %17
%208 = load i32*, i32** %18
%209 = load i32*, i32** %19
%210 = load i32*, i32** %20
%211 = load i32*, i32** %21
%212 = load i32*, i32** %22
%213 = load i32*, i32** %23
%214 = load i32*, i32** %24
%215 = call i32 @treasure(i32* %203, i32* %204, i32* %205, i32* %206, i32* %207, i32* %208, i32* %209, i32* %210, i32* %211, i32* %212, i32* %213, i32* %214, i32 0, i32 1, i32 0)
br label %216
216: ; preds = %202, %183
br label %217
217: ; preds = %216, %182
br label %218
218: ; preds = %217
%219 = load i32, i32* %26
%220 = icmp slt i32 %219, 0
br i1 %220, label %153, label %221
221: ; preds = %218
br label %222
222: ; preds = %221, %115
br label %223
223: ; preds = %222
%224 = load i32, i32* %25
%225 = load i32*, i32** %20
%226 = load i32*, i32** %23
%227 = load i32, i32* %226
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds i32, i32* %225, i64 %228
%230 = load i32, i32* %229
%231 = call i32 @valueitem(i32 %230)
%232 = icmp slt i32 %224, %231
br i1 %232, label %41, label %233
233: ; preds = %61, %82, %163, %169, %223
ret void
}

LLVM IR (-O2):
@.str.4 = [61 x i8] c"'My item is valued %d gems and you offer is worth %d gems.'\0A\00"
@.str.5 = [43 x i8] c"'I'm satisfied with your offer of %d gems:\00"
@.str.6 = [12 x i8] c" %s gems.'\0A\00"
@.str.7 = [10 x i8] c" %s gems,\00"
@str = [33 x i8] c"'What gem do you want to offer?'\00"
@str.11 = [44 x i8] c"'Do you accept the trade?'\0A[0]: No\0A[1]: Yes\00"
@str.12 = [51 x i8] c"'Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\00"
@str.13 = [57 x i8] c"'Do you want to propose another offer?'\0A[0]: No\0A[1]: Yes\00"
@str.16 = [69 x i8] c"'That's not a gem! Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\00"
@str.17 = [23 x i8] c"You aborted the trade.\00"
@str.18 = [71 x i8] c"'Are you kidding me? Do you want to abort the trade?'\0A[0]: No\0A[1]: Yes\00"
define void @gemoffer(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11) {
%13 = alloca i32
%14 = alloca [10 x i32]
%15 = bitcast [10 x i32]* %14 to i8*
%16 = alloca [20 x i8]
%17 = bitcast i32* %13 to i8*
store i32 10, i32* %13
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %16, i64 0, i64 0
br label %19
19: ; preds = %152, %12
%20 = phi i32 [ 0, %12 ], [ %53, %152 ]
%21 = phi i32 [ -1, %12 ], [ %153, %152 ]
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%23 = call i32 @getint(i32* %13)
%24 = load i32, i32* %13
%25 = icmp ugt i32 %24, 9
br i1 %25, label %31, label %26
26: ; preds = %19
%27 = zext i32 %24 to i64
%28 = getelementptr inbounds i32, i32* %3, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26, %19
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.18, i64 0, i64 0))
%33 = call i32 @getint(i32* %13)
%34 = load i32, i32* %13
%35 = icmp eq i32 %34, 1
br i1 %35, label %163, label %52
36: ; preds = %26
%37 = add i32 %29, -23
%38 = icmp ult i32 %37, -9
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.16, i64 0, i64 0))
%41 = call i32 @getint(i32* %13)
%42 = load i32, i32* %13
%43 = icmp eq i32 %42, 1
br i1 %43, label %160, label %52
44: ; preds = %36
%45 = trunc i32 %29 to i8
%46 = urem i8 %45, 13
%47 = zext i8 %46 to i32
%48 = add nsw i32 %20, %47
%49 = add nsw i32 %21, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %50
store i32 %29, i32* %51
br label %52
52: ; preds = %44, %39, %31
%53 = phi i32 [ %20, %31 ], [ %20, %39 ], [ %48, %44 ]
%54 = phi i32 [ %21, %31 ], [ %21, %39 ], [ %49, %44 ]
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %7, i64 %56
%58 = load i32, i32* %57
%59 = call i32 @valueitem(i32 %58)
%60 = icmp slt i32 %53, %59
br i1 %60, label %61, label %68
61: ; preds = %52
%62 = load i32, i32* %10
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %7, i64 %63
%65 = load i32, i32* %64
%66 = call i32 @valueitem(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i32 %66, i32 %53)
br label %152
68: ; preds = %52
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %53)
store i32 0, i32* %13
%70 = icmp slt i32 %54, 0
br i1 %70, label %84, label %71
71: ; preds = %68, %71
%72 = phi i32 [ %82, %71 ], [ 0, %68 ]
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = call i32 @nameitem(i8* %18, i32 %75)
%77 = load i32, i32* %13
%78 = icmp eq i32 %77, %54
%79 = select i1 %78, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %79, i8* %18)
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 1
store i32 %82, i32* %13
%83 = icmp slt i32 %81, %54
br i1 %83, label %71, label %84
84: ; preds = %71, %68
store i32 -1, i32* %13
%85 = add i32 %54, 1
%86 = zext i32 %85 to i64
%87 = add nsw i64 %86, -1
%88 = and i64 %86, 3
%89 = icmp ult i64 %87, 3
%90 = and i64 %86, 4294967292
%91 = icmp eq i64 %88, 0
br label %92
92: ; preds = %149, %84
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.11, i64 0, i64 0))
%94 = call i32 @getint(i32* %13)
%95 = load i32, i32* %13
switch i32 %95, label %149 [
i32 0, label %98
i32 1, label %96
]
96: ; preds = %92
br i1 %70, label %145, label %97
97: ; preds = %96
br i1 %89, label %133, label %108
98: ; preds = %92
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
%100 = call i32 @getint(i32* %13)
%101 = load i32, i32* %13
%102 = icmp eq i32 %101, 1
br i1 %102, label %160, label %103
103: ; preds = %98
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.13, i64 0, i64 0))
%105 = load i32, i32* %13
%106 = icmp eq i32 %105, 0
br i1 %106, label %160, label %107
107: ; preds = %103
store i32 10, i32* %13
br label %152
108: ; preds = %97, %108
%109 = phi i64 [ %130, %108 ], [ 0, %97 ]
%110 = phi i64 [ %131, %108 ], [ 0, %97 ]
%111 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %109
%112 = load i32, i32* %111
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i32, i32* %3, i64 %113
store i32 0, i32* %114
%115 = or i64 %109, 1
%116 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i32, i32* %3, i64 %118
store i32 0, i32* %119
%120 = or i64 %109, 2
%121 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %120
%122 = load i32, i32* %121
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %3, i64 %123
store i32 0, i32* %124
%125 = or i64 %109, 3
%126 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %125
%127 = load i32, i32* %126
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i32, i32* %3, i64 %128
store i32 0, i32* %129
%130 = add nuw nsw i64 %109, 4
%131 = add i64 %110, 4
%132 = icmp eq i64 %131, %90
br i1 %132, label %133, label %108
133: ; preds = %108, %97
%134 = phi i64 [ 0, %97 ], [ %130, %108 ]
br i1 %91, label %145, label %135
135: ; preds = %133, %135
%136 = phi i64 [ %142, %135 ], [ %134, %133 ]
%137 = phi i64 [ %143, %135 ], [ 0, %133 ]
%138 = getelementptr inbounds [10 x i32], [10 x i32]* %14, i64 0, i64 %136
%139 = load i32, i32* %138
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %3, i64 %140
store i32 0, i32* %141
%142 = add nuw nsw i64 %136, 1
%143 = add i64 %137, 1
%144 = icmp eq i64 %143, %88
br i1 %144, label %145, label %135
145: ; preds = %133, %135, %96
%146 = phi i32 [ 0, %96 ], [ %85, %135 ], [ %85, %133 ]
store i32 %146, i32* %13
%147 = 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* %11, i32 0, i32 1, i32 0)
%148 = load i32, i32* %13
br label %149
149: ; preds = %92, %145
%150 = phi i32 [ %95, %92 ], [ %148, %145 ]
%151 = icmp slt i32 %150, 0
br i1 %151, label %92, label %152
152: ; preds = %149, %107, %61
%153 = phi i32 [ %54, %61 ], [ -1, %107 ], [ %54, %149 ]
%154 = load i32, i32* %10
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds i32, i32* %7, i64 %155
%157 = load i32, i32* %156
%158 = call i32 @valueitem(i32 %157)
%159 = icmp slt i32 %53, %158
br i1 %159, label %19, label %163
160: ; preds = %103, %98, %39
%161 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0), %39 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0), %98 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0), %103 ]
%162 = call i32 @puts(i8* dereferenceable(1) %161)
br label %163
163: ; preds = %152, %31, %160
ret void
}