#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 dsnorm(double *);
int dsnize(double a[3]) {
  int k;
  double na;
  na = dsnorm(a);
  if (na <= 0.0)
    return (0);
  for (k = 0; k < 3; k++)
    a[k] = a[k] / na;
  return (1);
}


x86 assembly (clang, -O0):
<dsnize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <dsnorm@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1144 <dsnize+0x34>
movl   $0x0,-0x4(%rbp)
jmp    1189 <dsnize+0x79>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1182 <dsnize+0x72>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <dsnize+0x3b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsnize>:
push   %rbx
mov    %rdi,%rbx
call   1030 <dsnorm@plt>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    114c <dsnize+0x3c>
movupd (%rbx),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,(%rbx)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rbx)
mov    $0x1,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @dsnize(double* %0) {
%2 = tail call double @dsnorm(double* %0)
%3 = fcmp ugt double %2, 0.000000e+00
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = bitcast double* %0 to <2 x double>*
%6 = load <2 x double>, <2 x double>* %5
%7 = insertelement <2 x double> poison, double %2, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = fdiv <2 x double> %6, %8
%10 = bitcast double* %0 to <2 x double>*
store <2 x double> %9, <2 x double>* %10
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = fdiv double %12, %2
store double %13, double* %11
br label %14
14: ; preds = %4, %1
%15 = phi i32 [ 0, %1 ], [ 1, %4 ]
ret i32 %15
}