#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 *, char *);
void writelines(char *lineptr[], int nlines, bool descend) {
  int i;
  if (descend)
    for (i = nlines - 1; i > -1; i--)
      printf("%s\n", lineptr[i]);
  else
    for (i = 0; i < nlines; i++)
      printf("%s\n", lineptr[i]);
}


x86 assembly (clang, -O0):
<writelines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116a <writelines+0x5a>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    1165 <writelines+0x55>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <writelines+0x25>
jmp    11a8 <writelines+0x98>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <writelines+0x93>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <writelines+0x61>
jmp    11a8 <writelines+0x98>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writelines>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
test   %edx,%edx
je     114b <writelines+0x3b>
test   %esi,%esi
jle    1175 <writelines+0x65>
mov    %esi,%ebx
add    $0x1,%rbx
lea    0xed0(%rip),%r14
lea    -0x2(%rbx),%eax
mov    (%r15,%rax,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <writelines+0x20>
jmp    1175 <writelines+0x65>
test   %esi,%esi
jle    1175 <writelines+0x65>
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xea5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <writelines+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @writelines(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %3
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %7
br label %13
13: ; preds = %23, %10
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i8**, i8*** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, -1
store i32 %25, i32* %7
br label %13
26: ; preds = %13
br label %43
27: ; preds = %3
store i32 0, i32* %7
br label %28
28: ; preds = %39, %27
%29 = load i32, i32* %7
%30 = load i32, i32* %5
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i8**, i8*** %4
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %28
42: ; preds = %28
br label %43
43: ; preds = %42, %26
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @writelines(i8** nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = icmp sgt i32 %1, 0
br i1 %4, label %9, label %6
6: ; preds = %3
br i1 %5, label %7, label %27
7: ; preds = %6
%8 = zext i32 %1 to i64
br label %12
9: ; preds = %3
br i1 %5, label %10, label %27
10: ; preds = %9
%11 = zext i32 %1 to i64
br label %20
12: ; preds = %7, %12
%13 = phi i64 [ %8, %7 ], [ %14, %12 ]
%14 = add nsw i64 %13, -1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp ugt i64 %13, 1
br i1 %19, label %12, label %27
20: ; preds = %10, %20
%21 = phi i64 [ 0, %10 ], [ %25, %20 ]
%22 = getelementptr inbounds i8*, i8** %0, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %20
27: ; preds = %12, %20, %6, %9
ret void
}