#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ getint(int *);
int magicconsume(int *, int *, int, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *);
void stonestatue(int *aces, int *inv, int *map, int times, int combat,
                 int free) {
  if (combat == 1) {
    printf("Nope.\n");
    return;
  }
  int v;
  if (free == 0) {
    char s[20];
    memset(s, 0, sizeof(s));
    sprintf(s, "StoneStatue");
    v = magicconsume(aces, inv, 15, s);
    if (v < 0)
      return;
  }
  int e;
  for (v = 0; v < times; v++) {
    e = -1;
    do {
      printf("You can turn an enemy in a stone statue. You can do this %d "
             "times. What enemy do you want to kill?\n",
             times - v);
      getint(&e);
    } while ((e < 0) || (e > 11));
    if (*(map + e) > 0)
      *(map + e) = 0;
  }
}


x86 assembly (clang, -O0):
<stonestatue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    118c <stonestatue+0x3c>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <stonestatue+0x122>
cmpl   $0x0,-0x24(%rbp)
jne    11e3 <stonestatue+0x93>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rcx
mov    $0xf,%edx
call   1040 <magicconsume@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11de <stonestatue+0x8e>
jmp    1272 <stonestatue+0x122>
jmp    11e3 <stonestatue+0x93>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1272 <stonestatue+0x122>
movl   $0xffffffff,-0x44(%rbp)
mov    -0x1c(%rbp),%esi
sub    -0x28(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x44(%rbp),%rdi
call   1060 <getint@plt>
mov    $0x1,%al
cmpl   $0x0,-0x44(%rbp)
mov    %al,-0x45(%rbp)
jl     1233 <stonestatue+0xe3>
cmpl   $0xb,-0x44(%rbp)
setg   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    11fd <stonestatue+0xad>
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    125f <stonestatue+0x10f>
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1264 <stonestatue+0x114>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ea <stonestatue+0x9a>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stonestatue>:
cmp    $0x1,%r8d
jne    1162 <stonestatue+0x12>
lea    0xf13(%rip),%rdi
jmp    1030 <puts@plt>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
test   %r9d,%r9d
jne    11c0 <stonestatue+0x70>
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
movabs $0x617453656e6f7453,%rax
53 74 61
mov    %rax,(%rsp)
movl   $0x657574,0x8(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xf,%edx
mov    %r12,%rcx
call   1050 <magicconsume@plt>
test   %eax,%eax
js     122e <stonestatue+0xde>
test   %r15d,%r15d
jle    122e <stonestatue+0xde>
lea    0xe40(%rip),%r12
mov    %rsp,%rbp
xor    %r13d,%r13d
jmp    11e9 <stonestatue+0x99>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
cmp    %r15d,%r13d
je     122e <stonestatue+0xde>
movl   $0xffffffff,(%rsp)
mov    %r15d,%ebx
sub    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1070 <getint@plt>
mov    (%rsp),%eax
cmp    $0xb,%rax
ja     1200 <stonestatue+0xb0>
cmpl   $0x0,(%r14,%rax,4)
jle    11e0 <stonestatue+0x90>
movl   $0x0,(%r14,%rax,4)
jmp    11e0 <stonestatue+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Nope.\0A\00"
@.str.1 = [12 x i8] c"StoneStatue\00"
@.str.2 = [100 x i8] c"You can turn an enemy in a stone statue. You can do this %d times. What enemy do you want to kill?\0A\00"
define void @stonestatue(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [20 x i8]
%15 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %11
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %72
20: ; preds = %6
%21 = load i32, i32* %12
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %20
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 20)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%27 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32*, i32** %7
%29 = load i32*, i32** %8
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%31 = call i32 @magicconsume(i32* %28, i32* %29, i32 15, i8* %30)
store i32 %31, i32* %13
%32 = load i32, i32* %13
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %23
br label %72
35: ; preds = %23
br label %36
36: ; preds = %35, %20
store i32 0, i32* %13
br label %37
37: ; preds = %69, %36
%38 = load i32, i32* %13
%39 = load i32, i32* %10
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %72
41: ; preds = %37
store i32 -1, i32* %15
br label %42
42: ; preds = %54, %41
%43 = load i32, i32* %10
%44 = load i32, i32* %13
%45 = sub nsw i32 %43, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = call i32 @getint(i32* %15)
br label %48
48: ; preds = %42
%49 = load i32, i32* %15
%50 = icmp slt i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %15
%53 = icmp sgt i32 %52, 11
br label %54
54: ; preds = %51, %48
%55 = phi i1 [ true, %48 ], [ %53, %51 ]
br i1 %55, label %42, label %56
56: ; preds = %54
%57 = load i32*, i32** %9
%58 = load i32, i32* %15
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = load i32, i32* %60
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %56
%64 = load i32*, i32** %9
%65 = load i32, i32* %15
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
store i32 0, i32* %67
br label %68
68: ; preds = %63, %56
br label %69
69: ; preds = %68
%70 = load i32, i32* %13
%71 = add nsw i32 %70, 1
store i32 %71, i32* %13
br label %37
72: ; preds = %18, %34, %37
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"StoneStatue\00"
@.str.2 = [100 x i8] c"You can turn an enemy in a stone statue. You can do this %d times. What enemy do you want to kill?\0A\00"
@str = [6 x i8] c"Nope.\00"
define void @stonestatue(i32* %0, i32* %1, i32* nocapture %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca [20 x i8]
%8 = alloca i32
%9 = icmp eq i32 %4, 1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %40
12: ; preds = %6
%13 = icmp eq i32 %5, 0
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 20)
%17 = call i32 @magicconsume(i32* %0, i32* %1, i32 15, i8* %15)
%18 = icmp slt i32 %17, 0
br i1 %18, label %40, label %19
19: ; preds = %14, %12
%20 = bitcast i32* %8 to i8*
%21 = icmp sgt i32 %3, 0
br i1 %21, label %22, label %39
22: ; preds = %19, %36
%23 = phi i32 [ %37, %36 ], [ 0, %19 ]
store i32 -1, i32* %8
%24 = sub nsw i32 %3, %23
br label %25
25: ; preds = %25, %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%27 = call i32 @getint(i32* %8)
%28 = load i32, i32* %8
%29 = icmp ugt i32 %28, 11
br i1 %29, label %25, label %30
30: ; preds = %25
%31 = zext i32 %28 to i64
%32 = getelementptr inbounds i32, i32* %2, i64 %31
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %32
br label %36
36: ; preds = %30, %35
%37 = add nuw nsw i32 %23, 1
%38 = icmp eq i32 %37, %3
br i1 %38, label %39, label %22
39: ; preds = %36, %19
br label %40
40: ; preds = %39, %14, %10
ret void
}