#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 gen(char *, int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  char expr[5000];
  int i;
  for (i = 0; i < 10000; i++) {
    int end = gen(expr, 0, 5000, 0);
    expr[end] = 0;
    printf("%s\n", expr);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13a0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1394(%rbp)
cmpl   $0x2710,-0x1394(%rbp)
jge    11cd <main+0x8d>
lea    -0x1390(%rbp),%rdi
xor    %ecx,%ecx
mov    $0x1388,%edx
mov    %ecx,%esi
call   1060 <gen@plt>
mov    %eax,-0x1398(%rbp)
movslq -0x1398(%rbp),%rax
movb   $0x0,-0x1390(%rbp,%rax,1)
lea    -0x1390(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1394(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1394(%rbp)
jmp    116c <main+0x2c>
mov    -0x4(%rbp),%eax
add    $0x13a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1390,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x2710,%ebp
mov    %rsp,%rbx
lea    0xe98(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1388,%edx
xor    %ecx,%ecx
call   1060 <gen@plt>
cltq
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x1390,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5000 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10000
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = getelementptr inbounds [5000 x i8], [5000 x i8]* %2, i64 0, i64 0
%12 = call i32 @gen(i8* %11, i32 0, i32 5000, i32 0)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5000 x i8], [5000 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = getelementptr inbounds [5000 x i8], [5000 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %7
21: ; preds = %7
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [5000 x i8]
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = getelementptr inbounds [5000 x i8], [5000 x i8]* %1, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %11, %5 ]
%7 = call i32 @gen(i8* %4, i32 0, i32 5000, i32 0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [5000 x i8], [5000 x i8]* %1, i64 0, i64 %8
store i8 0, i8* %9
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, 10000
br i1 %12, label %13, label %5
13: ; preds = %5
ret i32 0
}