#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 */
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ swap(scalar_t__ *, scalar_t__ *);
void sort_triangle(uint32_t *triangle) {
  if (triangle[0] > triangle[1]) {
    swap(triangle, triangle + 1);
  }
  if (triangle[1] > triangle[2]) {
    swap(triangle + 1, triangle + 2);
  }
  if (triangle[0] > triangle[1]) {
    swap(triangle, triangle + 1);
  }
}


x86 assembly (clang, -O0):
<sort_triangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    1142 <sort_triangle+0x32>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
call   1030 <swap@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x10(%rcx),%rax
jle    116d <sort_triangle+0x5d>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%rsi
add    $0x10,%rsi
call   1030 <swap@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    1193 <sort_triangle+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
call   1030 <swap@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_triangle>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x8(%rdi),%r14
mov    0x8(%rdi),%rax
cmp    %rax,(%rdi)
jg     1141 <sort_triangle+0x31>
cmp    0x10(%rbx),%rax
jg     1156 <sort_triangle+0x46>
cmp    %rax,(%rbx)
jle    116a <sort_triangle+0x5a>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <swap@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <swap@plt>
mov    0x8(%rbx),%rax
cmp    0x10(%rbx),%rax
jle    112a <sort_triangle+0x1a>
lea    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1030 <swap@plt>
mov    (%r14),%rax
cmp    %rax,(%rbx)
jg     112f <sort_triangle+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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