#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_normal(int /*<<< orphan*/, int);
int Rand_sample(int mean, int upper, int lower, int stand_u, int stand_l) {
  int pick = Rand_normal(0, 1000);
  if (pick > 0) {
    pick *= (upper - mean);
    pick /= (100 * stand_u);
  } else if (pick < 0) {
    pick *= (mean - lower);
    pick /= (100 * stand_l);
  }
  return mean + pick;
}


x86 assembly (clang, -O0):
<Rand_sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
xor    %edi,%edi
mov    $0x3e8,%esi
call   1030 <Rand_normal@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1160 <Rand_sample+0x50>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0x64,-0x10(%rbp),%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1189 <Rand_sample+0x79>
cmpl   $0x0,-0x18(%rbp)
jge    1184 <Rand_sample+0x74>
mov    -0x4(%rbp),%eax
sub    -0xc(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0x64,-0x14(%rbp),%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1189 <Rand_sample+0x79>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rand_sample>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %edi,%r12d
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x3e8,%esi
call   1030 <Rand_normal@plt>
test   %eax,%eax
jle    114c <Rand_sample+0x3c>
sub    %r12d,%ebp
imul   %ebp,%eax
imul   $0x64,%r14d,%ecx
cltd
idiv   %ecx
mov    %eax,%ebx
jmp    114e <Rand_sample+0x3e>
js     1162 <Rand_sample+0x52>
add    %r12d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12d,%ebp
sub    %r13d,%ebp
mov    %r15d,%r14d
jmp    113e <Rand_sample+0x2e>

LLVM IR (-O0):
define i32 @Rand_sample(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = call i32 @Rand_normal(i32 0, i32 1000)
store i32 %12, i32* %11
%13 = load i32, i32* %11
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %5
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = sub nsw i32 %16, %17
%19 = load i32, i32* %11
%20 = mul nsw i32 %19, %18
store i32 %20, i32* %11
%21 = load i32, i32* %9
%22 = mul nsw i32 100, %21
%23 = load i32, i32* %11
%24 = sdiv i32 %23, %22
store i32 %24, i32* %11
br label %39
25: ; preds = %5
%26 = load i32, i32* %11
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = sub nsw i32 %29, %30
%32 = load i32, i32* %11
%33 = mul nsw i32 %32, %31
store i32 %33, i32* %11
%34 = load i32, i32* %10
%35 = mul nsw i32 100, %34
%36 = load i32, i32* %11
%37 = sdiv i32 %36, %35
store i32 %37, i32* %11
br label %38
38: ; preds = %28, %25
br label %39
39: ; preds = %38, %15
%40 = load i32, i32* %6
%41 = load i32, i32* %11
%42 = add nsw i32 %40, %41
ret i32 %42
}

LLVM IR (-O2):
define i32 @Rand_sample(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @Rand_normal(i32 0, i32 1000)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = sub nsw i32 %1, %0
br label %14
10: ; preds = %5
%11 = icmp slt i32 %6, 0
br i1 %11, label %12, label %20
12: ; preds = %10
%13 = sub nsw i32 %0, %2
br label %14
14: ; preds = %8, %12
%15 = phi i32 [ %13, %12 ], [ %9, %8 ]
%16 = phi i32 [ %4, %12 ], [ %3, %8 ]
%17 = mul nsw i32 %6, %15
%18 = mul nsw i32 %16, 100
%19 = sdiv i32 %17, %18
br label %20
20: ; preds = %14, %10
%21 = phi i32 [ 0, %10 ], [ %19, %14 ]
%22 = add nsw i32 %21, %0
ret i32 %22
}