#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*/ swap(int *, int *);
void three_sort(int *a, int *b, int *c) {
  if (*a > *b)
    swap(a, b);
  if (*a > *c)
    swap(a, c);
  if (*b > *c)
    swap(b, c);
}


x86 assembly (clang, -O0):
<three_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    1143 <three_sort+0x33>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <swap@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jle    1162 <three_sort+0x52>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <swap@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jle    1181 <three_sort+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <swap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<three_sort>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%eax
cmp    (%rsi),%eax
jle    1131 <three_sort+0x21>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <swap@plt>
mov    (%rbx),%eax
mov    (%r14),%ecx
cmp    %ecx,%eax
jle    1146 <three_sort+0x36>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <swap@plt>
mov    (%r14),%ecx
cmp    %ecx,(%r15)
jle    115b <three_sort+0x4b>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <swap@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @three_sort(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
%11 = icmp sgt i32 %8, %10
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32*, i32** %4
%14 = load i32*, i32** %5
%15 = call i32 @swap(i32* %13, i32* %14)
br label %16
16: ; preds = %12, %3
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = icmp sgt i32 %18, %20
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32*, i32** %4
%24 = load i32*, i32** %6
%25 = call i32 @swap(i32* %23, i32* %24)
br label %26
26: ; preds = %22, %16
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = icmp sgt i32 %28, %30
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32*, i32** %5
%34 = load i32*, i32** %6
%35 = call i32 @swap(i32* %33, i32* %34)
br label %36
36: ; preds = %32, %26
ret void
}

LLVM IR (-O2):
define void @three_sort(i32* %0, i32* %1, i32* %2) {
%4 = load i32, i32* %0
%5 = load i32, i32* %1
%6 = icmp sgt i32 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @swap(i32* %0, i32* %1)
%9 = load i32, i32* %0
br label %10
10: ; preds = %7, %3
%11 = phi i32 [ %9, %7 ], [ %4, %3 ]
%12 = load i32, i32* %2
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @swap(i32* %0, i32* %2)
%16 = load i32, i32* %2
br label %17
17: ; preds = %14, %10
%18 = phi i32 [ %16, %14 ], [ %12, %10 ]
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, %18
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 @swap(i32* %1, i32* %2)
br label %23
23: ; preds = %21, %17
ret void
}