#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 rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void fill_random_data(char *array, int size) {
  srand((unsigned)time(NULL));
  for (int i = 0; i < size - 1; ++i) {
    array[i] = (char)('a' + rand() % 26);
  }
  array[size - 2] = '\n';
  array[size - 1] = '\0';
}


x86 assembly (clang, -O0):
<fill_random_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1192 <fill_random_data+0x62>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
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    1156 <fill_random_data+0x26>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_random_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    -0x1(%r14),%r15d
cmp    $0x2,%r14d
jl     1196 <fill_random_data+0x66>
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x61,%al
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <fill_random_data+0x30>
movslq %r14d,%rax
movb   $0xa,-0x2(%rax,%r12,1)
movslq %r15d,%rax
movb   $0x0,(%r12,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fill_random_data(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 i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
store i32 0, i32* %5
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 26
%17 = add nsw i32 97, %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 = %14
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %9
26: ; preds = %9
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 10, i8* %31
%32 = load i8*, i8** %3
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
store i8 0, i8* %36
ret void
}

LLVM IR (-O2):
define void @fill_random_data(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = add i32 %1, -1
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = zext i32 %6 to i64
br label %16
10: ; preds = %16, %2
%11 = add nsw i32 %1, -2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 10, i8* %13
%14 = sext i32 %6 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
ret void
16: ; preds = %8, %16
%17 = phi i64 [ 0, %8 ], [ %23, %16 ]
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 26
%20 = trunc i32 %19 to i8
%21 = add nsw i8 %20, 97
%22 = getelementptr inbounds i8, i8* %0, i64 %17
store i8 %21, i8* %22
%23 = add nuw nsw i64 %17, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %10, label %16
}