#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 getpid();
scalar_t__ isprint(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, char);
scalar_t__ rand();
int /*<<< orphan*/ srand(int);
int time(int /*<<< orphan*/ *);
int main() {
  char c;
  srand(time(NULL) * getpid());
  while (1) {
    c = (char)rand() % 256;
    if (isprint(c) || isspace(c)) {
      printf("%c", c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%edi
imul   %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1090 <rand@plt>
movsbl %al,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1080 <isprint@plt>
cmp    $0x0,%rax
jne    11da <main+0x6a>
movsbl -0x5(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11ea <main+0x7a>
lea    0xe1f(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1040 <printf@plt>
jmp    119d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
imul   %eax,%ebx
mov    %ebx,%edi
call   1060 <srand@plt>
lea    0xe6c(%rip),%rbx
jmp    11aa <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rax,%rbp
movsbl %bpl,%edi
call   1080 <isprint@plt>
movsbl %bpl,%ebp
test   %rax,%rax
jne    11a0 <main+0x30>
mov    %ebp,%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
jmp    11aa <main+0x3a>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 (...) @getpid()
%5 = mul nsw i32 %3, %4
%6 = call i32 @srand(i32 %5)
br label %7
7: ; preds = %0, %23
%8 = call i64 (...) @rand()
%9 = trunc i64 %8 to i8
%10 = sext i8 %9 to i32
%11 = srem i32 %10, 256
%12 = trunc i32 %11 to i8
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = call i64 @isprint(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %7
%17 = load i8, i8* %2
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16, %7
%21 = load i8, i8* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
br label %23
23: ; preds = %20, %16
br label %7
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 (...) @getpid()
%3 = mul nsw i32 %2, %1
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %15, %0
%6 = tail call i64 (...) @rand()
%7 = trunc i64 %6 to i8
%8 = tail call i64 @isprint(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i64 @isspace(i8 signext %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10, %5
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %7)
br label %15
15: ; preds = %13, %10
br label %5
}