#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(" 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    1200 <showcard+0xf0>
lea    0xeb6(%rip),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <showcard+0xf0>
lea    0xe9c(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <showcard+0xf0>
lea    0xe82(%rip),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <showcard+0xf0>
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
cltq
mov    -0x30(%rbp,%rax,8),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showcard>:
push   %rbx
movslq %edi,%rsi
imul   $0x4ec4ec4f,%rsi,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,2),%eax
lea    (%rbx,%rax,4),%eax
sub    %eax,%esi
cmp    $0xc,%esi
ja     1155 <showcard+0x45>
lea    0xec4(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf15(%rip),%rdi
lea    0xf12(%rip),%rsi
jmp    1196 <showcard+0x86>
add    $0x1,%esi
lea    0xf0e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    119d <showcard+0x8d>
lea    0xef2(%rip),%rdi
lea    0xef1(%rip),%rsi
jmp    1196 <showcard+0x86>
lea    0xee2(%rip),%rdi
lea    0xee3(%rip),%rsi
jmp    1196 <showcard+0x86>
lea    0xed2(%rip),%rdi
lea    0xed5(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movslq %ebx,%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
pop    %rbx
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 %20
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 %20
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 %20
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 %20
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)
br label %20
20: ; preds = %15, %13, %11, %9, %7
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %25)
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 %15
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 %15
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 %15
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 %15
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)
br label %15
15: ; preds = %12, %10, %8, %6, %4
%16 = sext i32 %3 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.showcard to i8*), i64 %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %18)
ret void
}