#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 hypot2_sqr(double, double);
double sqrt(double);
double transcross2(const double origin[2], const double a[2], const double b[2],
                   int normalize) {
  double u[2], v[2];
  u[0] = a[0] - origin[0];
  u[1] = a[1] - origin[1];
  v[0] = b[0] - origin[0];
  v[1] = b[1] - origin[1];
  double norm = 1.0;
  if (normalize) {
    double u2 = hypot2_sqr(u[0], u[1]);
    double v2 = hypot2_sqr(v[0], v[1]);
    norm = sqrt(u2 * v2);
  }
  return (u[0] * v[1] - u[1] * v[0]) / norm;
}


x86 assembly (clang, -O0):
<transcross2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11e2 <transcross2+0xc2>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <hypot2_sqr@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <hypot2_sqr@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transcross2>:
sub    $0x28,%rsp
movsd  (%rsi),%xmm2
movsd  0x8(%rsi),%xmm1
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm3
subsd  %xmm0,%xmm2
subsd  %xmm3,%xmm1
movsd  (%rdx),%xmm4
movsd  0x8(%rdx),%xmm5
subsd  %xmm0,%xmm4
subsd  %xmm3,%xmm5
test   %ecx,%ecx
je     119f <transcross2+0x7f>
movsd  %xmm2,0x18(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
movsd  %xmm5,(%rsp)
call   1040 <hypot2_sqr@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1040 <hypot2_sqr@plt>
mulsd  0x20(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a9 <transcross2+0x89>
sqrtsd %xmm0,%xmm0
jmp    11ae <transcross2+0x8e>
movsd  0xe59(%rip),%xmm0
jmp    11c5 <transcross2+0xa5>
call   1030 <sqrt@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm4
movsd  (%rsp),%xmm5
mulsd  %xmm1,%xmm4
mulsd  %xmm5,%xmm2
subsd  %xmm4,%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @transcross2(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = load double, double* %1
%6 = load double, double* %0
%7 = fsub double %5, %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = load double, double* %2
%14 = fsub double %13, %6
%15 = getelementptr inbounds double, double* %2, i64 1
%16 = load double, double* %15
%17 = fsub double %16, %11
%18 = icmp eq i32 %3, 0
br i1 %18, label %24, label %19
19: ; preds = %4
%20 = tail call double @hypot2_sqr(double %7, double %12)
%21 = tail call double @hypot2_sqr(double %14, double %17)
%22 = fmul double %20, %21
%23 = tail call double @sqrt(double %22)
br label %24
24: ; preds = %19, %4
%25 = phi double [ %23, %19 ], [ 1.000000e+00, %4 ]
%26 = fneg double %12
%27 = fmul double %14, %26
%28 = tail call double @llvm.fmuladd.f64(double %7, double %17, double %27)
%29 = fdiv double %28, %25
ret double %29
}