#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*/ my_rand(unsigned long *, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i, seq_len = 5;
  unsigned long seed = (unsigned long)time(NULL);
  if (argc < 3) {
    printf("%s <lower_bound> <upper_bound> [<seq_len>]\n", argv[0]);
    printf("\tGenerate a sequence of random numbers\n");
    printf("\tlower_bound:  Lower bound\n");
    printf("\tupper_bound:  Upper bound\n");
    printf("\tseq_len: Length of the sequence to generate\n");
    exit(EXIT_FAILURE);
  } else if (argc == 4)
    seq_len = atoi(argv[3]);
  printf("Generated: ");
  for (i = 0; i < seq_len; i++) {
    printf((i < seq_len - 1) ? "%u," : "%u",
           my_rand(&seed, (unsigned int)atoi(argv[1]),
                   (unsigned int)atoi(argv[2])));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11df <main+0x8f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    11f9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11fe <main+0xae>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1286 <main+0x136>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
lea    0xe9b(%rip),%rax
lea    0xe90(%rip),%rcx
cmp    %esi,%edx
cmovl  %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    -0x20(%rbp),%rdi
call   1030 <my_rand@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1213 <main+0xc3>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %rax,(%rsp)
cmp    $0x2,%ebp
jle    1247 <main+0xd7>
cmp    $0x4,%ebp
jne    11bb <main+0x4b>
mov    0x18(%r12),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
jg     11cf <main+0x5f>
jmp    122c <main+0xbc>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x5,%r14d
lea    -0x1(%r14),%r13d
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
cmp    %r13d,%r15d
lea    0xe52(%rip),%rbp
lea    0xe47(%rip),%rax
cmovl  %rax,%rbp
mov    0x8(%r12),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%r12),%rdi
call   1080 <atoi@plt>
mov    %rsp,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <my_rand@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15d
cmp    %r15d,%r14d
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12),%rsi
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xddf(%rip),%rdi
call   1040 <puts@plt>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"%s <lower_bound> <upper_bound> [<seq_len>]\0A\00"
@.str.1 = [40 x i8] c"\09Generate a sequence of random numbers\0A\00"
@.str.2 = [28 x i8] c"\09lower_bound: Lower bound\0A\00"
@.str.3 = [28 x i8] c"\09upper_bound: Upper bound\0A\00"
@.str.4 = [46 x i8] c"\09seq_len: Length of the sequence to generate\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [12 x i8] c"Generated: \00"
@.str.6 = [4 x i8] c"%u,\00"
@.str.7 = [3 x i8] c"%u\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5, i32* %7
%9 = call i64 @time(i32* null)
store i64 %9, i64* %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 4
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %7
br label %31
31: ; preds = %26, %23
br label %32
32: ; preds = %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
br label %34
34: ; preds = %55, %32
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %58
38: ; preds = %34
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
%43 = zext i1 %42 to i64
%44 = select i1 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0)
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 @atoi(i8* %47)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
%53 = call i32 @my_rand(i64* %8, i32 %48, i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* %44, i32 %53)
br label %55
55: ; preds = %38
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %34
58: ; preds = %34
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"%s <lower_bound> <upper_bound> [<seq_len>]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [12 x i8] c"Generated: \00"
@.str.6 = [4 x i8] c"%u,\00"
@.str.7 = [3 x i8] c"%u\00"
@str = [39 x i8] c"\09Generate a sequence of random numbers\00"
@str.9 = [27 x i8] c"\09lower_bound: Lower bound\00"
@str.10 = [27 x i8] c"\09upper_bound: Upper bound\00"
@str.11 = [45 x i8] c"\09seq_len: Length of the sequence to generate\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i64 @time(i32* null)
store i64 %5, i64* %3
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.11, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = icmp eq i32 %0, 4
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %26
20: ; preds = %16
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp sgt i32 %23, 0
br i1 %25, label %26, label %43
26: ; preds = %18, %20
%27 = phi i32 [ 5, %18 ], [ %23, %20 ]
%28 = add nsw i32 %27, -1
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = getelementptr inbounds i8*, i8** %1, i64 2
br label %31
31: ; preds = %26, %31
%32 = phi i32 [ 0, %26 ], [ %41, %31 ]
%33 = icmp slt i32 %32, %28
%34 = select i1 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0)
%35 = load i8*, i8** %29
%36 = call i32 @atoi(i8* %35)
%37 = load i8*, i8** %30
%38 = call i32 @atoi(i8* %37)
%39 = call i32 @my_rand(i64* %3, i32 %36, i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34, i32 %39)
%41 = add nuw nsw i32 %32, 1
%42 = icmp eq i32 %41, %27
br i1 %42, label %43, label %31
43: ; preds = %31, %20
%44 = call i32 @putchar(i32 10)
ret i32 0
}