#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*/ printf(char *, ...);
void showcard(int card) {
  char *suit[4] = {"Spades", "Hearts", "Clubs", "Diamonds"};
  switch (card % 13) {
  case 0:
    printf("%2s", "A");
    break;
  case 10:
    printf("%2s", "J");
    break;
  case 11:
    printf("%2s", "Q");
    break;
  case 12:
    printf("%2s", "K");
    break;
  default:
    printf("%2d", card % 13 + 1);
    printf("%2d", card % 13 + 1);
  }
  printf(" of %s\n", suit[card / 13]);
}


x86 assembly (clang, -O0):
<showcard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movaps 0x2cee(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0x2cd3(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movslq -0x4(%rbp),%rcx
mov    %ecx,%eax
imul   $0x4ec4ec4f,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%esi
mov    %esi,%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0xc,%eax
ja     11e2 <showcard+0xd2>
mov    -0x38(%rbp),%rax
lea    0xe8f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed0(%rip),%rdi
lea    0xecd(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <showcard+0x10e>
lea    0xeb6(%rip),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <showcard+0x10e>
lea    0xe9c(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <showcard+0x10e>
lea    0xe82(%rip),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <showcard+0x10e>
mov    -0x4(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xd,%ecx
cltd
idiv   %ecx
cltq
mov    -0x30(%rbp,%rax,8),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showcard>:
push   %r15
push   %r14
push   %rbx
movslq %edi,%rbx
imul   $0x4ec4ec4f,%rbx,%r15
mov    %r15,%rax
shr    $0x3f,%rax
sar    $0x22,%r15
add    %eax,%r15d
lea    (%r15,%r15,2),%eax
lea    (%r15,%rax,4),%eax
sub    %eax,%ebx
cmp    $0xc,%ebx
ja     115c <showcard+0x4c>
lea    0xebd(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf0e(%rip),%rdi
lea    0xf0b(%rip),%rsi
jmp    11ae <showcard+0x9e>
add    $0x1,%ebx
lea    0xf07(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b5 <showcard+0xa5>
lea    0xeda(%rip),%rdi
lea    0xed9(%rip),%rsi
jmp    11ae <showcard+0x9e>
lea    0xeca(%rip),%rdi
lea    0xecb(%rip),%rsi
jmp    11ae <showcard+0x9e>
lea    0xeba(%rip),%rdi
lea    0xebd(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq %r15d,%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0xea4(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Spades\00"
@.str.1 = [7 x i8] c"Hearts\00"
@.str.2 = [6 x i8] c"Clubs\00"
@.str.3 = [9 x i8] c"Diamonds\00"
@__const.showcard.suit = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [4 x i8] c"%2s\00"
@.str.5 = [2 x i8] c"A\00"
@.str.6 = [2 x i8] c"J\00"
@.str.7 = [2 x i8] c"Q\00"
@.str.8 = [2 x i8] c"K\00"
@.str.9 = [4 x i8] c"%2d\00"
@.str.10 = [8 x i8] c" of %s\0A\00"
define void @showcard(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8*]
store i32 %0, i32* %2
%4 = bitcast [4 x i8*]* %3 to i8*
%5 = load i32, i32* %2
%6 = srem i32 %5, 13
switch i32 %6, label %15 [
i32 0, label %7
i32 10, label %9
i32 11, label %11
i32 12, label %13
]
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %24
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %24
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %24
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %24
15: ; preds = %1
%16 = load i32, i32* %2
%17 = srem i32 %16, 13
%18 = add nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = srem i32 %20, 13
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %15, %13, %11, %9, %7
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 13
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Spades\00"
@.str.1 = [7 x i8] c"Hearts\00"
@.str.2 = [6 x i8] c"Clubs\00"
@.str.3 = [9 x i8] c"Diamonds\00"
@reltable.showcard = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.showcard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.showcard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.showcard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.showcard to i64)) to i32)]
@.str.4 = [4 x i8] c"%2s\00"
@.str.5 = [2 x i8] c"A\00"
@.str.6 = [2 x i8] c"J\00"
@.str.7 = [2 x i8] c"Q\00"
@.str.8 = [2 x i8] c"K\00"
@.str.9 = [4 x i8] c"%2d\00"
@.str.10 = [8 x i8] c" of %s\0A\00"
define void @showcard(i32 %0) {
%2 = srem i32 %0, 13
%3 = sdiv i32 %0, 13
switch i32 %2, label %12 [
i32 0, label %4
i32 10, label %6
i32 11, label %8
i32 12, label %10
]
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %16
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %16
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %16
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %16
12: ; preds = %1
%13 = add nsw i32 %2, 1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %13)
br label %16
16: ; preds = %12, %10, %8, %6, %4
%17 = sext i32 %3 to i64
%18 = shl i64 %17, 2
%19 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.showcard to i8*), i64 %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %19)
ret void
}