#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*/ getpid();
int /*<<< orphan*/ putchar(int);
double rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i, c;
  int limit = 0;
  limit = argc > 1 ? atoi(argv[1]) : 0;
  srand(getpid());
  for (i = 0; !limit || i < limit; i++) {
    c = ((unsigned)(1 + (int)(256.0 * rand() / (32767 + 1.0))) - 1);
    putchar(c);
  }
  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   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    118c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1196 <main+0x46>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <main+0x46>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x21(%rbp)
je     11cc <main+0x7c>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11dc <main+0x8c>
jmp    1221 <main+0xd1>
mov    $0x0,%al
call   1070 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <main+0x61>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     1165 <main+0x15>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %ebp,%ebp
js     11ad <main+0x5d>
mov    $0x1,%eax
nopl   0x0(%rax)
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mulsd  0xe6f(%rip),%xmm0
mulsd  0xe6f(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
test   %ebp,%ebp
je     1180 <main+0x30>
cmp    %ebp,%ebx
jl     1180 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 0, %16 ]
store i32 %18, i32* %8
%19 = call i32 (...) @getpid()
%20 = call i32 @srand(i32 %19)
store i32 0, i32* %6
br label %21
21: ; preds = %39, %17
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %6
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br label %28
28: ; preds = %24, %21
%29 = phi i1 [ true, %21 ], [ %27, %24 ]
br i1 %29, label %30, label %42
30: ; preds = %28
%31 = call double (...) @rand()
%32 = fmul double 2.560000e+02, %31
%33 = fdiv double %32, 3.276800e+04
%34 = fptosi double %33 to i32
%35 = add nsw i32 1, %34
%36 = sub i32 %35, 1
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = call i32 @putchar(i32 %37)
br label %39
39: ; preds = %30
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %21
42: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 0, %2 ]
%10 = tail call i32 (...) @getpid()
%11 = tail call i32 @srand(i32 %10)
%12 = icmp eq i32 %9, 0
%13 = icmp sgt i32 %9, -1
br i1 %13, label %14, label %24
14: ; preds = %8, %14
%15 = phi i32 [ %21, %14 ], [ 0, %8 ]
%16 = tail call double (...) @rand()
%17 = fmul double %16, 2.560000e+02
%18 = fmul double %17, 0x3F00000000000000
%19 = fptosi double %18 to i32
%20 = tail call i32 @putchar(i32 %19)
%21 = add nuw nsw i32 %15, 1
%22 = icmp slt i32 %21, %9
%23 = select i1 %12, i1 true, i1 %22
br i1 %23, label %14, label %24
24: ; preds = %14, %8
ret i32 0
}