#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 /*<<< orphan*/ printf(char *, int, char *);
int readlines(char **, char *, int);
int main(int argc, char *argv[]) {
  char *lineptr[5000];
  char buf[10000];
  int nlines, i;
  nlines = 0;
  if ((nlines = readlines(lineptr, buf, 5000)) >= 0) {
    for (i = 0; i < nlines; i++) {
      printf("%d:%s\n", i, lineptr[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc370,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xc364(%rbp)
lea    -0x9c50(%rbp),%rdi
lea    -0xc360(%rbp),%rsi
mov    $0x1388,%edx
call   1040 <readlines@plt>
mov    %eax,-0xc364(%rbp)
cmp    $0x0,%eax
jl     11c0 <main+0xa0>
movl   $0x0,-0xc368(%rbp)
mov    -0xc368(%rbp),%eax
cmp    -0xc364(%rbp),%eax
jge    11bb <main+0x9b>
mov    -0xc368(%rbp),%esi
movslq -0xc368(%rbp),%rax
mov    -0x9c50(%rbp,%rax,8),%rdx
ff
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc368(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc368(%rbp)
jmp    1174 <main+0x54>
jmp    11c0 <main+0xa0>
xor    %eax,%eax
add    $0xc370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xc350,%rsp
lea    0x2710(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x1388,%edx
call   1040 <readlines@plt>
test   %eax,%eax
jle    117b <main+0x5b>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xeaf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2710(%rsp,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0xc350,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5000 x i8*]
%4 = alloca [10000 x i8]
%5 = bitcast [5000 x i8*]* %3 to i8*
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %3, i64 0, i64 0
%8 = call i32 @readlines(i8** %7, i8* %6, i32 5000)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %18, %12 ]
%14 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %3, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = trunc i64 %13 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %15)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %2
ret i32 0
}