#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 *, int);
void reverse(char **line) {
  int i;
  char **reversed;
  int end;
  for (i = 0; line[i] != NULL; i++) {
    end = i;
  }
  for (i = end; i >= 0; i--) {
    printf("%s\n", line[i], i);
  }
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     114a <reverse+0x3a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <reverse+0x13>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1183 <reverse+0x73>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0xc(%rbp),%edx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <reverse+0x40>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %edx,%eax
cmpq   $0x0,(%r14,%rcx,8)
mov    %ecx,%edx
lea    0x1(%rcx),%rcx
jne    1120 <reverse+0x10>
test   %eax,%eax
js     1154 <reverse+0x44>
mov    %eax,%ebx
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
jb     1140 <reverse+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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