#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);
scalar_t__ random();
int /*<<< orphan*/ srandomdev();
int main(int argc, char *argv[]) {
  int element = 10;
  if (argc > 1)
    element = atoi(argv[1]);
  int modulus = 10;
  if (argc > 2)
    modulus = atoi(argv[2]);
  while (element-- > 0) {
    srandomdev();
    printf("%d\n", (int)random() % modulus);
  }
  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)
movl   $0xa,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1198 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    119d <main+0x5d>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    11d6 <main+0x96>
mov    $0x0,%al
call   1050 <srandomdev@plt>
mov    $0x0,%al
call   1040 <random@plt>
cltd
idivl  -0x18(%rbp)
mov    %edx,%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
jmp    119d <main+0x5d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xa,%ebp
mov    $0xa,%ebx
cmp    $0x2,%edi
jl     1181 <main+0x41>
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    $0xa,%ebp
cmp    $0x2,%r15d
je     117d <main+0x3d>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
test   %ebx,%ebx
jle    11b3 <main+0x73>
add    $0x1,%ebx
lea    0xe75(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <srandomdev@plt>
xor    %eax,%eax
call   1040 <random@plt>
cltd
idiv   %ebp
mov    %r14,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [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
store i32 10, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
br label %15
15: ; preds = %10, %2
store i32 10, i32* %7
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
br label %23
23: ; preds = %18, %15
br label %24
24: ; preds = %28, %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, -1
store i32 %26, i32* %6
%27 = icmp sgt i32 %25, 0
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = call i32 (...) @srandomdev()
%30 = call i64 (...) @random()
%31 = trunc i64 %30 to i32
%32 = load i32, i32* %7
%33 = srem i32 %31, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %24
35: ; preds = %24
ret i32 0
}

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