#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 */
scalar_t__ get_random_bool(int);
char get_random_regular_char();
char get_random_whitespace_char();
void load_random_regular_token(size_t length, char buffer[length]) {
  for (size_t i = 0; i < length; i++) {
    buffer[i] = (get_random_bool(10)) ? get_random_whitespace_char()
                                      : get_random_regular_char();
  }
}


x86 assembly (clang, -O0):
<load_random_regular_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11aa <load_random_regular_token+0x7a>
mov    $0xa,%edi
call   1040 <get_random_bool@plt>
cmp    $0x0,%rax
je     117c <load_random_regular_token+0x4c>
mov    $0x0,%al
call   1050 <get_random_whitespace_char@plt>
movsbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    1189 <load_random_regular_token+0x59>
mov    $0x0,%al
call   1030 <get_random_regular_char@plt>
movsbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1148 <load_random_regular_token+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_random_regular_token>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     117c <load_random_regular_token+0x4c>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    1164 <load_random_regular_token+0x34>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <get_random_regular_char@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     117c <load_random_regular_token+0x4c>
mov    $0xa,%edi
call   1040 <get_random_bool@plt>
test   %rax,%rax
je     1150 <load_random_regular_token+0x20>
xor    %eax,%eax
call   1050 <get_random_whitespace_char@plt>
jmp    1157 <load_random_regular_token+0x27>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @load_random_regular_token(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = load i64, i64* %3
store i64 0, i64* %5
br label %7
7: ; preds = %26, %2
%8 = load i64, i64* %5
%9 = load i64, i64* %3
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = call i64 @get_random_bool(i32 10)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call signext i8 (...) @get_random_whitespace_char()
%16 = sext i8 %15 to i32
br label %20
17: ; preds = %11
%18 = call signext i8 (...) @get_random_regular_char()
%19 = sext i8 %18 to i32
br label %20
20: ; preds = %17, %14
%21 = phi i32 [ %16, %14 ], [ %19, %17 ]
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = load i64, i64* %5
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 %22, i8* %25
br label %26
26: ; preds = %20
%27 = load i64, i64* %5
%28 = add i64 %27, 1
store i64 %28, i64* %5
br label %7
29: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @load_random_regular_token(i64 %0, i8* nocapture writeonly %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %4, label %5
4: ; preds = %13, %2
ret void
5: ; preds = %2, %13
%6 = phi i64 [ %16, %13 ], [ 0, %2 ]
%7 = tail call i64 @get_random_bool(i32 10)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call signext i8 (...) @get_random_whitespace_char()
br label %13
11: ; preds = %5
%12 = tail call signext i8 (...) @get_random_regular_char()
br label %13
13: ; preds = %11, %9
%14 = phi i8 [ %10, %9 ], [ %12, %11 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 %14, i8* %15
%16 = add nuw i64 %6, 1
%17 = icmp eq i64 %16, %0
br i1 %17, label %4, label %5
}