#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*/ edge_sizes(int, int *, int *);
int triangle_size(int n, int *t) {
  int dist[3];
  edge_sizes(n, t, dist);
  int h;
  int res = 0;
  for (h = 0; h < 3; h++) {
    if (dist[h] > res) {
      res = dist[h];
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<triangle_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <edge_sizes@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    1176 <triangle_size+0x66>
movslq -0x20(%rbp),%rax
mov    -0x1c(%rbp,%rax,4),%eax
cmp    -0x24(%rbp),%eax
jle    1163 <triangle_size+0x53>
movslq -0x20(%rbp),%rax
mov    -0x1c(%rbp,%rax,4),%eax
mov    %eax,-0x24(%rbp)
jmp    1168 <triangle_size+0x58>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <triangle_size+0x2d>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangle_size>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdx
call   1030 <edge_sizes@plt>
mov    0xc(%rsp),%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
mov    0x10(%rsp),%ecx
cmp    %eax,%ecx
cmovg  %ecx,%eax
mov    0x14(%rsp),%ecx
cmp    %eax,%ecx
cmovg  %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @triangle_size(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [3 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = load i32*, i32** %4
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%11 = call i32 @edge_sizes(i32 %8, i32* %9, i32* %10)
store i32 0, i32* %7
store i32 0, i32* %6
br label %12
12: ; preds = %28, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %7
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %7
br label %27
27: ; preds = %22, %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %12
31: ; preds = %12
%32 = load i32, i32* %7
ret i32 %32
}

LLVM IR (-O2):
define i32 @triangle_size(i32 %0, i32* %1) {
%3 = alloca [3 x i32]
%4 = bitcast [3 x i32]* %3 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%6 = call i32 @edge_sizes(i32 %0, i32* %1, i32* %5)
%7 = load i32, i32* %5
%8 = icmp sgt i32 %7, 0
%9 = select i1 %8, i32 %7, i32 0
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, %9
%13 = select i1 %12, i32 %11, i32 %9
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, %13
%17 = select i1 %16, i32 %15, i32 %13
ret i32 %17
}