#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 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    $0x10,%rsp
mov    $0x80,%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    11c0 <gen_text+0x90>
mov    $0x64,%edi
call   1030 <get_random@plt>
add    $0x1a,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117f <gen_text+0x4f>
cmpl   $0x20,-0xc(%rbp)
je     1198 <gen_text+0x68>
mov    -0xc(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11a1 <gen_text+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe59(%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>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_text>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x80,%edi
call   1040 <get_random@plt>
test   %eax,%eax
js     11a2 <gen_text+0x72>
mov    %eax,%r15d
add    $0x1,%r15d
xor    %ebp,%ebp
lea    0xeaa(%rip),%r14
jmp    1186 <gen_text+0x56>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1176 <gen_text+0x46>
add    $0x1b,%ebx
mov    %ebx,%r12d
mov    %r12d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
je     11a2 <gen_text+0x72>
mov    $0x64,%edi
call   1040 <get_random@plt>
mov    %eax,%ebx
lea    0x1a(%rbx),%r12d
test   %ebp,%ebp
jne    1160 <gen_text+0x30>
cmp    $0x20,%r12d
je     1170 <gen_text+0x40>
jmp    1160 <gen_text+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 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 = call i32 @get_random(i32 128)
%5 = add nsw i32 1, %4
store i32 %5, i32* %2
store i32 0, i32* %1
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %31
10: ; preds = %6
%11 = call i32 @get_random(i32 100)
%12 = add nsw i32 26, %11
store i32 %12, i32* %3
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 32
br i1 %17, label %22, label %18
18: ; preds = %15, %10
%19 = load i32, i32* %3
%20 = call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18, %15
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %22, %18
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %6
31: ; preds = %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

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