void trackball(float *q, float p1x, float p1y, float p2x, float p2y) {
  float a[3l];
  float phi;
  float p1[3l];
  float p2[3l];
  float d[3l];
  float t;
  if ((p1x == p2x)) {
    if ((p1y == p2y)) {
      vzero(q);
      q[(signed long int)3] = (float)1.000000;
      return;
    }
  }
  float return_value_tb_project_to_sphere$1;
  return_value_tb_project_to_sphere$1 =
      tb_project_to_sphere((float)8.000000e-1, p1x, p1y);
  vset(p1, p1x, p1y, return_value_tb_project_to_sphere$1);
  float return_value_tb_project_to_sphere$2;
  return_value_tb_project_to_sphere$2 =
      tb_project_to_sphere((float)8.000000e-1, p2x, p2y);
  vset(p2, p2x, p2y, return_value_tb_project_to_sphere$2);
  vcross(p2, p1, a);
  vsub(p1, p2, d);
  float return_value_vlength$3;
  return_value_vlength$3 = vlength(d);
  t = (float)((double)return_value_vlength$3 / (2.000000 * 8.000000e-1));
  if (t > 1.000000f)
    t = (float)1.000000;
  if (t < -1.000000f)
    t = (float)-1.000000;
  double return_value_asin$4;
  return_value_asin$4 = asin((double)t);
  phi = (float)(2.000000 * return_value_asin$4);
  axis_to_quat(a, phi, q);
}


