#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 */
float sqrtf(float);
float vdot(float *, float *);
void make_reflector(float *v, float *u) {
  float s = sqrtf(vdot(v, v));
  u[0] = v[0];
  u[1] = v[1];
  u[2] = v[2] + ((v[2] < 0.f) ? -s : s);
  s = sqrtf(2.f / vdot(u, u));
  u[0] = u[0] * s;
  u[1] = u[1] * s;
  u[2] = u[2] * s;
}


x86 assembly (clang, -O0):
<make_reflector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <vdot@plt>
call   1030 <sqrtf@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomiss 0x8(%rax),%xmm0
jbe    11a4 <make_reflector+0x84>
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11ae <make_reflector+0x8e>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vdot@plt>
movaps %xmm0,%xmm1
movss  0xe23(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_reflector>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%rsi
call   1040 <vdot@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1140 <make_reflector+0x20>
sqrtss %xmm0,%xmm0
jmp    1145 <make_reflector+0x25>
call   1030 <sqrtf@plt>
movss  (%r14),%xmm1
movss  %xmm1,(%rbx)
movss  0x4(%r14),%xmm1
movss  %xmm1,0x4(%rbx)
movss  0x8(%r14),%xmm1
movaps 0xe9a(%rip),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,%xmm3
xorps  %xmm4,%xmm4
cmpltss %xmm4,%xmm3
andps  %xmm3,%xmm2
andnps %xmm0,%xmm3
orps   %xmm2,%xmm3
addss  %xmm1,%xmm3
movss  %xmm3,0x8(%rbx)
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <vdot@plt>
movaps %xmm0,%xmm1
movss  0xe74(%rip),%xmm0
divss  %xmm1,%xmm0
ucomiss 0xe6d(%rip),%xmm0
jb     11af <make_reflector+0x8f>
sqrtss %xmm0,%xmm0
jmp    11b4 <make_reflector+0x94>
call   1030 <sqrtf@plt>
movss  (%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  0x4(%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rbx)
mulss  0x8(%rbx),%xmm0
movss  %xmm0,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @make_reflector(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %3
%7 = load float*, float** %3
%8 = call float @vdot(float* %6, float* %7)
%9 = call float @sqrtf(float %8)
store float %9, float* %5
%10 = load float*, float** %3
%11 = getelementptr inbounds float, float* %10, i64 0
%12 = load float, float* %11
%13 = load float*, float** %4
%14 = getelementptr inbounds float, float* %13, i64 0
store float %12, float* %14
%15 = load float*, float** %3
%16 = getelementptr inbounds float, float* %15, i64 1
%17 = load float, float* %16
%18 = load float*, float** %4
%19 = getelementptr inbounds float, float* %18, i64 1
store float %17, float* %19
%20 = load float*, float** %3
%21 = getelementptr inbounds float, float* %20, i64 2
%22 = load float, float* %21
%23 = load float*, float** %3
%24 = getelementptr inbounds float, float* %23, i64 2
%25 = load float, float* %24
%26 = fcmp olt float %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %2
%28 = load float, float* %5
%29 = fneg float %28
br label %32
30: ; preds = %2
%31 = load float, float* %5
br label %32
32: ; preds = %30, %27
%33 = phi float [ %29, %27 ], [ %31, %30 ]
%34 = fadd float %22, %33
%35 = load float*, float** %4
%36 = getelementptr inbounds float, float* %35, i64 2
store float %34, float* %36
%37 = load float*, float** %4
%38 = load float*, float** %4
%39 = call float @vdot(float* %37, float* %38)
%40 = fdiv float 2.000000e+00, %39
%41 = call float @sqrtf(float %40)
store float %41, float* %5
%42 = load float*, float** %4
%43 = getelementptr inbounds float, float* %42, i64 0
%44 = load float, float* %43
%45 = load float, float* %5
%46 = fmul float %44, %45
%47 = load float*, float** %4
%48 = getelementptr inbounds float, float* %47, i64 0
store float %46, float* %48
%49 = load float*, float** %4
%50 = getelementptr inbounds float, float* %49, i64 1
%51 = load float, float* %50
%52 = load float, float* %5
%53 = fmul float %51, %52
%54 = load float*, float** %4
%55 = getelementptr inbounds float, float* %54, i64 1
store float %53, float* %55
%56 = load float*, float** %4
%57 = getelementptr inbounds float, float* %56, i64 2
%58 = load float, float* %57
%59 = load float, float* %5
%60 = fmul float %58, %59
%61 = load float*, float** %4
%62 = getelementptr inbounds float, float* %61, i64 2
store float %60, float* %62
ret void
}

LLVM IR (-O2):
define void @make_reflector(float* %0, float* %1) {
%3 = tail call float @vdot(float* %0, float* %0)
%4 = tail call float @sqrtf(float %3)
%5 = load float, float* %0
store float %5, float* %1
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = getelementptr inbounds float, float* %1, i64 1
store float %7, float* %8
%9 = getelementptr inbounds float, float* %0, i64 2
%10 = load float, float* %9
%11 = fcmp olt float %10, 0.000000e+00
%12 = fneg float %4
%13 = select i1 %11, float %12, float %4
%14 = fadd float %10, %13
%15 = getelementptr inbounds float, float* %1, i64 2
store float %14, float* %15
%16 = tail call float @vdot(float* %1, float* %1)
%17 = fdiv float 2.000000e+00, %16
%18 = tail call float @sqrtf(float %17)
%19 = load float, float* %1
%20 = fmul float %18, %19
store float %20, float* %1
%21 = load float, float* %8
%22 = fmul float %18, %21
store float %22, float* %8
%23 = load float, float* %15
%24 = fmul float %18, %23
store float %24, float* %15
ret void
}