#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(void *);
void ptr_reverse(void *array, size_t n) {
  void **a = (void **)array;
  void **e = a + n;
  void *t;
  assert(array);
  while (--e > a) {
    t = *e;
    *e = *a;
    *a++ = t;
  }
}


x86 assembly (clang, -O0):
<ptr_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
cmp    -0x18(%rbp),%rax
jbe    118e <ptr_reverse+0x7e>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,(%rax)
jmp    1144 <ptr_reverse+0x34>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptr_reverse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
lea    (%rbx,%r14,8),%rax
add    $0xfffffffffffffff8,%rax
cmp    %rbx,%rax
jbe    114e <ptr_reverse+0x3e>
add    $0x8,%rbx
mov    (%rax),%rcx
mov    -0x8(%rbx),%rdx
mov    %rdx,(%rax)
mov    %rcx,-0x8(%rbx)
add    $0xfffffffffffffff8,%rax
lea    0x8(%rbx),%rcx
cmp    %rbx,%rax
mov    %rcx,%rbx
ja     1130 <ptr_reverse+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @ptr_reverse(i8* %0, i64 %1) {
%3 = bitcast i8* %0 to i8**
%4 = getelementptr inbounds i8*, i8** %3, i64 %1
%5 = tail call i32 @assert(i8* %0)
%6 = getelementptr inbounds i8*, i8** %4, i64 -1
%7 = icmp ugt i8** %6, %3
br i1 %7, label %8, label %16
8: ; preds = %2, %8
%9 = phi i8** [ %14, %8 ], [ %6, %2 ]
%10 = phi i8** [ %13, %8 ], [ %3, %2 ]
%11 = load i8*, i8** %9
%12 = load i8*, i8** %10
store i8* %12, i8** %9
%13 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* %11, i8** %10
%14 = getelementptr inbounds i8*, i8** %9, i64 -1
%15 = icmp ugt i8** %14, %13
br i1 %15, label %8, label %16
16: ; preds = %8, %2
ret void
}