#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 random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void gentxt(unsigned char *text, int len) {
  int i;
  srandom(time(0));
  for (i = 0; i < len; i++) {
    text[i] = (random() & 0xFF) ^ (random() & 0xFF);
  }
}


x86 assembly (clang, -O0):
<gentxt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <gentxt+0x6e>
mov    $0x0,%al
call   1050 <random@plt>
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
and    $0xff,%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <gentxt+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gentxt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
test   %ebp,%ebp
jle    117f <gentxt+0x4f>
mov    %ebp,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <random@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <random@plt>
xor    %ebp,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <gentxt+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gentxt(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 @time(i32 0)
%7 = call i32 @srandom(i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = call i32 (...) @random()
%14 = and i32 %13, 255
%15 = call i32 (...) @random()
%16 = and i32 %15, 255
%17 = xor i32 %14, %16
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @gentxt(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srandom(i32 %3)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %15, %8 ]
%10 = tail call i32 (...) @random()
%11 = tail call i32 (...) @random()
%12 = xor i32 %11, %10
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %13, i8* %14
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, %7
br i1 %16, label %17, label %8
17: ; preds = %8, %2
ret void
}