#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 cos(double);
int /*<<< orphan*/ error(char *);
double sin(double);
double sqrt(double);
void ellipse_foci(double *param, double *foci) {
  double f;
  if (param == NULL)
    error("ellipse_foci: invalid input ellipse.");
  if (foci == NULL)
    error("ellipse_foci: 'foci' must be non null.");
  f = sqrt(param[2] * param[2] - param[3] * param[3]);
  foci[0] = param[0] + f * cos(param[4]);
  foci[1] = param[1] + f * sin(param[4]);
  foci[2] = param[0] - f * cos(param[4]);
  foci[3] = param[1] - f * sin(param[4]);
}


x86 assembly (clang, -O0):
<ellipse_foci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1167 <ellipse_foci+0x27>
lea    0xe9e(%rip),%rdi
call   1040 <error@plt>
cmpq   $0x0,-0x10(%rbp)
jne    117e <ellipse_foci+0x3e>
lea    0xeac(%rip),%rdi
call   1040 <error@plt>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
call   1050 <cos@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
call   1030 <sin@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
call   1050 <cos@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
call   1030 <sin@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ellipse_foci>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     1239 <ellipse_foci+0xf9>
test   %r14,%r14
je     124e <ellipse_foci+0x10e>
movsd  0x10(%rbx),%xmm0
movsd  0x18(%rbx),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1185 <ellipse_foci+0x45>
sqrtsd %xmm0,%xmm0
jmp    118a <ellipse_foci+0x4a>
call   1060 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdc0(%rip),%rdi
call   1040 <error@plt>
test   %r14,%r14
jne    115f <ellipse_foci+0x1f>
lea    0xdd0(%rip),%rdi
call   1040 <error@plt>
jmp    115f <ellipse_foci+0x1f>

LLVM IR (-O0):
@.str = [37 x i8] c"ellipse_foci: invalid input ellipse.\00"
@.str.1 = [39 x i8] c"ellipse_foci: 'foci' must be non null.\00"
define void @ellipse_foci(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = icmp eq double* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load double*, double** %4
%12 = icmp eq double* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = load double*, double** %3
%17 = getelementptr inbounds double, double* %16, i64 2
%18 = load double, double* %17
%19 = load double*, double** %3
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
%22 = load double*, double** %3
%23 = getelementptr inbounds double, double* %22, i64 3
%24 = load double, double* %23
%25 = load double*, double** %3
%26 = getelementptr inbounds double, double* %25, i64 3
%27 = load double, double* %26
%28 = fmul double %24, %27
%29 = fneg double %28
%30 = call double @llvm.fmuladd.f64(double %18, double %21, double %29)
%31 = call double @sqrt(double %30)
store double %31, double* %5
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = load double, double* %5
%36 = load double*, double** %3
%37 = getelementptr inbounds double, double* %36, i64 4
%38 = load double, double* %37
%39 = call double @cos(double %38)
%40 = call double @llvm.fmuladd.f64(double %35, double %39, double %34)
%41 = load double*, double** %4
%42 = getelementptr inbounds double, double* %41, i64 0
store double %40, double* %42
%43 = load double*, double** %3
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double, double* %5
%47 = load double*, double** %3
%48 = getelementptr inbounds double, double* %47, i64 4
%49 = load double, double* %48
%50 = call double @sin(double %49)
%51 = call double @llvm.fmuladd.f64(double %46, double %50, double %45)
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
%54 = load double*, double** %3
%55 = getelementptr inbounds double, double* %54, i64 0
%56 = load double, double* %55
%57 = load double, double* %5
%58 = load double*, double** %3
%59 = getelementptr inbounds double, double* %58, i64 4
%60 = load double, double* %59
%61 = call double @cos(double %60)
%62 = fneg double %57
%63 = call double @llvm.fmuladd.f64(double %62, double %61, double %56)
%64 = load double*, double** %4
%65 = getelementptr inbounds double, double* %64, i64 2
store double %63, double* %65
%66 = load double*, double** %3
%67 = getelementptr inbounds double, double* %66, i64 1
%68 = load double, double* %67
%69 = load double, double* %5
%70 = load double*, double** %3
%71 = getelementptr inbounds double, double* %70, i64 4
%72 = load double, double* %71
%73 = call double @sin(double %72)
%74 = fneg double %69
%75 = call double @llvm.fmuladd.f64(double %74, double %73, double %68)
%76 = load double*, double** %4
%77 = getelementptr inbounds double, double* %76, i64 3
store double %75, double* %77
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"ellipse_foci: invalid input ellipse.\00"
@.str.1 = [39 x i8] c"ellipse_foci: 'foci' must be non null.\00"
define void @ellipse_foci(double* %0, double* writeonly %1) {
%3 = icmp eq double* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = icmp eq double* %1, null
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 3
%14 = load double, double* %13
%15 = fneg double %14
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %16)
%18 = tail call double @sqrt(double %17)
%19 = load double, double* %0
%20 = getelementptr inbounds double, double* %0, i64 4
%21 = load double, double* %20
%22 = tail call double @cos(double %21)
%23 = tail call double @llvm.fmuladd.f64(double %18, double %22, double %19)
store double %23, double* %1
%24 = getelementptr inbounds double, double* %0, i64 1
%25 = load double, double* %24
%26 = load double, double* %20
%27 = tail call double @sin(double %26)
%28 = tail call double @llvm.fmuladd.f64(double %18, double %27, double %25)
%29 = getelementptr inbounds double, double* %1, i64 1
store double %28, double* %29
%30 = load double, double* %0
%31 = load double, double* %20
%32 = tail call double @cos(double %31)
%33 = fneg double %18
%34 = tail call double @llvm.fmuladd.f64(double %33, double %32, double %30)
%35 = getelementptr inbounds double, double* %1, i64 2
store double %34, double* %35
%36 = load double, double* %24
%37 = load double, double* %20
%38 = tail call double @sin(double %37)
%39 = tail call double @llvm.fmuladd.f64(double %33, double %38, double %36)
%40 = getelementptr inbounds double, double* %1, i64 3
store double %39, double* %40
ret void
}