#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
long CLOCKS_PER_SEC;
long clock();
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
main() {
  long x, tm;
  time_t segundos;
  time(&segundos);
  printf("\n%s\n", ctime(&segundos));
  srand((unsigned)time(NULL));
  for (x = 1; x <= 5; x++) {
    do
      tm = clock();
    while (tm / CLOCKS_PER_SEC < x);
    printf("Iteración %ld: %d\n", x, rand());
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1c(%rbp),%rdi
call   1070 <time@plt>
lea    -0x1c(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movq   $0x1,-0x10(%rbp)
cmpq   $0x5,-0x10(%rbp)
jg     1213 <main+0xb3>
jmp    11ba <main+0x5a>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e18(%rip),%rcx
cqto
idivq  (%rcx)
cmp    -0x10(%rbp),%rax
jl     11ba <main+0x5a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11aa <main+0x4a>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xe7f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x2e48(%rip),%rbx
jmp    11ba <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cqto
idiv   %rcx
test   %rax,%rax
jg     11d9 <main+0x79>
xor    %eax,%eax
call   1030 <clock@plt>
mov    (%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    11b0 <main+0x50>
xor    %edx,%edx
div    %ecx
test   %rax,%rax
jle    11ba <main+0x5a>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xe1e(%rip),%rdi
mov    $0x1,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120b <main+0xab>
nopw   0x0(%rax,%rax,1)
cqto
idiv   %rcx
cmp    $0x2,%rax
jge    122b <main+0xcb>
xor    %eax,%eax
call   1030 <clock@plt>
mov    (%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1200 <main+0xa0>
xor    %edx,%edx
div    %ecx
cmp    $0x2,%rax
jl     120b <main+0xab>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xdcc(%rip),%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    125b <main+0xfb>
nopl   0x0(%rax)
cqto
idiv   %rcx
cmp    $0x3,%rax
jge    127b <main+0x11b>
xor    %eax,%eax
call   1030 <clock@plt>
mov    (%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1250 <main+0xf0>
xor    %edx,%edx
div    %ecx
cmp    $0x3,%rax
jl     125b <main+0xfb>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xd7c(%rip),%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ab <main+0x14b>
nopl   0x0(%rax)
cqto
idiv   %rcx
cmp    $0x4,%rax
jge    12cb <main+0x16b>
xor    %eax,%eax
call   1030 <clock@plt>
mov    (%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    12a0 <main+0x140>
xor    %edx,%edx
div    %ecx
cmp    $0x4,%rax
jl     12ab <main+0x14b>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xd2c(%rip),%rdi
mov    $0x4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12fb <main+0x19b>
nopl   0x0(%rax)
cqto
idiv   %rcx
cmp    $0x5,%rax
jge    131b <main+0x1bb>
xor    %eax,%eax
call   1030 <clock@plt>
mov    (%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    12f0 <main+0x190>
xor    %edx,%edx
div    %ecx
cmp    $0x5,%rax
jl     12fb <main+0x19b>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xcdc(%rip),%rdi
mov    $0x5,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\0A%s\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.1 = [20 x i8] c"Iteraci\C3\B3n %ld: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @time(i32* %4)
%6 = call i8* @ctime(i32* %4)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i64 1, i64* %2
br label %11
11: ; preds = %27, %0
%12 = load i64, i64* %2
%13 = icmp sle i64 %12, 5
br i1 %13, label %14, label %30
14: ; preds = %11
br label %15
15: ; preds = %17, %14
%16 = call i64 (...) @clock()
store i64 %16, i64* %3
br label %17
17: ; preds = %15
%18 = load i64, i64* %3
%19 = load i64, i64* @CLOCKS_PER_SEC
%20 = sdiv i64 %18, %19
%21 = load i64, i64* %2
%22 = icmp slt i64 %20, %21
br i1 %22, label %15, label %23
23: ; preds = %17
%24 = load i64, i64* %2
%25 = call i32 (...) @rand()
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 %24, i32 %25)
br label %27
27: ; preds = %23
%28 = load i64, i64* %2
%29 = add nsw i64 %28, 1
store i64 %29, i64* %2
br label %11
30: ; preds = %11
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [5 x i8] c"\0A%s\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.1 = [20 x i8] c"Iteraci\C3\B3n %ld: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @time(i32* %1)
%4 = call i8* @ctime(i32* %1)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
br label %9
9: ; preds = %0, %9
%10 = call i64 (...) @clock()
%11 = load i64, i64* @CLOCKS_PER_SEC
%12 = sdiv i64 %10, %11
%13 = icmp slt i64 %12, 1
br i1 %13, label %9, label %14
14: ; preds = %9
%15 = call i32 (...) @rand()
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 1, i32 %15)
br label %17
17: ; preds = %17, %14
%18 = call i64 (...) @clock()
%19 = load i64, i64* @CLOCKS_PER_SEC
%20 = sdiv i64 %18, %19
%21 = icmp slt i64 %20, 2
br i1 %21, label %17, label %22
22: ; preds = %17
%23 = call i32 (...) @rand()
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 2, i32 %23)
br label %25
25: ; preds = %25, %22
%26 = call i64 (...) @clock()
%27 = load i64, i64* @CLOCKS_PER_SEC
%28 = sdiv i64 %26, %27
%29 = icmp slt i64 %28, 3
br i1 %29, label %25, label %30
30: ; preds = %25
%31 = call i32 (...) @rand()
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 3, i32 %31)
br label %33
33: ; preds = %33, %30
%34 = call i64 (...) @clock()
%35 = load i64, i64* @CLOCKS_PER_SEC
%36 = sdiv i64 %34, %35
%37 = icmp slt i64 %36, 4
br i1 %37, label %33, label %38
38: ; preds = %33
%39 = call i32 (...) @rand()
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 4, i32 %39)
br label %41
41: ; preds = %41, %38
%42 = call i64 (...) @clock()
%43 = load i64, i64* @CLOCKS_PER_SEC
%44 = sdiv i64 %42, %43
%45 = icmp slt i64 %44, 5
br i1 %45, label %41, label %46
46: ; preds = %41
%47 = call i32 (...) @rand()
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 5, i32 %47)
ret i32 0
}