#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.0) ? -s : s);
  s = sqrtf(2.0f / 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
movss  0x8(%rax),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11ad <make_reflector+0x8d>
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11b7 <make_reflector+0x97>
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  0xe1a(%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 = fpext float %25 to double
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %2
%29 = load float, float* %5
%30 = fneg float %29
br label %33
31: ; preds = %2
%32 = load float, float* %5
br label %33
33: ; preds = %31, %28
%34 = phi float [ %30, %28 ], [ %32, %31 ]
%35 = fadd float %22, %34
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 2
store float %35, float* %37
%38 = load float*, float** %4
%39 = load float*, float** %4
%40 = call float @vdot(float* %38, float* %39)
%41 = fdiv float 2.000000e+00, %40
%42 = call float @sqrtf(float %41)
store float %42, float* %5
%43 = load float*, float** %4
%44 = getelementptr inbounds float, float* %43, i64 0
%45 = load float, float* %44
%46 = load float, float* %5
%47 = fmul float %45, %46
%48 = load float*, float** %4
%49 = getelementptr inbounds float, float* %48, i64 0
store float %47, float* %49
%50 = load float*, float** %4
%51 = getelementptr inbounds float, float* %50, i64 1
%52 = load float, float* %51
%53 = load float, float* %5
%54 = fmul float %52, %53
%55 = load float*, float** %4
%56 = getelementptr inbounds float, float* %55, i64 1
store float %54, float* %56
%57 = load float*, float** %4
%58 = getelementptr inbounds float, float* %57, i64 2
%59 = load float, float* %58
%60 = load float, float* %5
%61 = fmul float %59, %60
%62 = load float*, float** %4
%63 = getelementptr inbounds float, float* %62, i64 2
store float %61, float* %63
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
}