#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*/ Util_in_range(double const, double const, double);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void Util_normalize(double *set, const int n, const double upper,
                    const double min, const double max) {
  int i;
  for (i = 0; i < n; i++) {
    assert(Util_in_range(min, max, set[i]));
    set[i] = upper * ((set[i] - min) / (max - min));
  }
}


x86 assembly (clang, -O0):
<Util_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b8 <Util_normalize+0x98>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
call   1030 <Util_in_range@plt>
mov    %eax,%edi
call   1040 <assert@plt>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1145 <Util_normalize+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Util_normalize>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
test   %esi,%esi
jle    11a7 <Util_normalize+0x87>
mov    %rdi,%r15
movsd  0x8(%rsp),%xmm1
subsd  (%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %esi,%r14d
xor    %ebx,%ebx
movsd  %xmm0,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm2
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <Util_in_range@plt>
mov    %eax,%edi
call   1040 <assert@plt>
movsd  0x18(%rsp),%xmm0
movsd  (%r15,%rbx,8),%xmm1
subsd  (%rsp),%xmm1
divsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <Util_normalize+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @Util_normalize(double* nocapture %0, i32 %1, double %2, double %3, double %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = fsub double %4, %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %20, %10 ]
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = tail call i32 @Util_in_range(double %3, double %4, double %13)
%15 = tail call i32 @assert(i32 %14)
%16 = load double, double* %12
%17 = fsub double %16, %3
%18 = fdiv double %17, %8
%19 = fmul double %18, %2
store double %19, double* %12
%20 = add nuw nsw i64 %11, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %22, label %10
22: ; preds = %10, %5
ret void
}