#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*/ printf(char *, unsigned long long);
unsigned long long rnd16(unsigned long long);
unsigned long long rnd16lfsr(unsigned long long);
unsigned long long rnd32(unsigned long long);
unsigned long long rnd8(unsigned long long);
unsigned long long rnd8lfsr(unsigned long long);
void testrnd() {
  unsigned long long int x;
  unsigned long long int n;
  n = 0;
  x = 0;
  do {
    n++;
    x = rnd8(x);
  } while (x != 0);
  printf("N = %llu\n", n);
  n = 0;
  x = 0;
  do {
    n++;
    x = rnd16(x);
  } while (x != 0);
  printf("N = %llu\n", n);
  n = 0;
  x = 0;
  do {
    n++;
    x = rnd32(x);
  } while (x != 0);
  printf("N = %llu\n", n);
  n = 0;
  x = 0;
  do {
    n++;
    x = rnd8lfsr(x);
  } while (x != 0);
  printf("N = %llu\n", n);
  n = 0;
  x = 0;
  do {
    n++;
    x = rnd16lfsr(x);
  } while (x != 0);
  printf("N = %llu\n", n);
}


x86 assembly (clang, -O0):
<testrnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <rnd8@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1178 <testrnd+0x18>
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rnd16@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11bc <testrnd+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rnd32@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1200 <testrnd+0xa0>
mov    -0x10(%rbp),%rsi
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <rnd8lfsr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1244 <testrnd+0xe4>
mov    -0x10(%rbp),%rsi
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <rnd16lfsr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1288 <testrnd+0x128>
mov    -0x10(%rbp),%rsi
lea    0xd49(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testrnd>:
push   %rbx
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
mov    %rax,%rdi
call   1080 <rnd8@plt>
test   %rax,%rax
jne    1170 <testrnd+0x10>
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %rax,%rdi
call   1050 <rnd16@plt>
test   %rax,%rax
jne    11a0 <testrnd+0x40>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %rax,%rdi
call   1030 <rnd32@plt>
test   %rax,%rax
jne    11d0 <testrnd+0x70>
lea    0xe18(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %rax,%rdi
call   1070 <rnd8lfsr@plt>
test   %rax,%rax
jne    1200 <testrnd+0xa0>
lea    0xde8(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %rax,%rdi
call   1060 <rnd16lfsr@plt>
test   %rax,%rax
jne    1230 <testrnd+0xd0>
lea    0xdb8(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"N = %llu\0A\00"
define void @testrnd() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %2
store i64 0, i64* %1
br label %3
3: ; preds = %8, %0
%4 = load i64, i64* %2
%5 = add i64 %4, 1
store i64 %5, i64* %2
%6 = load i64, i64* %1
%7 = call i64 @rnd8(i64 %6)
store i64 %7, i64* %1
br label %8
8: ; preds = %3
%9 = load i64, i64* %1
%10 = icmp ne i64 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %8
%12 = load i64, i64* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %12)
store i64 0, i64* %2
store i64 0, i64* %1
br label %14
14: ; preds = %19, %11
%15 = load i64, i64* %2
%16 = add i64 %15, 1
store i64 %16, i64* %2
%17 = load i64, i64* %1
%18 = call i64 @rnd16(i64 %17)
store i64 %18, i64* %1
br label %19
19: ; preds = %14
%20 = load i64, i64* %1
%21 = icmp ne i64 %20, 0
br i1 %21, label %14, label %22
22: ; preds = %19
%23 = load i64, i64* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %23)
store i64 0, i64* %2
store i64 0, i64* %1
br label %25
25: ; preds = %30, %22
%26 = load i64, i64* %2
%27 = add i64 %26, 1
store i64 %27, i64* %2
%28 = load i64, i64* %1
%29 = call i64 @rnd32(i64 %28)
store i64 %29, i64* %1
br label %30
30: ; preds = %25
%31 = load i64, i64* %1
%32 = icmp ne i64 %31, 0
br i1 %32, label %25, label %33
33: ; preds = %30
%34 = load i64, i64* %2
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %34)
store i64 0, i64* %2
store i64 0, i64* %1
br label %36
36: ; preds = %41, %33
%37 = load i64, i64* %2
%38 = add i64 %37, 1
store i64 %38, i64* %2
%39 = load i64, i64* %1
%40 = call i64 @rnd8lfsr(i64 %39)
store i64 %40, i64* %1
br label %41
41: ; preds = %36
%42 = load i64, i64* %1
%43 = icmp ne i64 %42, 0
br i1 %43, label %36, label %44
44: ; preds = %41
%45 = load i64, i64* %2
%46 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %45)
store i64 0, i64* %2
store i64 0, i64* %1
br label %47
47: ; preds = %52, %44
%48 = load i64, i64* %2
%49 = add i64 %48, 1
store i64 %49, i64* %2
%50 = load i64, i64* %1
%51 = call i64 @rnd16lfsr(i64 %50)
store i64 %51, i64* %1
br label %52
52: ; preds = %47
%53 = load i64, i64* %1
%54 = icmp ne i64 %53, 0
br i1 %54, label %47, label %55
55: ; preds = %52
%56 = load i64, i64* %2
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %56)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"N = %llu\0A\00"
define void @testrnd() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %5, %1 ]
%3 = phi i64 [ 0, %0 ], [ %4, %1 ]
%4 = add i64 %3, 1
%5 = tail call i64 @rnd8(i64 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %1
7: ; preds = %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %9
9: ; preds = %9, %7
%10 = phi i64 [ 0, %7 ], [ %13, %9 ]
%11 = phi i64 [ 0, %7 ], [ %12, %9 ]
%12 = add i64 %11, 1
%13 = tail call i64 @rnd16(i64 %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %9
15: ; preds = %9
%16 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %21, %17 ]
%19 = phi i64 [ 0, %15 ], [ %20, %17 ]
%20 = add i64 %19, 1
%21 = tail call i64 @rnd32(i64 %18)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %17
%24 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %20)
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %29, %25 ]
%27 = phi i64 [ 0, %23 ], [ %28, %25 ]
%28 = add i64 %27, 1
%29 = tail call i64 @rnd8lfsr(i64 %26)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %25
31: ; preds = %25
%32 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %28)
br label %33
33: ; preds = %33, %31
%34 = phi i64 [ 0, %31 ], [ %37, %33 ]
%35 = phi i64 [ 0, %31 ], [ %36, %33 ]
%36 = add i64 %35, 1
%37 = tail call i64 @rnd16lfsr(i64 %34)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %33
39: ; preds = %33
%40 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %36)
ret void
}