#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 *, unsigned int);
int rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  int i, n = 500000;
  if (argc > 1)
    n = atoi(argv[1]);
  srand(11);
  for (i = 0; i < n; ++i)
    printf("%u\n", (unsigned)((rand() % (n / 4)) * 271828183u));
  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   $0x7a120,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    $0xb,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d1 <main+0x91>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
imul   $0x1033c4d7,%edx,%esi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <main+0x48>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jle    1164 <main+0x24>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    $0xb,%edi
call   1040 <srand@plt>
test   %ebx,%ebx
jg     1173 <main+0x33>
jmp    119d <main+0x5d>
mov    $0xb,%edi
call   1040 <srand@plt>
mov    $0x7a120,%ebx
mov    %ebx,%ebp
shr    $0x2,%ebp
lea    0xe81(%rip),%r14
nop
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %ebp
imul   $0x1033c4d7,%edx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\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 500000, i32* %7
%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* %7
br label %15
15: ; preds = %10, %2
%16 = call i32 @srand(i32 11)
store i32 0, i32* %6
br label %17
17: ; preds = %28, %15
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = call i32 (...) @rand()
%23 = load i32, i32* %7
%24 = sdiv i32 %23, 4
%25 = srem i32 %22, %24
%26 = mul i32 %25, 271828183
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %17
31: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @srand(i32 11)
br label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @srand(i32 11)
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %23
12: ; preds = %4, %6
%13 = phi i32 [ 500000, %4 ], [ %9, %6 ]
%14 = lshr i32 %13, 2
br label %15
15: ; preds = %12, %15
%16 = phi i32 [ 0, %12 ], [ %21, %15 ]
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, %14
%19 = mul i32 %18, 271828183
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i32 %16, 1
%22 = icmp eq i32 %21, %13
br i1 %22, label %23, label %15
23: ; preds = %15, %6
ret i32 0
}