#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 magicconsume(int *, int *, int, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ treasure(int *, int *, int *, int *, int *, int *, int *,
                            int *, int *, int *, int *, int *, int,
                            int /*<<< orphan*/, int);
void genieofluck(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 combat, int *nomag) {
  char s[20];
  memset(s, 0, sizeof(s));
  sprintf(s, "GenieofLuck");
  int v = magicconsume(aces, inv, 11, s);
  if (v < 0)
    return;
  printf("You evoke a djinn of Luck and he gives you five gift!\n");
  treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, 1, 0, combat);
  treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, 1, 0, combat);
  treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, 1, 0, combat);
  treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, 1, 0, combat);
  treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos,
           antimag, 1, 0, combat);
  if (nomag)
    *nomag = 1;
}


x86 assembly (clang, -O0):
<genieofluck>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%eax
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    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x70(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x70(%rbp),%rcx
mov    $0xb,%edx
call   1050 <magicconsume@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    11e3 <genieofluck+0x93>
jmp    1420 <genieofluck+0x2d0>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
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),%r12
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%eax
xor    %r13d,%r13d
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1030 <treasure@plt>
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),%r12
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%eax
xor    %r13d,%r13d
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1030 <treasure@plt>
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),%r12
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%eax
xor    %r13d,%r13d
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1030 <treasure@plt>
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),%r12
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%eax
xor    %r13d,%r13d
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1030 <treasure@plt>
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),%r12
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%eax
xor    %r13d,%r13d
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x0,0x38(%rsp)
mov    %eax,0x40(%rsp)
call   1030 <treasure@plt>
cmpq   $0x0,0x48(%rbp)
je     1420 <genieofluck+0x2d0>
mov    0x48(%rbp),%rax
movl   $0x1,(%rax)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<genieofluck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
movabs $0x4c666f65696e6547,%rax
6f 66 4c
mov    %rax,0x10(%rsp)
movl   $0x6b6375,0x18(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xb,%edx
mov    %r14,%rcx
call   1050 <magicconsume@plt>
test   %eax,%eax
js     136b <genieofluck+0x22b>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    0x10(%rsp),%r14
mov    %r14,%r9
mov    0x98(%rsp),%eax
push   %rax
push   $0x0
push   $0x1
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
mov    0xa8(%rsp),%rax
push   %rax
mov    0xa8(%rsp),%rax
push   %rax
mov    0xa8(%rsp),%rax
push   %rax
call   1030 <treasure@plt>
add    $0x48,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
mov    0x98(%rsp),%eax
push   %rax
push   $0x0
push   $0x1
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
call   1030 <treasure@plt>
add    $0x48,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
mov    0x98(%rsp),%eax
push   %rax
push   $0x0
push   $0x1
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
call   1030 <treasure@plt>
add    $0x48,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
mov    0x98(%rsp),%eax
push   %rax
push   $0x0
push   $0x1
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
call   1030 <treasure@plt>
add    $0x48,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
mov    0x98(%rsp),%eax
push   %rax
push   $0x0
push   $0x1
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
push   0xa8(%rsp)
call   1030 <treasure@plt>
mov    0xe8(%rsp),%rax
add    $0x50,%rsp
test   %rax,%rax
je     136b <genieofluck+0x22b>
movl   $0x1,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"GenieofLuck\00"
@.str.1 = [55 x i8] c"You evoke a djinn of Luck and he gives you five gift!\0A\00"
define void @genieofluck(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) {
%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 i32
%28 = alloca i32*
%29 = alloca [20 x i8]
%30 = alloca i32
store i32* %0, i32** %15
store i32* %1, i32** %16
store i32* %2, i32** %17
store i32* %3, i32** %18
store i32* %4, i32** %19
store i32* %5, i32** %20
store i32* %6, i32** %21
store i32* %7, i32** %22
store i32* %8, i32** %23
store i32* %9, i32** %24
store i32* %10, i32** %25
store i32* %11, i32** %26
store i32 %12, i32* %27
store i32* %13, i32** %28
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %29, i64 0, i64 0
%32 = call i32 @memset(i8* %31, i32 0, i32 20)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %29, i64 0, i64 0
%34 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%35 = load i32*, i32** %17
%36 = load i32*, i32** %18
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %29, i64 0, i64 0
%38 = call i32 @magicconsume(i32* %35, i32* %36, i32 11, i8* %37)
store i32 %38, i32* %30
%39 = load i32, i32* %30
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %14
br label %118
42: ; preds = %14
%43 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32*, i32** %15
%45 = load i32*, i32** %16
%46 = load i32*, i32** %17
%47 = load i32*, i32** %18
%48 = load i32*, i32** %19
%49 = load i32*, i32** %20
%50 = load i32*, i32** %21
%51 = load i32*, i32** %22
%52 = load i32*, i32** %23
%53 = load i32*, i32** %24
%54 = load i32*, i32** %25
%55 = load i32*, i32** %26
%56 = load i32, i32* %27
%57 = call i32 @treasure(i32* %44, i32* %45, i32* %46, i32* %47, i32* %48, i32* %49, i32* %50, i32* %51, i32* %52, i32* %53, i32* %54, i32* %55, i32 1, i32 0, i32 %56)
%58 = load i32*, i32** %15
%59 = load i32*, i32** %16
%60 = load i32*, i32** %17
%61 = load i32*, i32** %18
%62 = load i32*, i32** %19
%63 = load i32*, i32** %20
%64 = load i32*, i32** %21
%65 = load i32*, i32** %22
%66 = load i32*, i32** %23
%67 = load i32*, i32** %24
%68 = load i32*, i32** %25
%69 = load i32*, i32** %26
%70 = load i32, i32* %27
%71 = call i32 @treasure(i32* %58, i32* %59, i32* %60, i32* %61, i32* %62, i32* %63, i32* %64, i32* %65, i32* %66, i32* %67, i32* %68, i32* %69, i32 1, i32 0, i32 %70)
%72 = load i32*, i32** %15
%73 = load i32*, i32** %16
%74 = load i32*, i32** %17
%75 = load i32*, i32** %18
%76 = load i32*, i32** %19
%77 = load i32*, i32** %20
%78 = load i32*, i32** %21
%79 = load i32*, i32** %22
%80 = load i32*, i32** %23
%81 = load i32*, i32** %24
%82 = load i32*, i32** %25
%83 = load i32*, i32** %26
%84 = load i32, i32* %27
%85 = call i32 @treasure(i32* %72, i32* %73, i32* %74, i32* %75, i32* %76, i32* %77, i32* %78, i32* %79, i32* %80, i32* %81, i32* %82, i32* %83, i32 1, i32 0, i32 %84)
%86 = load i32*, i32** %15
%87 = load i32*, i32** %16
%88 = load i32*, i32** %17
%89 = load i32*, i32** %18
%90 = load i32*, i32** %19
%91 = load i32*, i32** %20
%92 = load i32*, i32** %21
%93 = load i32*, i32** %22
%94 = load i32*, i32** %23
%95 = load i32*, i32** %24
%96 = load i32*, i32** %25
%97 = load i32*, i32** %26
%98 = load i32, i32* %27
%99 = call i32 @treasure(i32* %86, i32* %87, i32* %88, i32* %89, i32* %90, i32* %91, i32* %92, i32* %93, i32* %94, i32* %95, i32* %96, i32* %97, i32 1, i32 0, i32 %98)
%100 = load i32*, i32** %15
%101 = load i32*, i32** %16
%102 = load i32*, i32** %17
%103 = load i32*, i32** %18
%104 = load i32*, i32** %19
%105 = load i32*, i32** %20
%106 = load i32*, i32** %21
%107 = load i32*, i32** %22
%108 = load i32*, i32** %23
%109 = load i32*, i32** %24
%110 = load i32*, i32** %25
%111 = load i32*, i32** %26
%112 = load i32, i32* %27
%113 = call i32 @treasure(i32* %100, i32* %101, i32* %102, i32* %103, i32* %104, i32* %105, i32* %106, i32* %107, i32* %108, i32* %109, i32* %110, i32* %111, i32 1, i32 0, i32 %112)
%114 = load i32*, i32** %28
%115 = icmp ne i32* %114, null
br i1 %115, label %116, label %118
116: ; preds = %42
%117 = load i32*, i32** %28
store i32 1, i32* %117
br label %118
118: ; preds = %41, %116, %42
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"GenieofLuck\00"
@str = [54 x i8] c"You evoke a djinn of Luck and he gives you five gift!\00"
define void @genieofluck(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* writeonly %13) {
%15 = alloca [20 x i8]
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 20)
%18 = call i32 @magicconsume(i32* %2, i32* %3, i32 11, i8* %16)
%19 = icmp slt i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %14
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%22 = 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 1, i32 0, i32 %12)
%23 = 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 1, i32 0, i32 %12)
%24 = 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 1, i32 0, i32 %12)
%25 = 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 1, i32 0, i32 %12)
%26 = 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 1, i32 0, i32 %12)
%27 = icmp eq i32* %13, null
br i1 %27, label %29, label %28
28: ; preds = %20
store i32 1, i32* %13
br label %29
29: ; preds = %20, %28, %14
ret void
}