#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 rand_range(int /*<<< orphan*/, int);
char rand_percent(short percent) {
  return (rand_range(0, 99) <
          ((((100) < ((((percent) > (0)) ? (percent) : (0))))
                ? (100)
                : ((((percent) > (0)) ? (percent) : (0))))));
}


x86 assembly (clang, -O0):
<rand_percent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
xor    %edi,%edi
mov    $0x63,%esi
call   1030 <rand_range@plt>
mov    %eax,-0x8(%rbp)
movswl -0x2(%rbp),%eax
cmp    $0x0,%eax
jle    1147 <rand_percent+0x37>
movswl -0x2(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <rand_percent+0x41>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <rand_percent+0x41>
mov    -0xc(%rbp),%ecx
mov    $0x64,%eax
cmp    %ecx,%eax
jge    116e <rand_percent+0x5e>
mov    $0x64,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <rand_percent+0x87>
movswl -0x2(%rbp),%eax
cmp    $0x0,%eax
jle    1187 <rand_percent+0x77>
movswl -0x2(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <rand_percent+0x81>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <rand_percent+0x81>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
movsbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_percent>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x63,%esi
call   1030 <rand_range@plt>
test   %ebx,%ebx
cmovns %ebx,%ebp
cmp    $0x64,%ebp
mov    $0x64,%ecx
cmovb  %ebp,%ecx
cmp    %ecx,%eax
setl   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @rand_percent(i16 signext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = call i32 @rand_range(i32 0, i32 99)
%4 = load i16, i16* %2
%5 = sext i16 %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i16, i16* %2
%9 = sext i16 %8 to i32
br label %11
10: ; preds = %1
br label %11
11: ; preds = %10, %7
%12 = phi i32 [ %9, %7 ], [ 0, %10 ]
%13 = icmp slt i32 100, %12
br i1 %13, label %14, label %15
14: ; preds = %11
br label %25
15: ; preds = %11
%16 = load i16, i16* %2
%17 = sext i16 %16 to i32
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i16, i16* %2
%21 = sext i16 %20 to i32
br label %23
22: ; preds = %15
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 0, %22 ]
br label %25
25: ; preds = %23, %14
%26 = phi i32 [ 100, %14 ], [ %24, %23 ]
%27 = icmp slt i32 %3, %26
%28 = zext i1 %27 to i32
%29 = trunc i32 %28 to i8
ret i8 %29
}

LLVM IR (-O2):
define signext i8 @rand_percent(i16 signext %0) {
%2 = tail call i32 @rand_range(i32 0, i32 99)
%3 = sext i16 %0 to i32
%4 = icmp sgt i32 %3, 0
%5 = select i1 %4, i32 %3, i32 0
%6 = icmp ult i32 %5, 100
%7 = select i1 %6, i32 %5, i32 100
%8 = icmp slt i32 %2, %7
%9 = zext i1 %8 to i8
ret i8 %9
}