#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 */
int /*<<< orphan*/ AT_histo_sum(long const, double const, double const,
                                long const, double *, double *);
int /*<<< orphan*/ assert(int);
void AT_histo_normalize(const long number_of_bins,
                        const double lowest_left_limit, const double step,
                        const long histo_type, double frequency[]) {
  double sum;
  AT_histo_sum(number_of_bins, lowest_left_limit, step, histo_type, frequency,
               &sum);
  assert(sum > 0.0);
  long i;
  for (i = 0; i < number_of_bins; i++) {
    frequency[i] /= sum;
  }
}


x86 assembly (clang, -O0):
<AT_histo_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1030 <AT_histo_sum@plt>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11b8 <AT_histo_normalize+0x98>
movsd  -0x30(%rbp),%xmm1
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    117e <AT_histo_normalize+0x5e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AT_histo_normalize>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsp,%rcx
call   1030 <AT_histo_sum@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
xor    %edi,%edi
ucomisd %xmm1,%xmm0
seta   %dil
call   1040 <assert@plt>
test   %r14,%r14
jle    11e7 <AT_histo_normalize+0xc7>
movsd  (%rsp),%xmm0
cmp    $0x1,%r14
jne    1162 <AT_histo_normalize+0x42>
xor    %eax,%eax
jmp    11d0 <AT_histo_normalize+0xb0>
mov    %r14,%rax
and    $0xfffffffffffffffe,%rax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rax),%rdx
mov    %rdx,%rcx
shr    %rcx
add    $0x1,%rcx
test   %rdx,%rdx
je     11ef <AT_histo_normalize+0xcf>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edx,%edx
nopl   (%rax)
movupd (%rbx,%rdx,8),%xmm2
movupd 0x10(%rbx,%rdx,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rdx,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rsi
jne    1190 <AT_histo_normalize+0x70>
test   $0x1,%cl
je     11cb <AT_histo_normalize+0xab>
movupd (%rbx,%rdx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rdx,8)
cmp    %r14,%rax
je     11e7 <AT_histo_normalize+0xc7>
movsd  (%rbx,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r14
jne    11d0 <AT_histo_normalize+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %edx,%edx
test   $0x1,%cl
jne    11bd <AT_histo_normalize+0x9d>
jmp    11cb <AT_histo_normalize+0xab>

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

LLVM IR (-O2):
define void @AT_histo_normalize(i64 %0, double %1, double %2, i64 %3, double* %4) {
%6 = alloca double
%7 = bitcast double* %6 to i8*
%8 = call i32 @AT_histo_sum(i64 %0, double %1, double %2, i64 %3, double* %4, double* %6)
%9 = load double, double* %6
%10 = fcmp ogt double %9, 0.000000e+00
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = icmp sgt i64 %0, 0
br i1 %13, label %14, label %65
14: ; preds = %5
%15 = load double, double* %6
%16 = icmp eq i64 %0, 1
br i1 %16, label %56, label %17
17: ; preds = %14
%18 = and i64 %0, -2
%19 = insertelement <2 x double> poison, double %15, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = add i64 %18, -2
%22 = lshr exact i64 %21, 1
%23 = add nuw i64 %22, 1
%24 = and i64 %23, 1
%25 = icmp eq i64 %21, 0
br i1 %25, label %45, label %26
26: ; preds = %17
%27 = and i64 %23, -2
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %42, %28 ]
%30 = phi i64 [ 0, %26 ], [ %43, %28 ]
%31 = getelementptr inbounds double, double* %4, i64 %29
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = fdiv <2 x double> %33, %20
%35 = bitcast double* %31 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
%36 = or i64 %29, 2
%37 = getelementptr inbounds double, double* %4, i64 %36
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = fdiv <2 x double> %39, %20
%41 = bitcast double* %37 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = add nuw i64 %29, 4
%43 = add nuw i64 %30, 2
%44 = icmp eq i64 %43, %27
br i1 %44, label %45, label %28
45: ; preds = %28, %17
%46 = phi i64 [ 0, %17 ], [ %42, %28 ]
%47 = icmp eq i64 %24, 0
br i1 %47, label %54, label %48
48: ; preds = %45
%49 = getelementptr inbounds double, double* %4, i64 %46
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fdiv <2 x double> %51, %20
%53 = bitcast double* %49 to <2 x double>*
store <2 x double> %52, <2 x double>* %53
br label %54
54: ; preds = %45, %48
%55 = icmp eq i64 %18, %0
br i1 %55, label %65, label %56
56: ; preds = %14, %54
%57 = phi i64 [ 0, %14 ], [ %18, %54 ]
br label %58
58: ; preds = %56, %58
%59 = phi i64 [ %63, %58 ], [ %57, %56 ]
%60 = getelementptr inbounds double, double* %4, i64 %59
%61 = load double, double* %60
%62 = fdiv double %61, %15
store double %62, double* %60
%63 = add nuw nsw i64 %59, 1
%64 = icmp eq i64 %63, %0
br i1 %64, label %65, label %58
65: ; preds = %58, %54, %5
ret void
}