#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);
int rand();
int random();
int /*<<< orphan*/ sleep(long);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ syscall(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  while (1) {
    int value = rand();
    long waitTime = random() % 5 + 1;
    printf("[insert] Call insert with value %lu\n", value);
    syscall(374, value, NULL);
    sleep(waitTime);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <random@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %edx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    $0x176,%edi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <syscall@plt>
mov    -0x10(%rbp),%rdi
call   1080 <sleep@plt>
jmp    118f <main+0x1f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe77(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <random@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
movslq %eax,%rbx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    $0x176,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1050 <syscall@plt>
mov    %rbx,%rdi
call   1080 <sleep@plt>
jmp    1190 <main+0x20>

LLVM IR (-O0):
@.str = [37 x i8] c"[insert] Call insert with value %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
br label %6
6: ; preds = %0, %6
%7 = call i32 (...) @rand()
store i32 %7, i32* %2
%8 = call i32 (...) @random()
%9 = srem i32 %8, 5
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
store i64 %11, i64* %3
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @syscall(i32 374, i32 %14, i32* null)
%16 = load i64, i64* %3
%17 = call i32 @sleep(i64 %16)
br label %6
}

LLVM IR (-O2):
@.str = [37 x i8] c"[insert] Call insert with value %lu\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = tail call i32 (...) @rand()
%5 = tail call i32 (...) @random()
%6 = srem i32 %5, 5
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4)
%10 = tail call i32 @syscall(i32 374, i32 %4, i32* null)
%11 = tail call i32 @sleep(i64 %8)
br label %3
}