#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, ...);
int readlines(char *, int, int);
int main(int argc, char **argv) {
  char buf[4][8];
  int lines = readlines((char *)buf, 8, 4);
  printf("lines = %d\n", lines);
  for (int i = 0; i < lines; i++)
    printf("[%d] '%s'\n", i, buf[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x8,%esi
mov    $0x4,%edx
call   1040 <readlines@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    119e <main+0x7e>
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
lea    -0x30(%rbp),%rdx
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1164 <main+0x44>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x8,%esi
mov    $0x4,%edx
call   1040 <readlines@plt>
mov    %eax,%ebx
lea    0xeb7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    118c <main+0x6c>
mov    %ebx,%r12d
lea    0xeac(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0x8,%r15
cmp    %rbx,%r12
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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