#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 truncfarray(float *in, size_t size, float low, float high) {
  float *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):
<truncfarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    117b <truncfarray+0x6b>
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11a3 <truncfarray+0x93>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    119e <truncfarray+0x8e>
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11a3 <truncfarray+0x93>
jmp    11a8 <truncfarray+0x98>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
cmp    -0x20(%rbp),%rax
jb     1157 <truncfarray+0x47>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncfarray>:
push   %r14
push   %rbx
push   %rax
movss  %xmm1,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
movss  %xmm0,0x4(%rsp)
ucomiss %xmm0,%xmm1
seta   %dil
call   1030 <assert@plt>
movss  (%rsp),%xmm2
lea    (%rbx,%r14,4),%rax
jmp    114d <truncfarray+0x3d>
xchg   %ax,%ax
movss  %xmm0,(%rbx)
add    $0x4,%rbx
cmp    %rax,%rbx
jae    1166 <truncfarray+0x56>
movss  (%rbx),%xmm1
ucomiss %xmm2,%xmm1
movaps %xmm2,%xmm0
ja     1140 <truncfarray+0x30>
movss  0x4(%rsp),%xmm0
ucomiss %xmm1,%xmm0
ja     1140 <truncfarray+0x30>
jmp    1144 <truncfarray+0x34>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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