#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 GET_ELEM_N1(int);
int GET_ELEM_N2(int);
double GET_NODE_X(int);
double GET_NODE_Y(int);
double sqrt(double);
double compute_L(int pos) {
  int n1, n2;
  double x1, y1, x2, y2;
  n1 = GET_ELEM_N1(pos);
  n2 = GET_ELEM_N2(pos);
  x1 = GET_NODE_X(n1);
  y1 = GET_NODE_Y(n1);
  x2 = GET_NODE_X(n2);
  y2 = GET_NODE_Y(n2);
  return (sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1)));
}


x86 assembly (clang, -O0):
<compute_L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <GET_ELEM_N1@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <GET_ELEM_N2@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <GET_NODE_X@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <GET_NODE_Y@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <GET_NODE_X@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <GET_NODE_Y@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
subsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_L>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
call   1030 <GET_ELEM_N1@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <GET_ELEM_N2@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <GET_NODE_X@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1070 <GET_NODE_Y@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <GET_NODE_X@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1070 <GET_NODE_Y@plt>
subsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c7 <compute_L+0x77>
sqrtsd %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <sqrt@plt>

LLVM IR (-O0):
define double @compute_L(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %2
%9 = load i32, i32* %2
%10 = call i32 @GET_ELEM_N1(i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i32 @GET_ELEM_N2(i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = call double @GET_NODE_X(i32 %13)
store double %14, double* %5
%15 = load i32, i32* %3
%16 = call double @GET_NODE_Y(i32 %15)
store double %16, double* %6
%17 = load i32, i32* %4
%18 = call double @GET_NODE_X(i32 %17)
store double %18, double* %7
%19 = load i32, i32* %4
%20 = call double @GET_NODE_Y(i32 %19)
store double %20, double* %8
%21 = load double, double* %8
%22 = load double, double* %6
%23 = fsub double %21, %22
%24 = load double, double* %8
%25 = load double, double* %6
%26 = fsub double %24, %25
%27 = load double, double* %7
%28 = load double, double* %5
%29 = fsub double %27, %28
%30 = load double, double* %7
%31 = load double, double* %5
%32 = fsub double %30, %31
%33 = fmul double %29, %32
%34 = call double @llvm.fmuladd.f64(double %23, double %26, double %33)
%35 = call double @sqrt(double %34)
ret double %35
}

LLVM IR (-O2):
define double @compute_L(i32 %0) {
%2 = tail call i32 @GET_ELEM_N1(i32 %0)
%3 = tail call i32 @GET_ELEM_N2(i32 %0)
%4 = tail call double @GET_NODE_X(i32 %2)
%5 = tail call double @GET_NODE_Y(i32 %2)
%6 = tail call double @GET_NODE_X(i32 %3)
%7 = tail call double @GET_NODE_Y(i32 %3)
%8 = fsub double %7, %5
%9 = fsub double %6, %4
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %10)
%12 = tail call double @sqrt(double %11)
ret double %12
}