#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 ch[20];
  char temp;
  int i, j;
  printf("Enter the Word: (Either in Upper Caps or Lower Caps) \n");
  scanf("%s", ch);
  for (i = 0; i < strlen(ch); i++)
    for (j = 0; j < strlen(ch); j++)
      if (ch[i] < ch[j]) {
        temp = ch[i];
        ch[i] = ch[j];
        ch[j] = temp;
      }
  for (i = 0; i < strlen(ch); i++) {
    printf("%c", ch[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xedf(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    1209 <main+0xd9>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    11f6 <main+0xc6>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
movslq -0x2c(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jge    11e3 <main+0xb3>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%al
mov    %al,-0x21(%rbp)
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x21(%rbp),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
jmp    11e8 <main+0xb8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1187 <main+0x57>
jmp    11fb <main+0xcb>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1164 <main+0x34>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    1251 <main+0x121>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1210 <main+0xe0>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
lea    0xea4(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11d9 <main+0x99>
xor    %r15d,%r15d
mov    %rsp,%r14
jmp    1193 <main+0x53>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%r15
jge    11d9 <main+0x99>
mov    %r14,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x40>
xor    %ebx,%ebx
jmp    11c3 <main+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1180 <main+0x40>
movzbl (%rsp,%r15,1),%eax
movzbl (%rsp,%rbx,1),%ecx
cmp    %cl,%al
jge    11b0 <main+0x70>
mov    %cl,(%rsp,%r15,1)
mov    %al,(%rsp,%rbx,1)
jmp    11b0 <main+0x70>
mov    %rsp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    120c <main+0xcc>
xor    %ebx,%ebx
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11f0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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