#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 printlines(char *linesarray[], int n, int numberlines) {
  int i;
  if (n > numberlines)
    for (i = 0; i < numberlines; i++)
      printf("%s\n", linesarray[i]);
  else
    while (n)
      printf("%s\n", linesarray[numberlines - (n--)]);
}


x86 assembly (clang, -O0):
<printlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    116c <printlines+0x5c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1167 <printlines+0x57>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <printlines+0x25>
jmp    11ac <printlines+0x9c>
jmp    1171 <printlines+0x61>
cmpl   $0x0,-0xc(%rbp)
je     11a7 <printlines+0x97>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edx
mov    %edx,%esi
add    $0xffffffff,%esi
mov    %esi,-0xc(%rbp)
sub    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    1171 <printlines+0x61>
jmp    11ac <printlines+0x9c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlines>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
cmp    %edx,%esi
jle    1147 <printlines+0x37>
test   %edx,%edx
jle    1185 <printlines+0x75>
mov    %edx,%r12d
xor    %ebx,%ebx
lea    0xed1(%rip),%r14
nop
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <printlines+0x20>
jmp    1185 <printlines+0x75>
test   %esi,%esi
je     1185 <printlines+0x75>
movslq %esi,%rax
movslq %edx,%rcx
sub    %rax,%rcx
lea    (%r15,%rcx,8),%r15
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xe9c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1170 <printlines+0x60>
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 @printlines(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* %5
%9 = load i32, i32* %6
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %3
store i32 0, i32* %7
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%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 %12
26: ; preds = %12
br label %42
27: ; preds = %3
br label %28
28: ; preds = %31, %27
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = load i8**, i8*** %4
%33 = load i32, i32* %6
%34 = load i32, i32* %5
%35 = add nsw i32 %34, -1
store i32 %35, i32* %5
%36 = sub nsw i32 %33, %34
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %32, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %39)
br label %28
41: ; preds = %28
br label %42
42: ; preds = %41, %26
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @printlines(i8** nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = icmp eq i32 %1, 0
br i1 %6, label %30, label %7
7: ; preds = %5
%8 = sext i32 %1 to i64
%9 = sext i32 %2 to i64
br label %21
10: ; preds = %3
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %30
12: ; preds = %10
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %19, %14 ]
%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 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %13
br i1 %20, label %30, label %14
21: ; preds = %7, %21
%22 = phi i64 [ %8, %7 ], [ %23, %21 ]
%23 = add nsw i64 %22, -1
%24 = sub nsw i64 %9, %22
%25 = getelementptr inbounds i8*, i8** %0, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = trunc i64 %23 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %21
30: ; preds = %21, %14, %5, %10
ret void
}