#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 DSum(double *, int);
void DNorm(double *vec, int n) {
  int x;
  double sum;
  sum = DSum(vec, n);
  if (sum != 0.0)
    for (x = 0; x < n; x++)
      vec[x] /= sum;
  else
    for (x = 0; x < n; x++)
      vec[x] = 1. / (double)n;
}


x86 assembly (clang, -O0):
<DNorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <DSum@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114d <DNorm+0x3d>
jp     114d <DNorm+0x3d>
jmp    118e <DNorm+0x7e>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1189 <DNorm+0x79>
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <DNorm+0x44>
jmp    11d2 <DNorm+0xc2>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <DNorm+0xbd>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe52(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1195 <DNorm+0x85>
jmp    11d2 <DNorm+0xc2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DNorm>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <DSum@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1129 <DNorm+0x19>
jnp    113f <DNorm+0x2f>
test   %ebp,%ebp
jle    131e <DNorm+0x20e>
mov    %ebp,%eax
cmp    $0x1,%ebp
jne    116c <DNorm+0x5c>
xor    %ecx,%ecx
jmp    11f0 <DNorm+0xe0>
test   %ebp,%ebp
jle    131e <DNorm+0x20e>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  0xeaa(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    %ebp,%eax
cmp    $0x4,%ebp
jae    120c <DNorm+0xfc>
xor    %ecx,%ecx
jmp    1310 <DNorm+0x200>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rcx),%rsi
mov    %rsi,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     123a <DNorm+0x12a>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   0x0(%rax)
movupd (%rbx,%rsi,8),%xmm2
movupd 0x10(%rbx,%rsi,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdi
jne    11a0 <DNorm+0x90>
test   $0x1,%dl
je     11db <DNorm+0xcb>
movupd (%rbx,%rsi,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
cmp    %rax,%rcx
je     131e <DNorm+0x20e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rcx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11f0 <DNorm+0xe0>
jmp    131e <DNorm+0x20e>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x7,%edx
cmp    $0x1c,%rdi
jae    1243 <DNorm+0x133>
xor    %edi,%edi
jmp    12d5 <DNorm+0x1c5>
xor    %esi,%esi
test   $0x1,%dl
jne    11cd <DNorm+0xbd>
jmp    11db <DNorm+0xcb>
and    $0xfffffffffffffff8,%rsi
xor    %edi,%edi
nopl   0x0(%rax)
movupd %xmm1,(%rbx,%rdi,8)
movupd %xmm1,0x10(%rbx,%rdi,8)
movupd %xmm1,0x20(%rbx,%rdi,8)
movupd %xmm1,0x30(%rbx,%rdi,8)
movupd %xmm1,0x40(%rbx,%rdi,8)
movupd %xmm1,0x50(%rbx,%rdi,8)
movupd %xmm1,0x60(%rbx,%rdi,8)
movupd %xmm1,0x70(%rbx,%rdi,8)
movupd %xmm1,0x80(%rbx,%rdi,8)
movupd %xmm1,0x90(%rbx,%rdi,8)
movupd %xmm1,0xa0(%rbx,%rdi,8)
movupd %xmm1,0xb0(%rbx,%rdi,8)
movupd %xmm1,0xc0(%rbx,%rdi,8)
movupd %xmm1,0xd0(%rbx,%rdi,8)
movupd %xmm1,0xe0(%rbx,%rdi,8)
movupd %xmm1,0xf0(%rbx,%rdi,8)
add    $0x20,%rdi
add    $0xfffffffffffffff8,%rsi
jne    1250 <DNorm+0x140>
test   %rdx,%rdx
je     1304 <DNorm+0x1f4>
lea    (%rbx,%rdi,8),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
movupd %xmm1,-0x10(%rsi,%rdi,1)
movupd %xmm1,(%rsi,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    12f0 <DNorm+0x1e0>
cmp    %rax,%rcx
je     131e <DNorm+0x20e>
nopl   0x0(%rax)
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1310 <DNorm+0x200>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @DNorm(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load double*, double** %3
%8 = load i32, i32* %4
%9 = call double @DSum(double* %7, i32 %8)
store double %9, double* %6
%10 = load double, double* %6
%11 = fcmp une double %10, 0.000000e+00
br i1 %11, label %12, label %29
12: ; preds = %2
store i32 0, i32* %5
br label %13
13: ; preds = %25, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load double, double* %6
%19 = load double*, double** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = fdiv double %23, %18
store double %24, double* %22
br label %25
25: ; preds = %17
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %13
28: ; preds = %13
br label %46
29: ; preds = %2
store i32 0, i32* %5
br label %30
30: ; preds = %42, %29
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = load i32, i32* %4
%36 = sitofp i32 %35 to double
%37 = fdiv double 1.000000e+00, %36
%38 = load double*, double** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %34
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %30
45: ; preds = %30
br label %46
46: ; preds = %45, %28
ret void
}

LLVM IR (-O2):
define void @DNorm(double* %0, i32 %1) {
%3 = tail call double @DSum(double* %0, i32 %1)
%4 = fcmp une double %3, 0.000000e+00
%5 = icmp sgt i32 %1, 0
br i1 %4, label %87, label %6
6: ; preds = %2
br i1 %5, label %7, label %144
7: ; preds = %6
%8 = sitofp i32 %1 to double
%9 = fdiv double 1.000000e+00, %8
%10 = zext i32 %1 to i64
%11 = icmp ult i32 %1, 4
br i1 %11, label %85, label %12
12: ; preds = %7
%13 = and i64 %10, 4294967292
%14 = insertelement <2 x double> poison, double %9, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = insertelement <2 x double> poison, double %9, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = add nsw i64 %13, -4
%19 = lshr exact i64 %18, 2
%20 = add nuw nsw i64 %19, 1
%21 = and i64 %20, 7
%22 = icmp ult i64 %18, 28
br i1 %22, label %70, label %23
23: ; preds = %12
%24 = and i64 %20, 9223372036854775800
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %67, %25 ]
%27 = phi i64 [ 0, %23 ], [ %68, %25 ]
%28 = getelementptr inbounds double, double* %0, i64 %26
%29 = bitcast double* %28 to <2 x double>*
store <2 x double> %15, <2 x double>* %29
%30 = getelementptr inbounds double, double* %28, i64 2
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %17, <2 x double>* %31
%32 = or i64 %26, 4
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> %15, <2 x double>* %34
%35 = getelementptr inbounds double, double* %33, i64 2
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> %17, <2 x double>* %36
%37 = or i64 %26, 8
%38 = getelementptr inbounds double, double* %0, i64 %37
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> %15, <2 x double>* %39
%40 = getelementptr inbounds double, double* %38, i64 2
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %17, <2 x double>* %41
%42 = or i64 %26, 12
%43 = getelementptr inbounds double, double* %0, i64 %42
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %15, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %17, <2 x double>* %46
%47 = or i64 %26, 16
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %15, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %17, <2 x double>* %51
%52 = or i64 %26, 20
%53 = getelementptr inbounds double, double* %0, i64 %52
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %15, <2 x double>* %54
%55 = getelementptr inbounds double, double* %53, i64 2
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %17, <2 x double>* %56
%57 = or i64 %26, 24
%58 = getelementptr inbounds double, double* %0, i64 %57
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %15, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %17, <2 x double>* %61
%62 = or i64 %26, 28
%63 = getelementptr inbounds double, double* %0, i64 %62
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %15, <2 x double>* %64
%65 = getelementptr inbounds double, double* %63, i64 2
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> %17, <2 x double>* %66
%67 = add nuw i64 %26, 32
%68 = add i64 %27, 8
%69 = icmp eq i64 %68, %24
br i1 %69, label %70, label %25
70: ; preds = %25, %12
%71 = phi i64 [ 0, %12 ], [ %67, %25 ]
%72 = icmp eq i64 %21, 0
br i1 %72, label %83, label %73
73: ; preds = %70, %73
%74 = phi i64 [ %80, %73 ], [ %71, %70 ]
%75 = phi i64 [ %81, %73 ], [ 0, %70 ]
%76 = getelementptr inbounds double, double* %0, i64 %74
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> %15, <2 x double>* %77
%78 = getelementptr inbounds double, double* %76, i64 2
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %17, <2 x double>* %79
%80 = add nuw i64 %74, 4
%81 = add i64 %75, 1
%82 = icmp eq i64 %81, %21
br i1 %82, label %83, label %73
83: ; preds = %73, %70
%84 = icmp eq i64 %13, %10
br i1 %84, label %144, label %85
85: ; preds = %7, %83
%86 = phi i64 [ 0, %7 ], [ %13, %83 ]
br label %139
87: ; preds = %2
br i1 %5, label %88, label %144
88: ; preds = %87
%89 = zext i32 %1 to i64
%90 = icmp eq i32 %1, 1
br i1 %90, label %130, label %91
91: ; preds = %88
%92 = and i64 %89, 4294967294
%93 = insertelement <2 x double> poison, double %3, i64 0
%94 = shufflevector <2 x double> %93, <2 x double> poison, <2 x i32> zeroinitializer
%95 = add nsw i64 %92, -2
%96 = lshr exact i64 %95, 1
%97 = add nuw i64 %96, 1
%98 = and i64 %97, 1
%99 = icmp eq i64 %95, 0
br i1 %99, label %119, label %100
100: ; preds = %91
%101 = and i64 %97, -2
br label %102
102: ; preds = %102, %100
%103 = phi i64 [ 0, %100 ], [ %116, %102 ]
%104 = phi i64 [ 0, %100 ], [ %117, %102 ]
%105 = getelementptr inbounds double, double* %0, i64 %103
%106 = bitcast double* %105 to <2 x double>*
%107 = load <2 x double>, <2 x double>* %106
%108 = fdiv <2 x double> %107, %94
%109 = bitcast double* %105 to <2 x double>*
store <2 x double> %108, <2 x double>* %109
%110 = or i64 %103, 2
%111 = getelementptr inbounds double, double* %0, i64 %110
%112 = bitcast double* %111 to <2 x double>*
%113 = load <2 x double>, <2 x double>* %112
%114 = fdiv <2 x double> %113, %94
%115 = bitcast double* %111 to <2 x double>*
store <2 x double> %114, <2 x double>* %115
%116 = add nuw i64 %103, 4
%117 = add nuw i64 %104, 2
%118 = icmp eq i64 %117, %101
br i1 %118, label %119, label %102
119: ; preds = %102, %91
%120 = phi i64 [ 0, %91 ], [ %116, %102 ]
%121 = icmp eq i64 %98, 0
br i1 %121, label %128, label %122
122: ; preds = %119
%123 = getelementptr inbounds double, double* %0, i64 %120
%124 = bitcast double* %123 to <2 x double>*
%125 = load <2 x double>, <2 x double>* %124
%126 = fdiv <2 x double> %125, %94
%127 = bitcast double* %123 to <2 x double>*
store <2 x double> %126, <2 x double>* %127
br label %128
128: ; preds = %119, %122
%129 = icmp eq i64 %92, %89
br i1 %129, label %144, label %130
130: ; preds = %88, %128
%131 = phi i64 [ 0, %88 ], [ %92, %128 ]
br label %132
132: ; preds = %130, %132
%133 = phi i64 [ %137, %132 ], [ %131, %130 ]
%134 = getelementptr inbounds double, double* %0, i64 %133
%135 = load double, double* %134
%136 = fdiv double %135, %3
store double %136, double* %134
%137 = add nuw nsw i64 %133, 1
%138 = icmp eq i64 %137, %89
br i1 %138, label %144, label %132
139: ; preds = %85, %139
%140 = phi i64 [ %142, %139 ], [ %86, %85 ]
%141 = getelementptr inbounds double, double* %0, i64 %140
store double %9, double* %141
%142 = add nuw nsw i64 %140, 1
%143 = icmp eq i64 %142, %10
br i1 %143, label %144, label %139
144: ; preds = %139, %132, %83, %128, %6, %87
ret void
}