#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);
unsigned long getnum(char const *);
int /*<<< orphan*/ mkrandtree_sub(unsigned int, int /*<<< orphan*/,
                                  unsigned int *, unsigned int);
int /*<<< orphan*/ op_sync();
int random();
int /*<<< orphan*/ rmrandtree_sub(int /*<<< orphan*/, unsigned int *,
                                  unsigned int);
int /*<<< orphan*/ srandom(unsigned long);
void wl_rmrandtree(const char *seed) {
  unsigned testcode = 157;
  unsigned long seednum = getnum(seed);
  unsigned numthings, numthings2, count;
  srandom(seednum);
  numthings = random() % 44 + 12;
  count = 0;
  mkrandtree_sub(testcode, 0, &count, numthings);
  op_sync();
  srandom(seednum);
  numthings2 = random() % 44 + 12;
  assert(numthings == numthings2);
  count = 0;
  rmrandtree_sub(0, &count, numthings);
}


x86 assembly (clang, -O0):
<wl_rmrandtree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x9d,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getnum@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1090 <random@plt>
mov    $0x2c,%ecx
cltd
idiv   %ecx
add    $0xc,%edx
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%ecx
xor    %esi,%esi
lea    -0x24(%rbp),%rdx
call   1060 <mkrandtree_sub@plt>
mov    $0x0,%al
call   1080 <op_sync@plt>
mov    -0x18(%rbp),%rdi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1090 <random@plt>
mov    $0x2c,%ecx
cltd
idiv   %ecx
add    $0xc,%edx
mov    %edx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%edx
xor    %edi,%edi
lea    -0x24(%rbp),%rsi
call   1050 <rmrandtree_sub@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wl_rmrandtree>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
call   1030 <getnum@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1090 <random@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
imul   $0x2c,%ecx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0xc,%r15d
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    $0x9d,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1060 <mkrandtree_sub@plt>
xor    %eax,%eax
call   1080 <op_sync@plt>
mov    %rbx,%rdi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1090 <random@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
imul   $0x2c,%ecx,%ecx
sub    %ecx,%eax
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1070 <assert@plt>
movl   $0x0,0x4(%rsp)
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <rmrandtree_sub@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @wl_rmrandtree(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i32 157, i32* %3
%8 = load i8*, i8** %2
%9 = call i64 @getnum(i8* %8)
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = call i32 @srandom(i64 %10)
%12 = call i32 (...) @random()
%13 = srem i32 %12, 44
%14 = add nsw i32 %13, 12
store i32 %14, i32* %5
store i32 0, i32* %7
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = call i32 @mkrandtree_sub(i32 %15, i32 0, i32* %7, i32 %16)
%18 = call i32 (...) @op_sync()
%19 = load i64, i64* %4
%20 = call i32 @srandom(i64 %19)
%21 = call i32 (...) @random()
%22 = srem i32 %21, 44
%23 = add nsw i32 %22, 12
store i32 %23, i32* %6
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = icmp eq i32 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
store i32 0, i32* %7
%29 = load i32, i32* %5
%30 = call i32 @rmrandtree_sub(i32 0, i32* %7, i32 %29)
ret void
}

LLVM IR (-O2):
define void @wl_rmrandtree(i8* %0) {
%2 = alloca i32
%3 = tail call i64 @getnum(i8* %0)
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @srandom(i64 %3)
%6 = tail call i32 (...) @random()
%7 = srem i32 %6, 44
%8 = add nsw i32 %7, 12
store i32 0, i32* %2
%9 = call i32 @mkrandtree_sub(i32 157, i32 0, i32* %2, i32 %8)
%10 = call i32 (...) @op_sync()
%11 = call i32 @srandom(i64 %3)
%12 = call i32 (...) @random()
%13 = srem i32 %12, 44
%14 = icmp eq i32 %7, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
store i32 0, i32* %2
%17 = call i32 @rmrandtree_sub(i32 0, i32* %2, i32 %8)
ret void
}