#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char cards[14], swap;
  int i, d, l;
  printf("Enter 13 cards: ");
  scanf("%s", cards);
  l = strlen(cards) - 1;
  while (strlen(cards) != 13) {
    printf("Cards have to be 13: ");
    scanf("%s", cards);
  }
  for (i = 0; i < l; i++) {
    for (d = 0; d < l - i; d++) {
      if (cards[d] > cards[d + 1]) {
        swap = cards[d];
        cards[d] = cards[d + 1];
        cards[d + 1] = swap;
      }
    }
  }
  printf("Cards in ascending order:%s", cards);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xee8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xd,%eax
je     11a1 <main+0x71>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1050 <scanf@plt>
jmp    116c <main+0x3c>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    123f <main+0x10f>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    122c <main+0xfc>
movslq -0x1c(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x12(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jle    1219 <main+0xe9>
movslq -0x1c(%rbp),%rax
mov    -0x12(%rbp,%rax,1),%al
mov    %al,-0x13(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x12(%rbp,%rax,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x13(%rbp),%cl
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x12(%rbp,%rax,1)
jmp    121e <main+0xee>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bb <main+0x8b>
jmp    1231 <main+0x101>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a8 <main+0x78>
lea    -0x12(%rbp),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%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    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeed(%rip),%rdi
lea    0xa(%rsp),%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0xd,%eax
je     11b2 <main+0x82>
lea    0xe92(%rip),%r15
lea    0xeba(%rip),%r12
lea    0xa(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xd,%eax
jne    1190 <main+0x60>
cmp    $0x2,%r13d
jl     1263 <main+0x133>
add    $0xffffffff,%r13d
xor    %ebp,%ebp
mov    %r13d,%ecx
jmp    11df <main+0xaf>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffff,%ecx
cmp    %r13d,%ebp
je     1263 <main+0x133>
mov    %ecx,%ecx
cmp    %ebp,%r13d
jle    11d0 <main+0xa0>
mov    0xa(%rsp),%al
cmp    $0x1,%ecx
jne    1210 <main+0xe0>
xor    %ebx,%ebx
test   $0x1,%cl
je     11d0 <main+0xa0>
mov    0x1(%rbx,%r14,1),%dl
cmp    %dl,%al
jle    11d0 <main+0xa0>
mov    %dl,0xa(%rsp,%rbx,1)
mov    %al,0xb(%rsp,%rbx,1)
jmp    11d0 <main+0xa0>
nopl   0x0(%rax)
mov    %ecx,%esi
and    $0xfffffffe,%esi
xor    %edi,%edi
jmp    1230 <main+0x100>
nopl   0x0(%rax)
mov    %dl,0xb(%rsp,%rdi,1)
mov    %al,0xc(%rsp,%rdi,1)
mov    %rbx,%rdi
cmp    %rbx,%rsi
je     11f1 <main+0xc1>
movzbl 0xb(%rsp,%rdi,1),%edx
cmp    %dl,%al
jle    1250 <main+0x120>
mov    %dl,0xa(%rsp,%rdi,1)
mov    %al,0xb(%rsp,%rdi,1)
jmp    1252 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%eax
lea    0x2(%rdi),%rbx
movzbl 0xc(%rsp,%rdi,1),%edx
cmp    %dl,%al
jg     1220 <main+0xf0>
mov    %edx,%eax
jmp    1228 <main+0xf8>
lea    0xdbd(%rip),%rdi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter 13 cards: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"Cards have to be 13: \00"
@.str.3 = [28 x i8] c"Cards in ascending order:%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [14 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %6
br label %13
13: ; preds = %17, %0
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %15, 13
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %13
21: ; preds = %13
store i32 0, i32* %4
br label %22
22: ; preds = %69, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %72
26: ; preds = %22
store i32 0, i32* %5
br label %27
27: ; preds = %65, %26
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = load i32, i32* %4
%31 = sub nsw i32 %29, %30
%32 = icmp slt i32 %28, %31
br i1 %32, label %33, label %68
33: ; preds = %27
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp sgt i32 %38, %44
br i1 %45, label %46, label %64
46: ; preds = %33
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
store i8 %50, i8* %3
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
%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 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %57
store i8 %55, i8* %58
%59 = load i8, i8* %3
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %62
store i8 %59, i8* %63
br label %64
64: ; preds = %46, %33
br label %65
65: ; preds = %64
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %27
68: ; preds = %27
br label %69
69: ; preds = %68
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 1
store i32 %71, i32* %4
br label %22
72: ; preds = %22
%73 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %73)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter 13 cards: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"Cards have to be 13: \00"
@.str.3 = [28 x i8] c"Cards in ascending order:%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 ([17 x i8], [17 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 = add i32 %5, -1
%7 = call i32 @strlen(i8* %2)
%8 = icmp eq i32 %7, 13
br i1 %8, label %9, label %11
9: ; preds = %11, %0
%10 = icmp sgt i32 %5, 1
br i1 %10, label %16, label %64
11: ; preds = %0, %11
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%14 = call i32 @strlen(i8* %2)
%15 = icmp eq i32 %14, 13
br i1 %15, label %9, label %11
16: ; preds = %9, %60
%17 = phi i32 [ %62, %60 ], [ %6, %9 ]
%18 = phi i32 [ %61, %60 ], [ 0, %9 ]
%19 = zext i32 %17 to i64
%20 = icmp sgt i32 %6, %18
br i1 %20, label %21, label %60
21: ; preds = %16
%22 = load i8, i8* %2
%23 = and i64 %19, 1
%24 = icmp eq i32 %17, 1
br i1 %24, label %49, label %25
25: ; preds = %21
%26 = and i64 %19, 4294967294
br label %27
27: ; preds = %45, %25
%28 = phi i8 [ %22, %25 ], [ %46, %45 ]
%29 = phi i64 [ 0, %25 ], [ %39, %45 ]
%30 = phi i64 [ 0, %25 ], [ %47, %45 ]
%31 = or i64 %29, 1
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp sgt i8 %28, %33
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %29
store i8 %33, i8* %36
store i8 %28, i8* %32
br label %37
37: ; preds = %27, %35
%38 = phi i8 [ %33, %27 ], [ %28, %35 ]
%39 = add nuw nsw i64 %29, 2
%40 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp sgt i8 %38, %41
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %31
store i8 %41, i8* %44
store i8 %38, i8* %40
br label %45
45: ; preds = %43, %37
%46 = phi i8 [ %41, %37 ], [ %38, %43 ]
%47 = add i64 %30, 2
%48 = icmp eq i64 %47, %26
br i1 %48, label %49, label %27
49: ; preds = %45, %21
%50 = phi i8 [ %22, %21 ], [ %46, %45 ]
%51 = phi i64 [ 0, %21 ], [ %39, %45 ]
%52 = icmp eq i64 %23, 0
br i1 %52, label %60, label %53
53: ; preds = %49
%54 = add nuw nsw i64 %51, 1
%55 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = icmp sgt i8 %50, %56
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %51
store i8 %56, i8* %59
store i8 %50, i8* %55
br label %60
60: ; preds = %49, %58, %53, %16
%61 = add nuw nsw i32 %18, 1
%62 = add i32 %17, -1
%63 = icmp eq i32 %61, %6
br i1 %63, label %64, label %16
64: ; preds = %60, %9
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %2)
ret i32 0
}