x86 assembly (clang, -O0):
<trackball>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jne    11f0 <trackball+0x70>
jp     11f0 <trackball+0x70>
movss  -0x10(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    11eb <trackball+0x6b>
jp     11eb <trackball+0x6b>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   10a0 <vzero@plt>
mov    -0x8(%rbp),%rax
movss  0xe1f(%rip),%xmm0
movss  %xmm0,0xc(%rax)
jmp    136b <trackball+0x1eb>
jmp    11f0 <trackball+0x70>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xe06(%rip),%xmm0
mov    $0x3,%al
call   1030 <tb_project_to_sphere@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x54(%rbp)
lea    -0x34(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x54(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    $0x3,%al
call   1060 <vset@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xdb6(%rip),%xmm0
mov    $0x3,%al
call   1030 <tb_project_to_sphere@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x58(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    $0x3,%al
call   1060 <vset@plt>
lea    -0x40(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1090 <vcross@plt>
lea    -0x34(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
mov    $0x0,%al
call   1040 <vsub@plt>
lea    -0x4c(%rbp),%rdi
mov    $0x0,%al
call   1050 <vlength@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd2d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
movss  0xd0b(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    130b <trackball+0x18b>
movss  0xcfa(%rip),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  0xcf1(%rip),%xmm0
ucomiss -0x50(%rbp),%xmm0
jbe    132a <trackball+0x1aa>
movss  0xcdf(%rip),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1070 <asin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  0xcd3(%rip),%xmm0
mulsd  -0x68(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
lea    -0x24(%rbp),%rdi
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x8(%rbp),%rsi
mov    $0x1,%al
call   1080 <axis_to_quat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trackball>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%r12
ucomiss %xmm2,%xmm0
jne    11b6 <trackball+0x36>
jp     11b6 <trackball+0x36>
ucomiss %xmm3,%xmm1
jne    11b6 <trackball+0x36>
jp     11b6 <trackball+0x36>
mov    %r12,%rdi
xor    %eax,%eax
call   10a0 <vzero@plt>
movl   $0x3f800000,0xc(%r12)
80 3f
jmp    12f3 <trackball+0x173>
cvtss2sd %xmm0,%xmm4
movsd  %xmm4,0x18(%rsp)
cvtss2sd %xmm1,%xmm5
movsd  %xmm5,0x10(%rsp)
movsd  0xe2e(%rip),%xmm0
movaps %xmm4,%xmm1
movss  %xmm2,0x8(%rsp)
movaps %xmm5,%xmm2
mov    $0x3,%al
movss  %xmm3,(%rsp)
call   1030 <tb_project_to_sphere@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
lea    0x38(%rsp),%r15
mov    %r15,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x3,%al
call   1060 <vset@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movss  (%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movsd  0xdc1(%rip),%xmm0
mov    $0x3,%al
call   1030 <tb_project_to_sphere@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
lea    0x2c(%rsp),%r13
mov    %r13,%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x3,%al
call   1060 <vset@plt>
lea    0x44(%rsp),%r14
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <vcross@plt>
lea    0x20(%rsp),%rbx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <vsub@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <vlength@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xd53(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xd4f(%rip),%xmm1
minss  %xmm0,%xmm1
movss  0xd47(%rip),%xmm0
maxss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1070 <asin@plt>
addsd  %xmm0,%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1080 <axis_to_quat@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @trackball(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca [3 x float]
%12 = alloca float
%13 = alloca [3 x float]
%14 = alloca [3 x float]
%15 = alloca [3 x float]
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca double
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%21 = load float, float* %7
%22 = load float, float* %9
%23 = fcmp oeq float %21, %22
br i1 %23, label %24, label %34
24: ; preds = %5
%25 = load float, float* %8
%26 = load float, float* %10
%27 = fcmp oeq float %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load float*, float** %6
%30 = call i32 (float*, ...) bitcast (i32 (...)* @vzero to i32 (float*, ...)*)(float* %29)
%31 = load float*, float** %6
%32 = getelementptr inbounds float, float* %31, i64 3
store float 1.000000e+00, float* %32
br label %97
33: ; preds = %24
br label %34
34: ; preds = %33, %5
%35 = load float, float* %7
%36 = fpext float %35 to double
%37 = load float, float* %8
%38 = fpext float %37 to double
%39 = call i32 (double, double, double, ...) bitcast (i32 (...)* @tb_project_to_sphere to i32 (double, double, double, ...)*)(double 0x3FE99999A0000000, double %36, double %38)
%40 = sitofp i32 %39 to float
store float %40, float* %17
%41 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%42 = load float, float* %7
%43 = fpext float %42 to double
%44 = load float, float* %8
%45 = fpext float %44 to double
%46 = load float, float* %17
%47 = fpext float %46 to double
%48 = call i32 (float*, double, double, double, ...) bitcast (i32 (...)* @vset to i32 (float*, double, double, double, ...)*)(float* %41, double %43, double %45, double %47)
%49 = load float, float* %9
%50 = fpext float %49 to double
%51 = load float, float* %10
%52 = fpext float %51 to double
%53 = call i32 (double, double, double, ...) bitcast (i32 (...)* @tb_project_to_sphere to i32 (double, double, double, ...)*)(double 0x3FE99999A0000000, double %50, double %52)
%54 = sitofp i32 %53 to float
store float %54, float* %18
%55 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%56 = load float, float* %9
%57 = fpext float %56 to double
%58 = load float, float* %10
%59 = fpext float %58 to double
%60 = load float, float* %18
%61 = fpext float %60 to double
%62 = call i32 (float*, double, double, double, ...) bitcast (i32 (...)* @vset to i32 (float*, double, double, double, ...)*)(float* %55, double %57, double %59, double %61)
%63 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%64 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%65 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%66 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vcross to i32 (float*, float*, float*, ...)*)(float* %63, float* %64, float* %65)
%67 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%68 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%69 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%70 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vsub to i32 (float*, float*, float*, ...)*)(float* %67, float* %68, float* %69)
%71 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%72 = call i32 (float*, ...) bitcast (i32 (...)* @vlength to i32 (float*, ...)*)(float* %71)
%73 = sitofp i32 %72 to float
store float %73, float* %19
%74 = load float, float* %19
%75 = fpext float %74 to double
%76 = fdiv double %75, 1.600000e+00
%77 = fptrunc double %76 to float
store float %77, float* %16
%78 = load float, float* %16
%79 = fcmp ogt float %78, 1.000000e+00
br i1 %79, label %80, label %81
80: ; preds = %34
store float 1.000000e+00, float* %16
br label %81
81: ; preds = %80, %34
%82 = load float, float* %16
%83 = fcmp olt float %82, -1.000000e+00
br i1 %83, label %84, label %85
84: ; preds = %81
store float -1.000000e+00, float* %16
br label %85
85: ; preds = %84, %81
%86 = load float, float* %16
%87 = fpext float %86 to double
%88 = call double @asin(double %87)
store double %88, double* %20
%89 = load double, double* %20
%90 = fmul double 2.000000e+00, %89
%91 = fptrunc double %90 to float
store float %91, float* %12
%92 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%93 = load float, float* %12
%94 = fpext float %93 to double
%95 = load float*, float** %6
%96 = call i32 (float*, double, float*, ...) bitcast (i32 (...)* @axis_to_quat to i32 (float*, double, float*, ...)*)(float* %92, double %94, float* %95)
br label %97
97: ; preds = %85, %28
ret void
}

LLVM IR (-O2):
define void @trackball(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = bitcast [3 x float]* %6 to i8*
%11 = bitcast [3 x float]* %7 to i8*
%12 = bitcast [3 x float]* %8 to i8*
%13 = bitcast [3 x float]* %9 to i8*
%14 = fcmp oeq float %1, %3
%15 = fcmp oeq float %2, %4
%16 = and i1 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %5
%18 = tail call i32 (float*, ...) bitcast (i32 (...)* @vzero to i32 (float*, ...)*)(float* %0)
%19 = getelementptr inbounds float, float* %0, i64 3
store float 1.000000e+00, float* %19
br label %54
20: ; preds = %5
%21 = fpext float %1 to double
%22 = fpext float %2 to double
%23 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @tb_project_to_sphere to i32 (double, double, double, ...)*)(double 0x3FE99999A0000000, double %21, double %22)
%24 = sitofp i32 %23 to float
%25 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%26 = fpext float %24 to double
%27 = call i32 (float*, double, double, double, ...) bitcast (i32 (...)* @vset to i32 (float*, double, double, double, ...)*)(float* %25, double %21, double %22, double %26)
%28 = fpext float %3 to double
%29 = fpext float %4 to double
%30 = call i32 (double, double, double, ...) bitcast (i32 (...)* @tb_project_to_sphere to i32 (double, double, double, ...)*)(double 0x3FE99999A0000000, double %28, double %29)
%31 = sitofp i32 %30 to float
%32 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%33 = fpext float %31 to double
%34 = call i32 (float*, double, double, double, ...) bitcast (i32 (...)* @vset to i32 (float*, double, double, double, ...)*)(float* %32, double %28, double %29, double %33)
%35 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%36 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vcross to i32 (float*, float*, float*, ...)*)(float* %32, float* %25, float* %35)
%37 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%38 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vsub to i32 (float*, float*, float*, ...)*)(float* %25, float* %32, float* %37)
%39 = call i32 (float*, ...) bitcast (i32 (...)* @vlength to i32 (float*, ...)*)(float* %37)
%40 = sitofp i32 %39 to float
%41 = fpext float %40 to double
%42 = fdiv double %41, 1.600000e+00
%43 = fptrunc double %42 to float
%44 = fcmp ogt float %43, 1.000000e+00
%45 = select i1 %44, float 1.000000e+00, float %43
%46 = fcmp olt float %45, -1.000000e+00
%47 = select i1 %46, float -1.000000e+00, float %45
%48 = fpext float %47 to double
%49 = call double @asin(double %48)
%50 = fmul double %49, 2.000000e+00
%51 = fptrunc double %50 to float
%52 = fpext float %51 to double
%53 = call i32 (float*, double, float*, ...) bitcast (i32 (...)* @axis_to_quat to i32 (float*, double, float*, ...)*)(float* %35, double %52, float* %0)
br label %54
54: ; preds = %20, %17
ret void
}