#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*/ bit_swap(int *, int *);
void reverse_array(int array[], int size) {
  int first, last;
  for (first = 0, last = size - 1; first <= last; first++, last--)
    bit_swap(&array[first], &array[last]);
}


x86 assembly (clang, -O0):
<reverse_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1175 <reverse_array+0x65>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <bit_swap@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <reverse_array+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1153 <reverse_array+0x43>
mov    %rdi,%r14
mov    %esi,%r15d
lea    (%rdi,%r15,4),%r12
add    $0xfffffffffffffffc,%r12
add    $0xffffffffffffffff,%r15
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <bit_swap@plt>
add    $0x1,%rbx
add    $0x4,%r14
add    $0xfffffffffffffffc,%r12
lea    -0x1(%r15),%rax
cmp    %r15,%rbx
mov    %rax,%r15
jl     1130 <reverse_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @reverse_array(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %13, %6 ]
%8 = phi i64 [ %5, %4 ], [ %9, %6 ]
%9 = add nsw i64 %8, -1
%10 = getelementptr inbounds i32, i32* %0, i64 %7
%11 = getelementptr inbounds i32, i32* %0, i64 %9
%12 = tail call i32 @bit_swap(i32* %10, i32* %11)
%13 = add nuw nsw i64 %7, 1
%14 = icmp slt i64 %13, %9
br i1 %14, label %6, label %15
15: ; preds = %6, %2
ret void
}