#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*/ strcpy(char *, char *);
void reverse(char *lineptr[], int nlines) {
  char temp[1000];
  char **end = lineptr + nlines;
  while (lineptr < end) {
    strcpy(temp, *lineptr);
    strcpy(*(lineptr++), *end);
    strcpy(*(end--), temp);
  }
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x408(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x408(%rbp),%rax
jae    11a6 <reverse+0x96>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rdi
mov    -0x408(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x408(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x408(%rbp)
mov    (%rax),%rdi
lea    -0x400(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1138 <reverse+0x28>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
test   %esi,%esi
jle    1163 <reverse+0x53>
mov    %rdi,%r15
mov    %esi,%eax
lea    (%rdi,%rax,8),%rbx
add    $0x8,%r15
mov    %rsp,%r14
mov    -0x8(%r15),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    -0x8(%r15),%rdi
mov    (%rbx),%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%rdi
add    $0xfffffffffffffff8,%rbx
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0x8(%r15),%rax
cmp    %rbx,%r15
mov    %rax,%r15
jb     1130 <reverse+0x20>
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @reverse(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca i8**
store i8** %0, i8*** %3
store i32 %1, i32* %4
%7 = load i8**, i8*** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %7, i64 %9
store i8** %10, i8*** %6
br label %11
11: ; preds = %15, %2
%12 = load i8**, i8*** %3
%13 = load i8**, i8*** %6
%14 = icmp ult i8** %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %16, i8* %18)
%20 = load i8**, i8*** %3
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %3
%22 = load i8*, i8** %20
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %22, i8* %24)
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i32 -1
store i8** %27, i8*** %6
%28 = load i8*, i8** %26
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %11
31: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @reverse(i8** %0, i32 %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
br label %9
9: ; preds = %6, %9
%10 = phi i8** [ %18, %9 ], [ %8, %6 ]
%11 = phi i8** [ %14, %9 ], [ %0, %6 ]
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %4, i8* %12)
%14 = getelementptr inbounds i8*, i8** %11, i64 1
%15 = load i8*, i8** %11
%16 = load i8*, i8** %10
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds i8*, i8** %10, i64 -1
%19 = load i8*, i8** %10
%20 = call i32 @strcpy(i8* %19, i8* %4)
%21 = icmp ult i8** %14, %18
br i1 %21, label %9, label %22
22: ; preds = %9, %2
ret void
}