#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 acos(int);
int cos(double);
void elongation(double lam, double bet, double lsn, double *el) {
  *el = acos(cos(bet) * cos(lam - lsn));
  if (lam > lsn + 3.141592653589793 ||
      (lam > lsn - 3.141592653589793 && lam < lsn))
    *el = -*el;
}


x86 assembly (clang, -O0):
<elongation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x24(%rbp),%edi
imul   %eax,%edi
call   1030 <acos@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
ja     11ba <elongation+0x9a>
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe68(%rip),%xmm2
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e1 <elongation+0xc1>
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e1 <elongation+0xc1>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elongation>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movaps %xmm1,%xmm0
call   1040 <cos@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
imul   %eax,%ebp
mov    %ebp,%edi
call   1030 <acos@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm0,(%rbx)
movsd  0xe94(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm3
ucomisd %xmm1,%xmm3
ja     1194 <elongation+0x74>
movapd %xmm3,%xmm1
ucomisd %xmm3,%xmm2
jbe    11a0 <elongation+0x80>
addsd  0xe7a(%rip),%xmm2
ucomisd %xmm2,%xmm1
jbe    11a0 <elongation+0x80>
xorpd  0xe74(%rip),%xmm0
movlpd %xmm0,(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @elongation(double %0, double %1, double %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double*
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%9 = load double, double* %6
%10 = call i32 @cos(double %9)
%11 = load double, double* %5
%12 = load double, double* %7
%13 = fsub double %11, %12
%14 = call i32 @cos(double %13)
%15 = mul nsw i32 %10, %14
%16 = call double @acos(i32 %15)
%17 = load double*, double** %8
store double %16, double* %17
%18 = load double, double* %5
%19 = load double, double* %7
%20 = fadd double %19, 0x400921FB54442D18
%21 = fcmp ogt double %18, %20
br i1 %21, label %31, label %22
22: ; preds = %4
%23 = load double, double* %5
%24 = load double, double* %7
%25 = fsub double %24, 0x400921FB54442D18
%26 = fcmp ogt double %23, %25
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = load double, double* %5
%29 = load double, double* %7
%30 = fcmp olt double %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27, %4
%32 = load double*, double** %8
%33 = load double, double* %32
%34 = fneg double %33
%35 = load double*, double** %8
store double %34, double* %35
br label %36
36: ; preds = %31, %27, %22
ret void
}

LLVM IR (-O2):
define void @elongation(double %0, double %1, double %2, double* nocapture %3) {
%5 = tail call i32 @cos(double %1)
%6 = fsub double %0, %2
%7 = tail call i32 @cos(double %6)
%8 = mul nsw i32 %7, %5
%9 = tail call double @acos(i32 %8)
store double %9, double* %3
%10 = fadd double %2, 0x400921FB54442D18
%11 = fcmp olt double %10, %0
br i1 %11, label %17, label %12
12: ; preds = %4
%13 = fadd double %2, 0xC00921FB54442D18
%14 = fcmp olt double %13, %0
%15 = fcmp olt double %0, %2
%16 = and i1 %15, %14
br i1 %16, label %17, label %19
17: ; preds = %12, %4
%18 = fneg double %9
store double %18, double* %3
br label %19
19: ; preds = %17, %12
ret void
}