#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 *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sort_puple(char *, int);
int strlen(char *);
int main() {
  char in[1024];
  char *p = in;
  while (gets(in) != NULL) {
    int len = strlen(in);
    sort_puple(in, len);
    printf("%s\n", in);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1060 <gets@plt>
cmp    $0x0,%rax
je     11b2 <main+0x72>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x41c(%rbp),%esi
call   1050 <sort_puple@plt>
lea    -0x410(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     119a <main+0x5a>
mov    %rsp,%rbx
lea    0xe9f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <sort_puple@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
test   %rax,%rax
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
store i8* %5, i8** %3
br label %6
6: ; preds = %10, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32* @gets(i8* %7)
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %4
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 @sort_puple(i8* %13, i32 %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %6
18: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32* @gets(i8* %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = call i32 @strlen(i8* %2)
%7 = call i32 @sort_puple(i8* %2, i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i32* @gets(i8* %2)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %0
ret i32 0
}