#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*/ assert(int);
int /*<<< orphan*/ printf(char *, char *);
void print_lines(int pos, char **buffer, int max) {
  assert(pos >= 0 && buffer != NULL);
  for (int i = pos; i < max; i++)
    printf("%s", buffer[i]);
  for (int i = 0; i < pos; i++)
    printf("%s", buffer[i]);
}


x86 assembly (clang, -O0):
<print_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x1d(%rbp)
jl     114c <print_lines+0x2c>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1191 <print_lines+0x71>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <print_lines+0x3f>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ca <print_lines+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <print_lines+0x78>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%r12
mov    %edi,%r14d
test   %edi,%edi
setns  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
cmp    %r13d,%r14d
jge    1185 <print_lines+0x65>
movslq %r14d,%rax
lea    (%r12,%rax,8),%rbx
sub    %r14d,%r13d
xor    %ebp,%ebp
lea    0xe9f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rsi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
jne    1170 <print_lines+0x50>
test   %r14d,%r14d
jle    11b5 <print_lines+0x95>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xe6a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <print_lines+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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