#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 x, y, i, t;
  char a[14];
  printf("Enter cards:");
  scanf("%s", a);
  for (i = 0; i < strlen(a); i++) {
    t = 0;
    if (a[i] >= '2' && a[i] <= '9') {
      t = 1;
    } else if (a[i] == 'A' || a[i] == 'K' || a[i] == 'Q' || a[i] == 'J' ||
               a[i] == 'T') {
      t = 1;
    }
    if (t == 0) {
      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    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x22(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    1256 <main+0x116>
movl   $0x0,-0x14(%rbp)
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x32,%eax
jl     11c7 <main+0x87>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jg     11c7 <main+0x87>
movl   $0x1,-0x14(%rbp)
jmp    122d <main+0xed>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x41,%eax
je     1221 <main+0xe1>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x4b,%eax
je     1221 <main+0xe1>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x51,%eax
je     1221 <main+0xe1>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x4a,%eax
je     1221 <main+0xe1>
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x54,%eax
jne    1228 <main+0xe8>
movl   $0x1,-0x14(%rbp)
jmp    122d <main+0xed>
cmpl   $0x0,-0x14(%rbp)
jne    1243 <main+0x103>
movl   $0x0,-0x4(%rbp)
jmp    1343 <main+0x203>
jmp    1248 <main+0x108>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1174 <main+0x34>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x22(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    132a <main+0x1ea>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x22(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1317 <main+0x1d7>
movslq -0xc(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x22(%rbp,%rax,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jle    1304 <main+0x1c4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x22(%rbp,%rax,1),%eax
mov    %eax,-0x28(%rbp)
movslq -0xc(%rbp),%rax
mov    -0x22(%rbp,%rax,1),%cl
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x22(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x22(%rbp,%rax,1)
jmp    1309 <main+0x1c9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1280 <main+0x140>
jmp    131c <main+0x1dc>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    125d <main+0x11d>
lea    -0x22(%rbp),%rsi
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0x2(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11c8 <main+0x88>
xor    %ebx,%ebx
lea    0x2(%rsp),%r14
mov    $0x90601,%r15d
jmp    11a3 <main+0x63>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11c8 <main+0x88>
movzbl 0x2(%rsp,%rbx,1),%eax
lea    -0x32(%rax),%ecx
cmp    $0x8,%cl
jb     1190 <main+0x50>
add    $0xbf,%al
cmp    $0x13,%al
ja     1260 <main+0x120>
movzbl %al,%eax
bt     %rax,%r15
jb     1190 <main+0x50>
jmp    1260 <main+0x120>
lea    0x2(%rsp),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    124d <main+0x10d>
xor    %r15d,%r15d
lea    0x2(%rsp),%r14
jmp    11f1 <main+0xb1>
add    $0x1,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jge    124d <main+0x10d>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11e0 <main+0xa0>
xor    %ebx,%ebx
jmp    1225 <main+0xe5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
mov    %r13,%rbx
cmp    %rax,%r13
jge    11e0 <main+0xa0>
movsbl 0x2(%rsp,%rbx,1),%edi
call   1030 <Findvalue@plt>
mov    %rax,%r12
lea    0x1(%rbx),%r13
movsbl 0x3(%rsp,%rbx,1),%edi
call   1030 <Findvalue@plt>
cmp    %rax,%r12
jle    1210 <main+0xd0>
rolw   $0x8,0x2(%rsp,%rbx,1)
jmp    1210 <main+0xd0>
lea    0xdb9(%rip),%rdi
lea    0x2(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Enter cards:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %17, %0
%8 = call i32 @strlen(i8* %2)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %22, label %48
10: ; preds = %0, %17
%11 = phi i64 [ %18, %17 ], [ 0, %0 ]
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = add i8 %13, -50
%15 = icmp ult i8 %14, 8
br i1 %15, label %17, label %16
16: ; preds = %10
switch i8 %13, label %50 [
i8 65, label %17
i8 75, label %17
i8 81, label %17
i8 74, label %17
i8 84, label %17
]
17: ; preds = %16, %16, %16, %16, %16, %10
%18 = add nuw nsw i64 %11, 1
%19 = call i32 @strlen(i8* %2)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %10, label %7
22: ; preds = %7, %44
%23 = phi i32 [ %45, %44 ], [ 0, %7 ]
%24 = call i32 @strlen(i8* %2)
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %44
26: ; preds = %22, %39
%27 = phi i64 [ %31, %39 ], [ 0, %22 ]
%28 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @Findvalue(i8 signext %29)
%31 = add nuw nsw i64 %27, 1
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i64 @Findvalue(i8 signext %33)
%35 = icmp sgt i64 %30, %34
br i1 %35, label %36, label %39
36: ; preds = %26
%37 = load i8, i8* %32
%38 = load i8, i8* %28
store i8 %38, i8* %32
store i8 %37, i8* %28
br label %39
39: ; preds = %26, %36
%40 = call i32 @strlen(i8* %2)
%41 = add nsw i32 %40, -1
%42 = sext i32 %41 to i64
%43 = icmp slt i64 %31, %42
br i1 %43, label %26, label %44
44: ; preds = %39, %22
%45 = add nuw nsw i32 %23, 1
%46 = call i32 @strlen(i8* %2)
%47 = icmp slt i32 %45, %46
br i1 %47, label %22, label %48
48: ; preds = %44, %7
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %50
50: ; preds = %16, %48
ret i32 0
}