#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 min(int, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ sprintf(char *, char *);
void futureperception(int *aces, int *inv, int *future, int *nomag) {
  char s[20];
  memset(s, 0, sizeof(s));
  sprintf(s, "FuturePerception");
  int v = magicconsume(aces, inv, 1, s);
  if (v < 0)
    return;
  int i;
  v = min(v, 10);
  printf("Your future is: ");
  for (i = 0; i < v; i++) {
    if (*(future + i) < 0)
      *(future + i) = rand() % 54;
    if (*(future + i) > 51)
      printf("H");
    else if (*(future + i) % 13 == 12)
      printf("K");
    else if (*(future + i) % 13 == 11)
      printf("Q");
    else if (*(future + i) % 13 == 10)
      printf("J");
    else
      printf("%d", *(future + i) % 13 + 1);
    if (i + 1 == v)
      printf(".\n");
    else
      printf(", ");
  }
  if (nomag)
    *nomag = 1;
}


x86 assembly (clang, -O0):
<futureperception>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x40(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rcx
mov    $0x1,%edx
call   1040 <magicconsume@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    11c0 <futureperception+0x60>
jmp    135c <futureperception+0x1fc>
mov    -0x44(%rbp),%edi
mov    $0xa,%esi
call   1050 <min@plt>
mov    %eax,-0x44(%rbp)
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1347 <futureperception+0x1e7>
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    121d <futureperception+0xbd>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x36,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
cmpl   $0x33,(%rax,%rcx,4)
jle    1242 <futureperception+0xe2>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1304 <futureperception+0x1a4>
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xc,%edx
jne    1271 <futureperception+0x111>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ff <futureperception+0x19f>
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xb,%edx
jne    12a0 <futureperception+0x140>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fa <futureperception+0x19a>
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jne    12cf <futureperception+0x16f>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f5 <futureperception+0x195>
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fa <futureperception+0x19a>
jmp    12ff <futureperception+0x19f>
jmp    1304 <futureperception+0x1a4>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
cmp    -0x44(%rbp),%eax
jne    1326 <futureperception+0x1c6>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <futureperception+0x1d4>
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1339 <futureperception+0x1d9>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11e5 <futureperception+0x85>
cmpq   $0x0,-0x20(%rbp)
je     135c <futureperception+0x1fc>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<futureperception>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x10(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1080 <memset@plt>
movups 0xe5b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1060 <magicconsume@plt>
test   %eax,%eax
js     131e <futureperception+0x1ae>
mov    %r14,0x8(%rsp)
mov    %eax,%edi
mov    $0xa,%esi
call   1070 <min@plt>
mov    %eax,%ebp
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    130e <futureperception+0x19e>
mov    %ebp,%ebp
lea    -0x1(%rbp),%r13
lea    0xe25(%rip),%r12
xor    %r15d,%r15d
jmp    1226 <futureperception+0xb6>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%r15
cmp    %r14,%rbp
je     130e <futureperception+0x19e>
mov    (%rbx,%r15,4),%eax
test   %eax,%eax
js     1250 <futureperception+0xe0>
cmp    $0x34,%eax
jl     127b <futureperception+0x10b>
mov    $0x48,%edi
call   1030 <putchar@plt>
jmp    12f0 <futureperception+0x180>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x4bda12f7,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x36,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rbx,%r15,4)
cmp    $0x34,%eax
jge    1233 <futureperception+0xc3>
movsbl %al,%ecx
imul   $0x4f,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0xa,%edx
add    %cl,%dl
movzbl %dl,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %cl,%al
movsbl %al,%esi
cmp    $0xa,%esi
je     12c4 <futureperception+0x154>
cmp    $0xb,%esi
je     12b8 <futureperception+0x148>
cmp    $0xc,%esi
jne    12d0 <futureperception+0x160>
mov    $0x4b,%edi
call   1030 <putchar@plt>
jmp    12f0 <futureperception+0x180>
mov    $0x51,%edi
call   1030 <putchar@plt>
jmp    12f0 <futureperception+0x180>
mov    $0x4a,%edi
call   1030 <putchar@plt>
jmp    12f0 <futureperception+0x180>
add    $0x1,%esi
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%r15),%r14
cmp    %r15,%r13
jne    1210 <futureperception+0xa0>
lea    0xd24(%rip),%rdi
call   1040 <puts@plt>
jmp    121a <futureperception+0xaa>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     131e <futureperception+0x1ae>
movl   $0x1,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"FuturePerception\00"
@.str.1 = [17 x i8] c"Your future is: \00"
@.str.2 = [2 x i8] c"H\00"
@.str.3 = [2 x i8] c"K\00"
@.str.4 = [2 x i8] c"Q\00"
@.str.5 = [2 x i8] c"J\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [3 x i8] c".\0A\00"
@.str.8 = [3 x i8] c", \00"
define void @futureperception(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [20 x i8]
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 20)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = load i32*, i32** %5
%17 = load i32*, i32** %6
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%19 = call i32 @magicconsume(i32* %16, i32* %17, i32 1, i8* %18)
store i32 %19, i32* %10
%20 = load i32, i32* %10
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %4
br label %114
23: ; preds = %4
%24 = load i32, i32* %10
%25 = call i32 @min(i32 %24, i32 10)
store i32 %25, i32* %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %11
br label %27
27: ; preds = %106, %23
%28 = load i32, i32* %11
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %109
31: ; preds = %27
%32 = load i32*, i32** %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %31
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 54
%41 = load i32*, i32** %7
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %38, %31
%46 = load i32*, i32** %7
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = icmp sgt i32 %50, 51
br i1 %51, label %52, label %54
52: ; preds = %45
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %96
54: ; preds = %45
%55 = load i32*, i32** %7
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %58
%60 = srem i32 %59, 13
%61 = icmp eq i32 %60, 12
br i1 %61, label %62, label %64
62: ; preds = %54
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %95
64: ; preds = %54
%65 = load i32*, i32** %7
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = srem i32 %69, 13
%71 = icmp eq i32 %70, 11
br i1 %71, label %72, label %74
72: ; preds = %64
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %94
74: ; preds = %64
%75 = load i32*, i32** %7
%76 = load i32, i32* %11
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %75, i64 %77
%79 = load i32, i32* %78
%80 = srem i32 %79, 13
%81 = icmp eq i32 %80, 10
br i1 %81, label %82, label %84
82: ; preds = %74
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %93
84: ; preds = %74
%85 = load i32*, i32** %7
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = srem i32 %89, 13
%91 = add nsw i32 %90, 1
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %84, %82
br label %94
94: ; preds = %93, %72
br label %95
95: ; preds = %94, %62
br label %96
96: ; preds = %95, %52
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 1
%99 = load i32, i32* %10
%100 = icmp eq i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %96
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %105
103: ; preds = %96
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %105
105: ; preds = %103, %101
br label %106
106: ; preds = %105
%107 = load i32, i32* %11
%108 = add nsw i32 %107, 1
store i32 %108, i32* %11
br label %27
109: ; preds = %27
%110 = load i32*, i32** %8
%111 = icmp ne i32* %110, null
br i1 %111, label %112, label %114
112: ; preds = %109
%113 = load i32*, i32** %8
store i32 1, i32* %113
br label %114
114: ; preds = %22, %112, %109
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"FuturePerception\00"
@.str.1 = [17 x i8] c"Your future is: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.8 = [3 x i8] c", \00"
@str = [2 x i8] c".\00"
define void @futureperception(i32* %0, i32* %1, i32* nocapture %2, i32* writeonly %3) {
%5 = alloca [20 x i8]
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 20)
%8 = call i32 @magicconsume(i32* %0, i32* %1, i32 1, i8* %6)
%9 = icmp slt i32 %8, 0
br i1 %9, label %54, label %10
10: ; preds = %4
%11 = call i32 @min(i32 %8, i32 10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %51
14: ; preds = %10
%15 = zext i32 %11 to i64
br label %16
16: ; preds = %14, %49
%17 = phi i64 [ 0, %14 ], [ %43, %49 ]
%18 = getelementptr inbounds i32, i32* %2, i64 %17
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 54
store i32 %23, i32* %18
br label %24
24: ; preds = %21, %16
%25 = phi i32 [ %23, %21 ], [ %19, %16 ]
%26 = icmp sgt i32 %25, 51
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @putchar(i32 72)
br label %42
29: ; preds = %24
%30 = trunc i32 %25 to i8
%31 = srem i8 %30, 13
%32 = sext i8 %31 to i32
switch i32 %32, label %39 [
i32 12, label %33
i32 11, label %35
i32 10, label %37
]
33: ; preds = %29
%34 = call i32 @putchar(i32 75)
br label %42
35: ; preds = %29
%36 = call i32 @putchar(i32 81)
br label %42
37: ; preds = %29
%38 = call i32 @putchar(i32 74)
br label %42
39: ; preds = %29
%40 = add nsw i32 %32, 1
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %33, %37, %39, %35, %27
%43 = add nuw nsw i64 %17, 1
%44 = icmp eq i64 %43, %15
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %49
49: ; preds = %45, %47
%50 = icmp eq i64 %43, %15
br i1 %50, label %51, label %16
51: ; preds = %49, %10
%52 = icmp eq i32* %3, null
br i1 %52, label %54, label %53
53: ; preds = %51
store i32 1, i32* %3
br label %54
54: ; preds = %51, %53, %4
ret void
}