#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 *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  void swap(char *, char *);
  char str1[20], str2[20], str3[20];
  printf("input three line:\n");
  gets(str1);
  gets(str2);
  gets(str3);
  if (strcmp(str1, str2) > 0)
    swap(str1, str2);
  if (strcmp(str1, str3) > 0)
    swap(str1, str3);
  if (strcmp(str2, str3) > 0)
    swap(str2, str3);
  printf("New order is:\n");
  printf("%s\n%s\n%s\n", str1, str2, str3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x40(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x60(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    119c <main+0x5c>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <swap@plt>
lea    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11c0 <main+0x80>
lea    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <swap@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11e4 <main+0xa4>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <swap@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0x40(%rsp),%r14
mov    %r14,%rdi
call   1060 <gets@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rsp,%rdi
call   1060 <gets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11a4 <main+0x54>
lea    0x40(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1070 <swap@plt>
lea    0x40(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11c3 <main+0x73>
lea    0x40(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <swap@plt>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11e2 <main+0x92>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <swap@plt>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0b(%rip),%rdi
lea    0x40(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %rsp,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"input three line:\0A\00"
@.str.1 = [15 x i8] c"New order is:\0A\00"
@.str.2 = [10 x i8] c"%s\0A%s\0A%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%14 = call i64 @strcmp(i8* %12, i8* %13)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
br label %19
19: ; preds = %16, %0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
br label %27
27: ; preds = %24, %19
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
br label %35
35: ; preds = %32, %27
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* %38, i8* %39)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [10 x i8] c"%s\0A%s\0A%s\0A\00"
@str = [18 x i8] c"input three line:\00"
@str.3 = [14 x i8] c"New order is:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @gets(i8* %5)
%10 = call i32 @gets(i8* %6)
%11 = call i64 @strcmp(i8* %4, i8* %5)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %0
br label %14
14: ; preds = %13, %0
%15 = call i64 @strcmp(i8* %4, i8* %6)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
br label %18
18: ; preds = %17, %14
%19 = call i64 @strcmp(i8* %5, i8* %6)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %22
22: ; preds = %21, %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
ret i32 0
}