#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*/ do_randr_test();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rnd32();
void randr_test(void) {
  long n = 5 * 1000 * 1000;
  printf("randr(lo, hi) test begin...\n");
  do_randr_test();
  printf("Generate %ld more...\n", n);
  while (n--)
    (void)rnd32();
  printf("Test again...\n");
  do_randr_test();
  printf("randr(lo, hi) test done.\n");
}


x86 assembly (clang, -O0):
<randr_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x4c4b40,-0x8(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <do_randr_test@plt>
mov    -0x8(%rbp),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
cmp    $0x0,%rax
je     118c <randr_test+0x5c>
mov    $0x0,%al
call   1030 <rnd32@plt>
jmp    1167 <randr_test+0x37>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <do_randr_test@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randr_test>:
push   %rbx
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <do_randr_test@plt>
lea    0xea5(%rip),%rdi
mov    $0x4c4b40,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffffffb3b4c0,%rbx
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rnd32@plt>
inc    %rbx
jne    1170 <randr_test+0x30>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <do_randr_test@plt>
lea    0xeaa(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"randr(lo, hi) test begin...\0A\00"
@.str.1 = [22 x i8] c"Generate %ld more...\0A\00"
@.str.2 = [15 x i8] c"Test again...\0A\00"
@.str.3 = [26 x i8] c"randr(lo, hi) test done.\0A\00"
define void @randr_test() {
%1 = alloca i64
store i64 5000000, i64* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @do_randr_test()
%4 = load i64, i64* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 %4)
br label %6
6: ; preds = %10, %0
%7 = load i64, i64* %1
%8 = add nsw i64 %7, -1
store i64 %8, i64* %1
%9 = icmp ne i64 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 (...) @rnd32()
br label %6
12: ; preds = %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (...) @do_randr_test()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Generate %ld more...\0A\00"
@str = [28 x i8] c"randr(lo, hi) test begin...\00"
@str.4 = [14 x i8] c"Test again...\00"
@str.5 = [25 x i8] c"randr(lo, hi) test done.\00"
define void @randr_test() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @do_randr_test()
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 5000000)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 5000000, %0 ], [ %6, %4 ]
%6 = add nsw i64 %5, -1
%7 = tail call i32 (...) @rnd32()
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 (...) @do_randr_test()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
ret void
}