#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 *, int /*<<< orphan*/);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ random();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int main() {
  int i;
  sleep(10);
  srandom(0);
  for (i = 0; i < 10; i++) {
    printf("%ld\n", random());
    printf("%ld\n", rand());
    printf("%ld\n", random());
    printf("%ld\n", rand());
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11e3 <main+0x93>
mov    $0x0,%al
call   1050 <random@plt>
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%esi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <random@plt>
mov    %eax,%esi
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%esi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x27>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%ebp
mov    $0xa,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1030 <srandom@plt>
lea    0xe90(%rip),%rbx
xor    %eax,%eax
call   1050 <random@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <random@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @sleep(i32 10)
%4 = call i32 @srandom(i32 0)
store i32 0, i32* %2
br label %5
5: ; preds = %17, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = call i32 (...) @random()
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (...) @rand()
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @random()
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @rand()
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %8
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %5
20: ; preds = %5
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = tail call i32 @sleep(i32 10)
%2 = tail call i32 @srandom(i32 0)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %13, %3 ]
%5 = tail call i32 (...) @random()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (...) @rand()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @random()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 (...) @rand()
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i32 %4, 1
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %3
15: ; preds = %3
ret i32 0
}