#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*/ EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int max, i;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s #values [seed]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  max = atoi(argv[1]);
  if (max < 1) {
    fprintf(stderr, "%s: too few values\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (max > 1000000) {
    fprintf(stderr, "%s: too many values\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (argc == 3)
    srand(atoi(argv[2]));
  else
    srand(time(NULL));
  for (i = 0; i < max; i++)
    printf("%d\n", 1 + rand() % (max * 10));
  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)
jge    11ba <main+0x4a>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    11fe <main+0x8e>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmpl   $0xf4240,-0x14(%rbp)
jle    1235 <main+0xc5>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1258 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1040 <srand@plt>
jmp    1268 <main+0xf8>
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    12a8 <main+0x138>
mov    $0x0,%al
call   1090 <rand@plt>
imul   $0xa,-0x14(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126f <main+0xff>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
jle    11e1 <main+0x71>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
call   1070 <atoi@plt>
test   %eax,%eax
jle    11f6 <main+0x86>
mov    %eax,%ebx
cmp    $0xf4241,%eax
jae    120b <main+0x9b>
cmp    $0x3,%ebp
jne    11a4 <main+0x34>
mov    0x10(%r14),%rdi
call   1070 <atoi@plt>
jmp    11ab <main+0x3b>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    %ebx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%ebp
lea    0xe83(%rip),%r14
xor    %eax,%eax
call   1090 <rand@plt>
cltd
idiv   %ebp
lea    0x1(%rdx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    11c0 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe0c(%rip),%rsi
jmp    121e <main+0xae>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe11(%rip),%rsi
jmp    121e <main+0xae>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe10(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s #values [seed]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"%s: too few values\0A\00"
@.str.2 = [21 x i8] c"%s: too many values\0A\00"
@.str.3 = [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 slt i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %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* %6
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %33
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %18
%34 = load i32, i32* %6
%35 = icmp sgt i32 %34, 1000000
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %33
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 3
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
%52 = call i32 @srand(i32 %51)
br label %56
53: ; preds = %44
%54 = call i32 @time(i32* null)
%55 = call i32 @srand(i32 %54)
br label %56
56: ; preds = %53, %47
store i32 0, i32* %7
br label %57
57: ; preds = %68, %56
%58 = load i32, i32* %7
%59 = load i32, i32* %6
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = call i32 (...) @rand()
%63 = load i32, i32* %6
%64 = mul nsw i32 %63, 10
%65 = srem i32 %62, %64
%66 = add nsw i32 1, %65
%67 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %57
71: ; preds = %57
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s #values [seed]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"%s: too few values\0A\00"
@.str.2 = [21 x i8] c"%s: too many values\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %10
%22 = icmp ugt i32 %13, 1000000
br i1 %22, label %23, label %29
23: ; preds = %21
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %1
%26 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %21
%30 = icmp eq i32 %0, 3
br i1 %30, label %31, label %35
31: ; preds = %29
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32 @atoi(i8* %33)
br label %37
35: ; preds = %29
%36 = tail call i32 @time(i32* null)
br label %37
37: ; preds = %31, %35
%38 = phi i32 [ %34, %31 ], [ %36, %35 ]
%39 = tail call i32 @srand(i32 %38)
%40 = mul nuw nsw i32 %13, 10
br label %41
41: ; preds = %37, %41
%42 = phi i32 [ 0, %37 ], [ %47, %41 ]
%43 = tail call i32 (...) @rand()
%44 = srem i32 %43, %40
%45 = add nsw i32 %44, 1
%46 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = add nuw nsw i32 %42, 1
%48 = icmp eq i32 %47, %13
br i1 %48, label %49, label %41
49: ; preds = %41
ret i32 0
}