#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*/ read_input(char *);
int /*<<< orphan*/ sort(char *, char *, char *);
int strlen(char *);
int main(void) {
  char smallest[81];
  char largest[81];
  char str[81];
  while (true) {
    read_input(str);
    if (strlen(str) == 4) {
      break;
    }
    sort(str, smallest, largest);
  }
  printf("\n");
  printf("Smallest word: %s\n", smallest);
  printf("Largest word: %s\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x120(%rbp),%rdi
call   1060 <read_input@plt>
lea    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    1178 <main+0x38>
jmp    1194 <main+0x54>
lea    -0x120(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
call   1050 <sort@plt>
jmp    1152 <main+0x12>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <read_input@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
je     11b3 <main+0x63>
mov    %rsp,%rbx
lea    0xc0(%rsp),%r14
lea    0x60(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <sort@plt>
mov    %rbx,%rdi
call   1070 <read_input@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    1190 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe3c(%rip),%rdi
lea    0xc0(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [19 x i8] c"Smallest word: %s\0A\00"
@.str.2 = [18 x i8] c"Largest word: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca [81 x i8]
%4 = alloca [81 x i8]
store i32 0, i32* %1
br label %5
5: ; preds = %0, %12
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%7 = call i32 @read_input(i8* %6)
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %12
11: ; preds = %5
br label %17
12: ; preds = %5
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%16 = call i32 @sort(i8* %13, i8* %14, i8* %15)
br label %5
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Smallest word: %s\0A\00"
@.str.2 = [18 x i8] c"Largest word: %s\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = alloca [81 x i8]
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%7 = call i32 @read_input(i8* %6)
%8 = call i32 @strlen(i8* %6)
%9 = icmp eq i32 %8, 4
br i1 %9, label %15, label %10
10: ; preds = %0, %10
%11 = call i32 @sort(i8* %6, i8* %4, i8* %5)
%12 = call i32 @read_input(i8* %6)
%13 = call i32 @strlen(i8* %6)
%14 = icmp eq i32 %13, 4
br i1 %14, label %15, label %10
15: ; preds = %10, %0
%16 = call i32 @putchar(i32 10)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}