#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 */
scalar_t__ cardValue(char);
int /*<<< orphan*/ isCard(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char cards[14];
  char hold;
  int i, j;
  for (i = 0; i < 13; i++) {
    scanf("%12s", &cards[i]);
    while (!isCard(cards[i])) {
      printf("%c is not valid card - try again \n", cards[i]);
      scanf("%12s", &cards[i]);
    }
  }
  for (i = 0; i < strlen(cards); i++) {
    for (j = i + 1; j < strlen(cards); j++) {
      if (cardValue(cards[i]) > cardValue(cards[j])) {
        hold = cards[i];
        cards[i] = cards[j];
        cards[j] = hold;
      }
    }
  }
  for (i = 0; i < 13; i++) {
    printf("%c ", cards[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xd,-0x18(%rbp)
jge    11f0 <main+0xa0>
movslq -0x18(%rbp),%rax
lea    -0x12(%rbp),%rsi
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
call   1070 <scanf@plt>
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1060 <isCard@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11aa <main+0x5a>
jmp    11dd <main+0x8d>
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x18(%rbp),%rax
lea    -0x12(%rbp),%rsi
add    %rax,%rsi
lea    0xe2d(%rip),%rdi
call   1070 <scanf@plt>
jmp    1187 <main+0x37>
jmp    11e2 <main+0x92>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1166 <main+0x16>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    12b4 <main+0x164>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x12(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    12a1 <main+0x151>
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1030 <cardValue@plt>
mov    %rax,-0x30(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1030 <cardValue@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jle    128e <main+0x13e>
movslq -0x18(%rbp),%rax
mov    -0x12(%rbp,%rax,1),%al
mov    %al,-0x13(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x12(%rbp,%rax,1),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x13(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
jmp    1293 <main+0x143>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121c <main+0xcc>
jmp    12a6 <main+0x156>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f7 <main+0xa7>
movl   $0x0,-0x18(%rbp)
cmpl   $0xd,-0x18(%rbp)
jge    12ea <main+0x19a>
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%esi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12bb <main+0x16b>
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%r15
lea    0xe89(%rip),%r14
xor    %r12d,%r12d
jmp    119a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    $0xd,%r12
je     11e6 <main+0x86>
lea    (%rsp,%r12,1),%rbx
add    $0xa,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movsbl 0xa(%rsp,%r12,1),%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1070 <isCard@plt>
test   %eax,%eax
jne    1190 <main+0x30>
movsbl (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movsbl (%rbx),%edi
jmp    11c0 <main+0x60>
lea    0xa(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1283 <main+0x123>
mov    $0x1,%r15d
xor    %r12d,%r12d
lea    0xa(%rsp),%r14
jmp    1223 <main+0xc3>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
add    $0x1,%r15
cmp    %rax,%r12
jge    1283 <main+0x123>
mov    %r12,%r13
add    $0x1,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%r12
jge    1210 <main+0xb0>
mov    %r15,%rbp
jmp    1250 <main+0xf0>
xchg   %ax,%ax
add    $0x1,%rbp
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    %ebp,%eax
jle    1210 <main+0xb0>
movsbl 0xa(%rsp,%r13,1),%edi
call   1040 <cardValue@plt>
mov    %rax,%rbx
movsbl 0xa(%rsp,%rbp,1),%edi
call   1040 <cardValue@plt>
cmp    %rax,%rbx
jle    1240 <main+0xe0>
movzbl 0xa(%rsp,%r13,1),%eax
movzbl 0xa(%rsp,%rbp,1),%ecx
mov    %cl,0xa(%rsp,%r13,1)
mov    %al,0xa(%rsp,%rbp,1)
jmp    1240 <main+0xe0>
movsbl 0xa(%rsp),%esi
lea    0xd99(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xb(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xd(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xf(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x11(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x12(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x13(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x15(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x16(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%12s\00"
@.str.1 = [35 x i8] c"%c is not valid card - try again \0A\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [14 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %34, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 13
br i1 %8, label %9, label %37
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %22, %9
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @isCard(i8 signext %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %33
22: ; preds = %14
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %14
33: ; preds = %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %6
37: ; preds = %6
store i32 0, i32* %4
br label %38
38: ; preds = %84, %37
%39 = load i32, i32* %4
%40 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %87
43: ; preds = %38
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %46
46: ; preds = %80, %43
%47 = load i32, i32* %5
%48 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %83
51: ; preds = %46
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = call i64 @cardValue(i8 signext %55)
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = call i64 @cardValue(i8 signext %60)
%62 = icmp sgt i64 %56, %61
br i1 %62, label %63, label %79
63: ; preds = %51
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %65
%67 = load i8, i8* %66
store i8 %67, i8* %3
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %73
store i8 %71, i8* %74
%75 = load i8, i8* %3
%76 = load i32, i32* %5
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %77
store i8 %75, i8* %78
br label %79
79: ; preds = %63, %51
br label %80
80: ; preds = %79
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %46
83: ; preds = %46
br label %84
84: ; preds = %83
%85 = load i32, i32* %4
%86 = add nsw i32 %85, 1
store i32 %86, i32* %4
br label %38
87: ; preds = %38
store i32 0, i32* %4
br label %88
88: ; preds = %98, %87
%89 = load i32, i32* %4
%90 = icmp slt i32 %89, 13
br i1 %90, label %91, label %101
91: ; preds = %88
%92 = load i32, i32* %4
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %91
%99 = load i32, i32* %4
%100 = add nsw i32 %99, 1
store i32 %100, i32* %4
br label %88
101: ; preds = %88
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%12s\00"
@.str.1 = [35 x i8] c"%c is not valid card - try again \0A\00"
@.str.2 = [4 x i8] c"%c \00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
br label %6
3: ; preds = %21
%4 = call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %82, label %29
6: ; preds = %0, %21
%7 = phi i64 [ 0, %0 ], [ %22, %21 ]
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %7
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8, i8* %8
%11 = call i32 @isCard(i8 signext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %6, %13
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%18 = load i8, i8* %8
%19 = call i32 @isCard(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %13, label %21
21: ; preds = %13, %6
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, 13
br i1 %23, label %3, label %6
24: ; preds = %102, %82
%25 = call i32 @strlen(i8* %2)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %85, %26
%28 = add nuw nsw i64 %84, 1
br i1 %27, label %82, label %29
29: ; preds = %24, %3
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 4
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 5
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 6
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 7
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 8
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 9
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %67)
%69 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 10
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 11
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 12
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %79)
%81 = call i32 @putchar(i32 10)
ret i32 0
82: ; preds = %3, %24
%83 = phi i64 [ %85, %24 ], [ 0, %3 ]
%84 = phi i64 [ %28, %24 ], [ 1, %3 ]
%85 = add nuw nsw i64 %83, 1
%86 = call i32 @strlen(i8* %2)
%87 = sext i32 %86 to i64
%88 = icmp slt i64 %85, %87
br i1 %88, label %89, label %24
89: ; preds = %82
%90 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %83
br label %91
91: ; preds = %89, %102
%92 = phi i64 [ %84, %89 ], [ %103, %102 ]
%93 = load i8, i8* %90
%94 = call i64 @cardValue(i8 signext %93)
%95 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %92
%96 = load i8, i8* %95
%97 = call i64 @cardValue(i8 signext %96)
%98 = icmp sgt i64 %94, %97
br i1 %98, label %99, label %102
99: ; preds = %91
%100 = load i8, i8* %90
%101 = load i8, i8* %95
store i8 %101, i8* %90
store i8 %100, i8* %95
br label %102
102: ; preds = %91, %99
%103 = add nuw nsw i64 %92, 1
%104 = call i32 @strlen(i8* %2)
%105 = trunc i64 %103 to i32
%106 = icmp sgt i32 %104, %105
br i1 %106, label %91, label %24
}