#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*/ assert(int);
void truncdarray(double *in, size_t size, double low, double high) {
  double *fpt;
  {
    assert(low < high);
    fpt = in + size;
    do {
      if (*in > high)
        *in = high;
      else if (*in < low)
        *in = low;
    } while (++in < fpt);
  }
}


x86 assembly (clang, -O0):
<truncdarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    117d <truncdarray+0x6d>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11a6 <truncdarray+0x96>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a1 <truncdarray+0x91>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11a6 <truncdarray+0x96>
jmp    11ab <truncdarray+0x9b>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
cmp    -0x28(%rbp),%rax
jb     1158 <truncdarray+0x48>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncdarray>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
movsd  %xmm0,0x10(%rsp)
ucomisd %xmm0,%xmm1
seta   %dil
call   1030 <assert@plt>
movsd  0x8(%rsp),%xmm2
lea    (%rbx,%r14,8),%rax
jmp    115d <truncdarray+0x4d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
cmp    %rax,%rbx
jae    1179 <truncdarray+0x69>
movsd  (%rbx),%xmm1
ucomisd %xmm2,%xmm1
movapd %xmm2,%xmm0
ja     1150 <truncdarray+0x40>
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
ja     1150 <truncdarray+0x40>
jmp    1154 <truncdarray+0x44>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @truncdarray(double* %0, i64 %1, double %2, double %3) {
%5 = fcmp olt double %2, %3
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds double, double* %0, i64 %1
br label %9
9: ; preds = %17, %4
%10 = phi double* [ %0, %4 ], [ %18, %17 ]
%11 = load double, double* %10
%12 = fcmp ogt double %11, %3
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = fcmp olt double %11, %2
br i1 %14, label %15, label %17
15: ; preds = %13, %9
%16 = phi double [ %3, %9 ], [ %2, %13 ]
store double %16, double* %10
br label %17
17: ; preds = %15, %13
%18 = getelementptr inbounds double, double* %10, i64 1
%19 = icmp ult double* %18, %8
br i1 %19, label %9, label %20
20: ; preds = %17
ret void
}