#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 length(float *);
void normalize4(float *v) {
  float d = length(v);
  if (d == 0)
    return;
  v[0] /= d;
  v[1] /= d;
  v[2] /= d;
  v[3] /= d;
}


x86 assembly (clang, -O0):
<normalize4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <length@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1146 <normalize4+0x36>
jp     1146 <normalize4+0x36>
jmp    11a0 <normalize4+0x90>
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x8(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0xc(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize4>:
push   %rbx
mov    %rdi,%rbx
call   1030 <length@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1125 <normalize4+0x15>
jp     1125 <normalize4+0x15>
pop    %rbx
ret
movups (%rbx),%xmm1
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm1
movups %xmm1,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @normalize4(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = call float @length(float* %4)
store float %5, float* %3
%6 = load float, float* %3
%7 = fcmp oeq float %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
br label %30
9: ; preds = %1
%10 = load float, float* %3
%11 = load float*, float** %2
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = fdiv float %13, %10
store float %14, float* %12
%15 = load float, float* %3
%16 = load float*, float** %2
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = fdiv float %18, %15
store float %19, float* %17
%20 = load float, float* %3
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
%24 = fdiv float %23, %20
store float %24, float* %22
%25 = load float, float* %3
%26 = load float*, float** %2
%27 = getelementptr inbounds float, float* %26, i64 3
%28 = load float, float* %27
%29 = fdiv float %28, %25
store float %29, float* %27
br label %30
30: ; preds = %9, %8
ret void
}

LLVM IR (-O2):
define void @normalize4(float* %0) {
%2 = tail call float @length(float* %0)
%3 = fcmp oeq float %2, 0.000000e+00
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = bitcast float* %0 to <4 x float>*
%6 = load <4 x float>, <4 x float>* %5
%7 = insertelement <4 x float> poison, float %2, i64 0
%8 = shufflevector <4 x float> %7, <4 x float> poison, <4 x i32> zeroinitializer
%9 = fdiv <4 x float> %6, %8
%10 = bitcast float* %0 to <4 x float>*
store <4 x float> %9, <4 x float>* %10
br label %11
11: ; preds = %1, %4
ret void
}