#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 *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ swap(char *, char *);
void main() {
  char str1[20], str2[20], str3[20];
  printf("Please input three strings\n");
  scanf("%s", str1);
  scanf("%s", str2);
  scanf("%s", 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("The sorted strings are %s, %s, %s\n", str1, str2, str3);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeab(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11aa <main+0x6a>
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    11ce <main+0x8e>
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    11f2 <main+0xb2>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <swap@plt>
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rbx
lea    0x40(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11b6 <main+0x66>
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    11d5 <main+0x85>
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    11f4 <main+0xa4>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <swap@plt>
lea    0xe08(%rip),%rdi
lea    0x40(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %rsp,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please input three strings\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [35 x i8] c"The sorted strings are %s, %s, %s\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%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)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = call i64 @strcmp(i8* %11, i8* %12)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = call i32 @swap(i8* %16, i8* %17)
br label %19
19: ; preds = %15, %0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%27 = call i32 @swap(i8* %25, i8* %26)
br label %28
28: ; preds = %24, %19
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%36 = call i32 @swap(i8* %34, i8* %35)
br label %37
37: ; preds = %33, %28
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %38, i8* %39, i8* %40)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [35 x i8] c"The sorted strings are %s, %s, %s\0A\00"
@str = [27 x i8] c"Please input three strings\00"
define void @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 ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = call i64 @strcmp(i8* %4, i8* %5)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @swap(i8* %4, i8* %5)
br label %15
15: ; preds = %13, %0
%16 = call i64 @strcmp(i8* %4, i8* %6)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @swap(i8* %4, i8* %6)
br label %20
20: ; preds = %18, %15
%21 = call i64 @strcmp(i8* %5, i8* %6)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @swap(i8* %5, i8* %6)
br label %25
25: ; preds = %23, %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
ret void
}