#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 get_random(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strchr(char *, int);
void gen_text() {
  int line, nlines = 1 + get_random(5);
  for (line = 0; line < nlines; ++line) {
    int n, nchars = 1 + get_random(128);
    for (n = 0; n < nchars; ++n) {
      int c = 26 + get_random(100);
      if ((n == 0 && c == ' ') || strchr("\r\n", c))
        ++c;
      printf("%c", c);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<gen_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x5,%edi
call   1030 <get_random@plt>
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ff <gen_text+0xcf>
mov    $0x80,%edi
call   1030 <get_random@plt>
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e3 <gen_text+0xb3>
mov    $0x64,%edi
call   1030 <get_random@plt>
add    $0x1a,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11a2 <gen_text+0x72>
cmpl   $0x20,-0x14(%rbp)
je     11bb <gen_text+0x8b>
mov    -0x14(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11c4 <gen_text+0x94>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <gen_text+0x42>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <gen_text+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_text>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x5,%edi
call   1040 <get_random@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     11df <gen_text+0xaf>
xor    %r13d,%r13d
lea    0xea5(%rip),%r15
jmp    1178 <gen_text+0x48>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%eax
cmp    0x4(%rsp),%r13d
mov    %eax,%r13d
je     11df <gen_text+0xaf>
mov    $0x80,%edi
call   1040 <get_random@plt>
test   %eax,%eax
js     1160 <gen_text+0x30>
mov    %eax,%r12d
add    $0x1,%r12d
xor    %r14d,%r14d
jmp    11c4 <gen_text+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11b4 <gen_text+0x84>
add    $0x1b,%ebx
mov    %ebx,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r14d,%r12d
je     1160 <gen_text+0x30>
mov    $0x64,%edi
call   1040 <get_random@plt>
mov    %eax,%ebx
lea    0x1a(%rbx),%ebp
test   %r14d,%r14d
jne    11a0 <gen_text+0x70>
cmp    $0x20,%ebp
je     11af <gen_text+0x7f>
jmp    11a0 <gen_text+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @gen_text() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @get_random(i32 5)
%7 = add nsw i32 1, %6
store i32 %7, i32* %2
store i32 0, i32* %1
br label %8
8: ; preds = %42, %0
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %45
12: ; preds = %8
%13 = call i32 @get_random(i32 128)
%14 = add nsw i32 1, %13
store i32 %14, i32* %4
store i32 0, i32* %3
br label %15
15: ; preds = %37, %12
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = call i32 @get_random(i32 100)
%21 = add nsw i32 26, %20
store i32 %21, i32* %5
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 32
br i1 %26, label %31, label %27
27: ; preds = %24, %19
%28 = load i32, i32* %5
%29 = call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27, %24
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %15
40: ; preds = %15
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %1
%44 = add nsw i32 %43, 1
store i32 %44, i32* %1
br label %8
45: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define void @gen_text() {
%1 = tail call i32 @get_random(i32 5)
%2 = icmp slt i32 %1, 0
br i1 %2, label %28, label %3
3: ; preds = %0, %24
%4 = phi i32 [ %26, %24 ], [ 0, %0 ]
%5 = tail call i32 @get_random(i32 128)
%6 = icmp slt i32 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %3, %19
%8 = phi i32 [ %22, %19 ], [ 0, %3 ]
%9 = tail call i32 @get_random(i32 100)
%10 = add nsw i32 %9, 26
%11 = icmp eq i32 %8, 0
%12 = icmp eq i32 %10, 32
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %17, label %14
14: ; preds = %7
%15 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %7, %14
%18 = add nsw i32 %9, 27
br label %19
19: ; preds = %17, %14
%20 = phi i32 [ %18, %17 ], [ %10, %14 ]
%21 = tail call i32 @putchar(i32 %20)
%22 = add nuw i32 %8, 1
%23 = icmp eq i32 %8, %5
br i1 %23, label %24, label %7
24: ; preds = %19, %3
%25 = tail call i32 @putchar(i32 10)
%26 = add nuw i32 %4, 1
%27 = icmp eq i32 %4, %1
br i1 %27, label %28, label %3
28: ; preds = %24, %0
ret void
}