#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;
struct node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ alloc(struct node **, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void genrandlist(struct node *head, int size) {
  time_t t;
  srand((unsigned)time(&t));
  int data;
  for (int i = 0; i < size; i++) {
    data = rand() % 1000;
    alloc(&head, data);
  }
}


x86 assembly (clang, -O0):
<genrandlist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <genrandlist+0x5e>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1050 <alloc@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1166 <genrandlist+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genrandlist>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,0x8(%rsp)
lea    0x14(%rsp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebx,%ebx
jle    11a3 <genrandlist+0x63>
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
mov    %r14,%rdi
call   1050 <alloc@plt>
add    $0xffffffff,%ebx
jne    1170 <genrandlist+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define void @genrandlist(%struct.node* %0, i32 %1) {
%3 = alloca %struct.node*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.node* %0, %struct.node** %3
store i32 %1, i32* %4
%8 = call i64 @time(i32* %5)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 1000
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32 @alloc(%struct.node** %3, i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %11
23: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
define void @genrandlist(%struct.node* %0, i32 %1) {
%3 = alloca %struct.node*
%4 = alloca i32
store %struct.node* %0, %struct.node** %3
%5 = bitcast i32* %4 to i8*
%6 = call i64 @time(i32* %4)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %11, label %10
10: ; preds = %11, %2
ret void
11: ; preds = %2, %11
%12 = phi i32 [ %16, %11 ], [ 0, %2 ]
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 1000
%15 = call i32 @alloc(%struct.node** %3, i32 %14)
%16 = add nuw nsw i32 %12, 1
%17 = icmp eq i32 %16, %1
br i1 %17, label %10, label %11
}