#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__ Findvalue(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int n, x, y, z, i, t;
  char a[13], b[13] = "23456789TJQKA", temp;
  printf("Enter cards:");
  scanf("%s", a);
  for (i = 0; i < strlen(b) - 1; i++) {
    t = 0;
    for (z = 0; z < strlen(b) - 1; z++) {
      if (a[i] == b[z]) {
        t = 1;
      }
    }
    if (t == 0) {
      printf("Invalid deck.");
      return 0;
    }
  }
  for (x = 0; x < strlen(a); x++) {
    for (y = 0; y < strlen(a) - 1; y++) {
      if (Findvalue(a[y]) > Findvalue(a[y + 1])) {
        int temp = a[y + 1];
        a[y + 1] = a[y];
        a[y] = temp;
      }
    }
  }
  printf("\n%s", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x36(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x2e(%rbp)
mov    0xea3(%rip),%al
mov    %al,-0x2a(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x29(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x36(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1248 <main+0x108>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x36(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1211 <main+0xd1>
movslq -0x18(%rbp),%rax
movsbl -0x29(%rbp,%rax,1),%eax
movslq -0x14(%rbp),%rcx
movsbl -0x36(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11fe <main+0xbe>
movl   $0x1,-0x1c(%rbp)
jmp    1203 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11be <main+0x7e>
cmpl   $0x0,-0x1c(%rbp)
jne    1235 <main+0xf5>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1335 <main+0x1f5>
jmp    123a <main+0xfa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1191 <main+0x51>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x48(%rbp)
lea    -0x29(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jge    131c <main+0x1dc>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x29(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1309 <main+0x1c9>
movslq -0x10(%rbp),%rax
movsbl -0x29(%rbp,%rax,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x29(%rbp,%rax,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jle    12f6 <main+0x1b6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x29(%rbp,%rax,1),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x10(%rbp),%rax
mov    -0x29(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x29(%rbp,%rax,1)
mov    -0x3c(%rbp),%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x29(%rbp,%rax,1)
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1272 <main+0x132>
jmp    130e <main+0x1ce>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    124f <main+0x10f>
lea    -0x29(%rbp),%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movabs $0x414b514a54393837,%rax
51 4b 41
mov    %rax,0x15(%rsp)
movabs $0x3938373635343332,%rax
37 38 39
mov    %rax,0x10(%rsp)
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1060 <scanf@plt>
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1212 <main+0xd2>
xor    %r12d,%r12d
lea    0x10(%rsp),%r14
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     12b2 <main+0x172>
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x3(%rsp,%r12,1),%eax
cmp    0x10(%rsp,%rbp,1),%al
cmove  %r15d,%ebx
add    $0x1,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbp
jl     11d0 <main+0x90>
test   %ebx,%ebx
je     12b2 <main+0x172>
add    $0x1,%r12
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%r12
jl     11b0 <main+0x70>
lea    0x3(%rsp),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    129d <main+0x15d>
xor    %r15d,%r15d
lea    0x3(%rsp),%r14
jmp    1241 <main+0x101>
xchg   %ax,%ax
add    $0x1,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jge    129d <main+0x15d>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1230 <main+0xf0>
xor    %ebp,%ebp
jmp    1275 <main+0x135>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
mov    %rbx,%rbp
cmp    %rax,%rbx
jge    1230 <main+0xf0>
movsbl 0x3(%rsp,%rbp,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,%r12
lea    0x1(%rbp),%rbx
movsbl 0x4(%rsp,%rbp,1),%edi
call   1030 <Findvalue@plt>
cmp    %rax,%r12
jle    1260 <main+0x120>
rolw   $0x8,0x3(%rsp,%rbp,1)
jmp    1260 <main+0x120>
lea    0xd84(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12c0 <main+0x180>
lea    0xd61(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.b = [13 x i8] c"23456789TJQKA"
@.str = [13 x i8] c"Enter cards:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [14 x i8] c"Invalid deck.\00"
@.str.3 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @strlen(i8* %4)
%8 = icmp sgt i32 %7, 1
br i1 %8, label %14, label %20
9: ; preds = %36
%10 = call i32 @strlen(i8* %4)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %38, %12
br i1 %13, label %14, label %20
14: ; preds = %0, %9
%15 = phi i64 [ %38, %9 ], [ 0, %0 ]
%16 = call i32 @strlen(i8* %4)
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %15
br label %23
20: ; preds = %9, %0
%21 = call i32 @strlen(i8* %3)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %41, label %67
23: ; preds = %18, %23
%24 = phi i64 [ 0, %18 ], [ %31, %23 ]
%25 = phi i32 [ 0, %18 ], [ %30, %23 ]
%26 = load i8, i8* %19
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 %24
%28 = load i8, i8* %27
%29 = icmp eq i8 %26, %28
%30 = select i1 %29, i32 1, i32 %25
%31 = add nuw nsw i64 %24, 1
%32 = call i32 @strlen(i8* %4)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %31, %34
br i1 %35, label %23, label %36
36: ; preds = %23
%37 = icmp eq i32 %30, 0
%38 = add nuw nsw i64 %15, 1
br i1 %37, label %39, label %9
39: ; preds = %14, %36
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %69
41: ; preds = %20, %63
%42 = phi i32 [ %64, %63 ], [ 0, %20 ]
%43 = call i32 @strlen(i8* %3)
%44 = icmp sgt i32 %43, 1
br i1 %44, label %45, label %63
45: ; preds = %41, %58
%46 = phi i64 [ %50, %58 ], [ 0, %41 ]
%47 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call i64 @Findvalue(i8 signext %48)
%50 = add nuw nsw i64 %46, 1
%51 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = call i64 @Findvalue(i8 signext %52)
%54 = icmp sgt i64 %49, %53
br i1 %54, label %55, label %58
55: ; preds = %45
%56 = load i8, i8* %51
%57 = load i8, i8* %47
store i8 %57, i8* %51
store i8 %56, i8* %47
br label %58
58: ; preds = %45, %55
%59 = call i32 @strlen(i8* %3)
%60 = add nsw i32 %59, -1
%61 = sext i32 %60 to i64
%62 = icmp slt i64 %50, %61
br i1 %62, label %45, label %63
63: ; preds = %58, %41
%64 = add nuw nsw i32 %42, 1
%65 = call i32 @strlen(i8* %3)
%66 = icmp slt i32 %64, %65
br i1 %66, label %41, label %67
67: ; preds = %63, %20
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %69
69: ; preds = %67, %39
ret i32 0
}