#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 random();
int /*<<< orphan*/ random_init();
int random_level(void) {
  int i, level = 1;
  random_init();
  for (i = 1; i < 15; i++)
    if (random() % 2 == 1)
      level++;
  return level;
}


x86 assembly (clang, -O0):
<random_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1040 <random_init@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0xf,-0x4(%rbp)
jge    117b <random_level+0x5b>
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1168 <random_level+0x48>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <random_level+0x4d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113d <random_level+0x1d>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_level>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <random_init@plt>
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
add    %ebx,%ebp
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %r15d,%r15d
cmp    $0x1,%eax
sete   %r15b
add    %ebx,%r15d
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <random@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1030 <random@plt>
movd   0x4(%rsp),%xmm0
movd   (%rsp),%xmm1
punpckldq %xmm0,%xmm1
movd   %r12d,%xmm2
movd   %ebp,%xmm0
punpckldq %xmm2,%xmm0
punpcklqdq %xmm1,%xmm0
movd   %r13d,%xmm1
movd   %ebx,%xmm2
punpckldq %xmm1,%xmm2
movd   %r14d,%xmm3
movd   %eax,%xmm1
punpckldq %xmm3,%xmm1
punpcklqdq %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
paddd  %xmm1,%xmm2
psrad  $0x1,%xmm2
paddd  %xmm2,%xmm2
psubd  %xmm2,%xmm1
movdqa %xmm0,%xmm2
psrld  $0x1f,%xmm2
paddd  %xmm0,%xmm2
psrad  $0x1,%xmm2
paddd  %xmm2,%xmm2
psubd  %xmm2,%xmm0
movdqa 0xd57(%rip),%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%eax
mov    %eax,%ecx
shr    $0x7,%cl
movzbl %cl,%esi
add    %r15d,%esi
mov    %eax,%edi
and    $0x2,%dil
shr    %dil
mov    %eax,%r8d
and    $0x4,%r8b
shr    $0x2,%r8b
mov    %eax,%r9d
and    $0x8,%r9b
shr    $0x3,%r9b
mov    %eax,%ecx
and    $0x10,%cl
shr    $0x4,%cl
mov    %eax,%edx
and    $0x20,%dl
shr    $0x5,%dl
mov    %eax,%ebx
and    $0x40,%bl
shr    $0x6,%bl
movzbl %bl,%ebp
add    %esi,%ebp
movzbl %dl,%edx
add    %ebp,%edx
movzbl %cl,%ecx
add    %edx,%ecx
movzbl %r9b,%edx
add    %ecx,%edx
movzbl %r8b,%ecx
add    %edx,%ecx
movzbl %dil,%edx
add    %ecx,%edx
and    $0x1,%eax
add    %edx,%eax
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @random_level() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
%3 = call i32 (...) @random_init()
store i32 1, i32* %1
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 15
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = call i32 (...) @random()
%9 = srem i32 %8, 2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %14
14: ; preds = %11, %7
br label %15
15: ; preds = %14
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %4
18: ; preds = %4
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @random_level() {
%1 = tail call i32 (...) @random_init()
%2 = tail call i32 (...) @random()
%3 = srem i32 %2, 2
%4 = icmp eq i32 %3, 1
%5 = select i1 %4, i32 2, i32 1
%6 = tail call i32 (...) @random()
%7 = srem i32 %6, 2
%8 = icmp eq i32 %7, 1
%9 = zext i1 %8 to i32
%10 = add nuw nsw i32 %5, %9
%11 = tail call i32 (...) @random()
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %10, %14
%16 = tail call i32 (...) @random()
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %15, %19
%21 = tail call i32 (...) @random()
%22 = srem i32 %21, 2
%23 = icmp eq i32 %22, 1
%24 = zext i1 %23 to i32
%25 = add nuw nsw i32 %20, %24
%26 = tail call i32 (...) @random()
%27 = srem i32 %26, 2
%28 = icmp eq i32 %27, 1
%29 = zext i1 %28 to i32
%30 = add nuw nsw i32 %25, %29
%31 = tail call i32 (...) @random()
%32 = tail call i32 (...) @random()
%33 = tail call i32 (...) @random()
%34 = tail call i32 (...) @random()
%35 = tail call i32 (...) @random()
%36 = tail call i32 (...) @random()
%37 = tail call i32 (...) @random()
%38 = tail call i32 (...) @random()
%39 = insertelement <8 x i32> poison, i32 %38, i64 0
%40 = insertelement <8 x i32> %39, i32 %37, i64 1
%41 = insertelement <8 x i32> %40, i32 %36, i64 2
%42 = insertelement <8 x i32> %41, i32 %35, i64 3
%43 = insertelement <8 x i32> %42, i32 %34, i64 4
%44 = insertelement <8 x i32> %43, i32 %33, i64 5
%45 = insertelement <8 x i32> %44, i32 %32, i64 6
%46 = insertelement <8 x i32> %45, i32 %31, i64 7
%47 = srem <8 x i32> %46, <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
%48 = icmp eq <8 x i32> %47, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
%49 = extractelement <8 x i1> %48, i64 7
%50 = zext i1 %49 to i32
%51 = add nuw nsw i32 %30, %50
%52 = extractelement <8 x i1> %48, i64 6
%53 = zext i1 %52 to i32
%54 = add nuw nsw i32 %51, %53
%55 = extractelement <8 x i1> %48, i64 5
%56 = zext i1 %55 to i32
%57 = add nuw nsw i32 %54, %56
%58 = extractelement <8 x i1> %48, i64 4
%59 = zext i1 %58 to i32
%60 = add nuw nsw i32 %57, %59
%61 = extractelement <8 x i1> %48, i64 3
%62 = zext i1 %61 to i32
%63 = add nuw nsw i32 %60, %62
%64 = extractelement <8 x i1> %48, i64 2
%65 = zext i1 %64 to i32
%66 = add nuw nsw i32 %63, %65
%67 = extractelement <8 x i1> %48, i64 1
%68 = zext i1 %67 to i32
%69 = add nuw nsw i32 %66, %68
%70 = extractelement <8 x i1> %48, i64 0
%71 = zext i1 %70 to i32
%72 = add nuw nsw i32 %69, %71
ret i32 %72
}