#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 truncucarray(unsigned char *in, size_t size, unsigned char low,
                  unsigned char high) {
  unsigned char *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):
<truncucarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
movzbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jle    116e <truncucarray+0x5e>
mov    -0x12(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    118f <truncucarray+0x7f>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
movzbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jge    118a <truncucarray+0x7a>
mov    -0x11(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    118f <truncucarray+0x7f>
jmp    1194 <truncucarray+0x84>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
cmp    -0x20(%rbp),%rax
jb     114d <truncucarray+0x3d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncucarray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %edi,%edi
cmp    %bl,%r14b
setb   %dil
call   1030 <assert@plt>
add    %rbp,%r15
jmp    114c <truncucarray+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,0x0(%rbp)
add    $0x1,%rbp
cmp    %r15,%rbp
jae    1160 <truncucarray+0x50>
movzbl 0x0(%rbp),%ecx
mov    %ebx,%eax
cmp    %bl,%cl
ja     1140 <truncucarray+0x30>
mov    %r14d,%eax
cmp    %r14b,%cl
jb     1140 <truncucarray+0x30>
jmp    1143 <truncucarray+0x33>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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