#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("need a positive integer\n");
    return EXIT_FAILURE;
  }
  int num = strtol(argv[1], NULL, 10);
  if (num <= 0) {
    printf("need a positive integer\n");
    return EXIT_FAILURE;
  }
  srand(time(NULL));
  int count;
  for (count = 0; count < num; count++) {
    printf("%d\n", rand() % 10000);
  }
  return EXIT_SUCCESS;
}


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)
jge    118f <main+0x3f>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    122d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11d1 <main+0x81>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    122d <main+0xdd>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1221 <main+0xd1>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e8 <main+0x98>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jl     11d7 <main+0x77>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
test   %eax,%eax
jle    11d7 <main+0x77>
mov    %eax,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe6b(%rip),%r14
mov    0x2e3c(%rip),%r15
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0x68db8bad,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x40>
jmp    11ea <main+0x8a>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df6(%rip),%r15
mov    (%r15),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"need a positive integer\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
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 slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %3
br label %39
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i32* null, i32 10)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %39
23: ; preds = %13
%24 = call i32 @time(i32* null)
%25 = call i32 @srand(i32 %24)
store i32 0, i32* %7
br label %26
26: ; preds = %34, %23
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 10000
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %26
37: ; preds = %26
%38 = load i32, i32* @EXIT_SUCCESS
store i32 %38, i32* %3
br label %39
39: ; preds = %37, %20, %10
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str.2 = [24 x i8] c"need a positive integer\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strtol(i8* nocapture %6, i32* null, i32 10)
%8 = icmp slt i32 %7, 1
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = tail call i32 @time(i32* null)
%11 = tail call i32 @srand(i32 %10)
br label %12
12: ; preds = %9, %12
%13 = phi i32 [ %17, %12 ], [ 0, %9 ]
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 10000
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i32 %13, 1
%18 = icmp eq i32 %17, %7
br i1 %18, label %22, label %12
19: ; preds = %4, %2
%20 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.2, i64 0, i64 0), %4 ]
%21 = tail call i32 @puts(i8* dereferenceable(1) %20)
br label %22
22: ; preds = %12, %19
%23 = phi i32* [ @EXIT_FAILURE, %19 ], [ @EXIT_SUCCESS, %12 ]
%24 = load i32, i32* %23
ret i32 %24
}