#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*/ gets(char *);
scalar_t__ karti(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main() {
  char k, cards[13];
  int l, min, j, i;
  printf("vuvedi karti");
  gets(cards);
  l = strlen(cards) - 1;
  for (i = 0; i <= l; ++i) {
    min = i;
    for (j = i; j <= l; ++j)
      if (karti(cards[min]) > karti(cards[j]))
        min = j;
    k = cards[min];
    cards[min] = cards[i];
    cards[i] = k;
  }
  puts(cards);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x12(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x12(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     122b <main+0xdb>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11f7 <main+0xa7>
movslq -0x1c(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1040 <karti@plt>
mov    %rax,-0x30(%rbp)
movslq -0x20(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edi
call   1040 <karti@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jle    11e4 <main+0x94>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11e9 <main+0x99>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a2 <main+0x52>
movslq -0x1c(%rbp),%rax
mov    -0x12(%rbp,%rax,1),%al
mov    %al,-0x5(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x12(%rbp,%rax,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x5(%rbp),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <main+0x3a>
lea    -0x12(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9d(%rip),%rdi
call   1060 <printf@plt>
lea    0x3(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11f0 <main+0xa0>
mov    %eax,%r14d
xor    %r15d,%r15d
jmp    11ae <main+0x5e>
nopl   0x0(%rax)
movslq %ecx,%rax
mov    0x3(%rsp,%rax,1),%cl
mov    0x3(%rsp,%r15,1),%dl
mov    %dl,0x3(%rsp,%rax,1)
mov    %cl,0x3(%rsp,%r15,1)
add    $0x1,%r15
cmp    %r14,%r15
je     11f0 <main+0xa0>
mov    %r15,%rbx
mov    %r15d,%ebp
jmp    11cb <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %ecx,%ebp
cmp    %rbx,%r14
je     1190 <main+0x40>
movslq %ebp,%rax
movsbl 0x3(%rsp,%rax,1),%edi
call   1040 <karti@plt>
mov    %rax,%r12
movsbl 0x3(%rsp,%rbx,1),%edi
call   1040 <karti@plt>
mov    %ebx,%ecx
cmp    %rax,%r12
jg     11c0 <main+0x70>
mov    %ebp,%ecx
jmp    11c0 <main+0x70>
lea    0x3(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"vuvedi karti\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [13 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %4
store i32 0, i32* %7
br label %14
14: ; preds = %59, %0
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %62
18: ; preds = %14
%19 = load i32, i32* %7
store i32 %19, i32* %5
%20 = load i32, i32* %7
store i32 %20, i32* %6
br label %21
21: ; preds = %40, %18
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %43
25: ; preds = %21
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @karti(i8 signext %29)
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i64 @karti(i8 signext %34)
%36 = icmp sgt i64 %30, %35
br i1 %36, label %37, label %39
37: ; preds = %25
%38 = load i32, i32* %6
store i32 %38, i32* %5
br label %39
39: ; preds = %37, %25
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %21
43: ; preds = %21
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %45
%47 = load i8, i8* %46
store i8 %47, i8* %2
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %53
store i8 %51, i8* %54
%55 = load i8, i8* %2
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %43
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %14
62: ; preds = %14
%63 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%64 = call i32 @puts(i8* %63)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"vuvedi karti\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %35
7: ; preds = %0
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %27, %7
%10 = phi i64 [ 0, %7 ], [ %33, %27 ]
%11 = trunc i64 %10 to i32
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ %10, %9 ], [ %25, %12 ]
%14 = phi i32 [ %11, %9 ], [ %24, %12 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @karti(i8 signext %17)
%19 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %13
%20 = load i8, i8* %19
%21 = call i64 @karti(i8 signext %20)
%22 = icmp sgt i64 %18, %21
%23 = trunc i64 %13 to i32
%24 = select i1 %22, i32 %23, i32 %14
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %12
27: ; preds = %12
%28 = sext i32 %24 to i64
%29 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %10
%32 = load i8, i8* %31
store i8 %32, i8* %29
store i8 %30, i8* %31
%33 = add nuw nsw i64 %10, 1
%34 = icmp eq i64 %33, %8
br i1 %34, label %35, label %9
35: ; preds = %27, %0
%36 = call i32 @puts(i8* %2)
ret i32 0
}