#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 min(int, int);
int /*<<< orphan*/ nameitem(char *, int);
int /*<<< orphan*/ printf(char *, ...);
void useitem(int *hpmax, int *hpnow, int *inv) {
  int k;
  printf("What item do you want to use?\n");
  getint(&k);
  if ((k < 0) || (k >= 10)) {
    printf("You don't have that slot! Insert a number between 0 and %d!\n",
           10 - 1);
    return;
  }
  if (*(inv + k) == 0) {
    printf("It's empty...\n");
    return;
  }
  if ((*(inv + k) > 9) || (*hpmax == *hpnow)) {
    printf("It isn't really useful now...\n");
    return;
  }
  *hpnow = min(*hpmax, *hpnow + 1 + *(inv + k));
  char s[20];
  nameitem(s, *(inv + k));
  printf("You use %s!\n", s);
  *(inv + k) = 0;
}


x86 assembly (clang, -O0):
<useitem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
call   1050 <getint@plt>
cmpl   $0x0,-0x1c(%rbp)
jl     117f <useitem+0x3f>
cmpl   $0xa,-0x1c(%rbp)
jl     1197 <useitem+0x57>
lea    0xe99(%rip),%rdi
mov    $0x9,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124f <useitem+0x10f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11bc <useitem+0x7c>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124f <useitem+0x10f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x9,(%rax,%rcx,4)
jg     11e0 <useitem+0xa0>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jne    11f3 <useitem+0xb3>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124f <useitem+0x10f>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    (%rax,%rcx,4),%esi
call   1040 <min@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <nameitem@plt>
lea    -0x30(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<useitem>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdi
call   1060 <getint@plt>
mov    0xc(%rsp),%eax
cmp    $0xa,%rax
jb     1197 <useitem+0x47>
lea    0xe77(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120b <useitem+0xbb>
mov    (%r15,%rax,4),%eax
test   %eax,%eax
je     11bb <useitem+0x6b>
cmp    $0x9,%eax
jg     11ad <useitem+0x5d>
mov    (%rbx),%edi
mov    (%r14),%ecx
cmp    %ecx,%edi
jne    11c9 <useitem+0x79>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
jmp    120b <useitem+0xbb>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
jmp    120b <useitem+0xbb>
lea    (%rax,%rcx,1),%esi
add    $0x1,%esi
call   1050 <min@plt>
mov    %eax,(%r14)
movslq 0xc(%rsp),%rax
mov    (%r15,%rax,4),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <nameitem@plt>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
movl   $0x0,(%r15,%rax,4)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"What item do you want to use?\0A\00"
@.str.1 = [61 x i8] c"You don't have that slot! Insert a number between 0 and %d!\0A\00"
@.str.2 = [15 x i8] c"It's empty...\0A\00"
@.str.3 = [31 x i8] c"It isn't really useful now...\0A\00"
@.str.4 = [13 x i8] c"You use %s!\0A\00"
define void @useitem(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [20 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @getint(i32* %7)
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %13, %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 9)
br label %69
18: ; preds = %13
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %69
27: ; preds = %18
%28 = load i32*, i32** %6
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = icmp sgt i32 %32, 9
br i1 %33, label %40, label %34
34: ; preds = %27
%35 = load i32*, i32** %4
%36 = load i32, i32* %35
%37 = load i32*, i32** %5
%38 = load i32, i32* %37
%39 = icmp eq i32 %36, %38
br i1 %39, label %40, label %42
40: ; preds = %34, %27
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %69
42: ; preds = %34
%43 = load i32*, i32** %4
%44 = load i32, i32* %43
%45 = load i32*, i32** %5
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
%48 = load i32*, i32** %6
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = add nsw i32 %47, %52
%54 = call i32 @min(i32 %44, i32 %53)
%55 = load i32*, i32** %5
store i32 %54, i32* %55
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%57 = load i32*, i32** %6
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = load i32, i32* %60
%62 = call i32 @nameitem(i8* %56, i32 %61)
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %63)
%65 = load i32*, i32** %6
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
store i32 0, i32* %68
br label %69
69: ; preds = %42, %40, %25, %16
ret void
}

LLVM IR (-O2):
@.str.1 = [61 x i8] c"You don't have that slot! Insert a number between 0 and %d!\0A\00"
@.str.4 = [13 x i8] c"You use %s!\0A\00"
@str = [30 x i8] c"What item do you want to use?\00"
@str.5 = [30 x i8] c"It isn't really useful now...\00"
@str.6 = [14 x i8] c"It's empty...\00"
define void @useitem(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca i32
%5 = alloca [20 x i8]
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%8 = call i32 @getint(i32* %4)
%9 = load i32, i32* %4
%10 = icmp ugt i32 %9, 9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 9)
br label %42
13: ; preds = %3
%14 = zext i32 %9 to i64
%15 = getelementptr inbounds i32, i32* %2, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
br label %42
20: ; preds = %13
%21 = icmp sgt i32 %16, 9
br i1 %21, label %26, label %22
22: ; preds = %20
%23 = load i32, i32* %0
%24 = load i32, i32* %1
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22, %20
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
br label %42
28: ; preds = %22
%29 = add nsw i32 %16, 1
%30 = add i32 %29, %24
%31 = call i32 @min(i32 %23, i32 %30)
store i32 %31, i32* %1
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %2, i64 %34
%36 = load i32, i32* %35
%37 = call i32 @nameitem(i8* %32, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %2, i64 %40
store i32 0, i32* %41
br label %42
42: ; preds = %28, %26, %18, %11
ret void
}