#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 exchange(int *q1, int *q2, int *q3) {
  if (*q1 < *q2)
    swap(q1, q2);
  if (*q1 < *q3)
    swap(q1, q3);
  if (*q2 < *q3)
    swap(q2, q3);
}


x86 assembly (clang, -O0):
<exchange>:
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
jge    1143 <exchange+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
jge    1162 <exchange+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
jge    1181 <exchange+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <swap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exchange>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%eax
cmp    (%rsi),%eax
jge    1131 <exchange+0x21>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <swap@plt>
mov    (%rbx),%eax
mov    (%r14),%ecx
cmp    %ecx,%eax
jge    1146 <exchange+0x36>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <swap@plt>
mov    (%r14),%ecx
cmp    %ecx,(%r15)
jge    115b <exchange+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 @exchange(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 slt 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 slt 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 slt 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 @exchange(i32* %0, i32* %1, i32* %2) {
%4 = load i32, i32* %0
%5 = load i32, i32* %1
%6 = icmp slt 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 slt 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 slt 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
}