#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 norm(double const *, int);
extern int normv3(const double *a, double *b) {
  double r;
  if ((r = norm(a, 3)) <= 0.0)
    return 0;
  b[0] = a[0] / r;
  b[1] = a[1] / r;
  b[2] = a[2] / r;
  return 1;
}


x86 assembly (clang, -O0):
<normv3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1030 <norm@plt>
movaps %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     114f <normv3+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    1199 <normv3+0x89>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normv3>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x3,%esi
call   1030 <norm@plt>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1160 <normv3+0x50>
movsd  (%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @normv3(double* %0, double* nocapture writeonly %1) {
%3 = tail call double @norm(double* %0, i32 3)
%4 = fcmp ugt double %3, 0.000000e+00
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = load double, double* %0
%7 = fdiv double %6, %3
store double %7, double* %1
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = fdiv double %9, %3
%11 = getelementptr inbounds double, double* %1, i64 1
store double %10, double* %11
%12 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = fdiv double %13, %3
%15 = getelementptr inbounds double, double* %1, i64 2
store double %14, double* %15
br label %16
16: ; preds = %2, %5
%17 = phi i32 [ 1, %5 ], [ 0, %2 ]
ret i32 %17
}