#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 2 && argc != 3) {
    printf("Usage: %s n [s]\n", argv[0]);
    return 1;
  }
  int n = atoi(argv[1]);
  if (argc == 3)
    srand((unsigned int)atoi(argv[2]));
  else
    srand((unsigned int)time(NULL));
  for (int i = 0; i < n; i++)
    printf("%d\n", rand() % 65536);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119b <main+0x4b>
cmpl   $0x3,-0x8(%rbp)
je     119b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1225 <main+0xd5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11ce <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1040 <srand@plt>
jmp    11de <main+0x8e>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121e <main+0xce>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e5 <main+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1180 <main+0x30>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
cmp    $0x3,%ebp
jne    1198 <main+0x48>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
jmp    11a2 <main+0x52>
mov    (%r14),%rsi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11ef <main+0x9f>
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rdi
call   1040 <srand@plt>
test   %ebx,%ebx
jle    11ed <main+0x9d>
lea    0xe5f(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
sub    %ecx,%eax
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    11c0 <main+0x70>
jmp    11ef <main+0x9f>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Usage: %s n [s]\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = and i32 %0, -2
%4 = icmp eq i32 %3, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %31
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp eq i32 %0, 3
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
br label %20
17: ; preds = %8
%18 = tail call i64 @time(i32* null)
%19 = trunc i64 %18 to i32
br label %20
20: ; preds = %17, %13
%21 = phi i32 [ %19, %17 ], [ %16, %13 ]
%22 = tail call i32 @srand(i32 %21)
%23 = icmp sgt i32 %11, 0
br i1 %23, label %24, label %31
24: ; preds = %20, %24
%25 = phi i32 [ %29, %24 ], [ 0, %20 ]
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 65536
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i32 %25, 1
%30 = icmp eq i32 %29, %11
br i1 %30, label %31, label %24
31: ; preds = %24, %20, %5
%32 = phi i32 [ 1, %5 ], [ 0, %20 ], [ 0, %24 ]
ret i32 %32
}