#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 */
double edgelen(int, int);
int longestedge(int t) {
  int LE;
  int e;
  double len;
  double maxlen;
  if (t == 0) {
    return 0;
  } else {
    maxlen = 0.0;
    for (e = 0; e < 3; e++) {
      len = edgelen(t, e);
      if (maxlen < len) {
        maxlen = len;
        LE = e;
      }
    }
    return LE;
  }
}


x86 assembly (clang, -O0):
<longestedge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1131 <longestedge+0x21>
movl   $0x0,-0x4(%rbp)
jmp    1197 <longestedge+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    1191 <longestedge+0x81>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <edgelen@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    117e <longestedge+0x6e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <longestedge+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <longestedge+0x30>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longestedge>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     1177 <longestedge+0x67>
mov    %edi,%ebx
xor    %esi,%esi
call   1030 <edgelen@plt>
xorpd  %xmm1,%xmm1
maxsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x1,%esi
call   1030 <edgelen@plt>
xor    %ebp,%ebp
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
seta   %bpl
maxsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%r14d
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <edgelen@plt>
ucomisd 0x8(%rsp),%xmm0
cmova  %r14d,%ebp
jmp    1179 <longestedge+0x69>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @longestedge(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %31
11: ; preds = %1
store double 0.000000e+00, double* %7
store i32 0, i32* %5
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = call double @edgelen(i32 %16, i32 %17)
store double %18, double* %6
%19 = load double, double* %7
%20 = load double, double* %6
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load double, double* %6
store double %23, double* %7
%24 = load i32, i32* %5
store i32 %24, i32* %4
br label %25
25: ; preds = %22, %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %12
29: ; preds = %12
%30 = load i32, i32* %4
store i32 %30, i32* %2
br label %31
31: ; preds = %29, %10
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @longestedge(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call double @edgelen(i32 %0, i32 0)
%5 = fcmp ogt double %4, 0.000000e+00
%6 = select i1 %5, double %4, double 0.000000e+00
%7 = tail call double @edgelen(i32 %0, i32 1)
%8 = fcmp olt double %6, %7
%9 = zext i1 %8 to i32
%10 = select i1 %8, double %7, double %6
%11 = tail call double @edgelen(i32 %0, i32 2)
%12 = fcmp olt double %10, %11
%13 = select i1 %12, i32 2, i32 %9
br label %14
14: ; preds = %3, %1
%15 = phi i32 [ 0, %1 ], [ %13, %3 ]
ret i32 %15
}