#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*/ inplace_swap(int *, int *);
void reverse_array(int a[], int cnt) {
  int first, last;
  for (first = 0, last = cnt - 1; first < last; first++, last--)
    inplace_swap(&a[first], &a[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
jge    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 <inplace_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
cmp    $0x2,%esi
jl     1163 <reverse_array+0x53>
mov    %rdi,%r14
mov    %esi,%r15d
lea    (%rdi,%r15,4),%r12
add    $0xfffffffffffffffc,%r12
add    $0xfffffffffffffffe,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <inplace_swap@plt>
add    $0x1,%rbx
add    $0x4,%r14
add    $0xfffffffffffffffc,%r12
lea    -0x1(%r15),%rax
cmp    %r15,%rbx
mov    %rax,%r15
jl     1140 <reverse_array+0x30>
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 slt 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 @inplace_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, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = add nsw i64 %5, -1
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %13, %7 ]
%9 = phi i64 [ %6, %4 ], [ %14, %7 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %8
%11 = getelementptr inbounds i32, i32* %0, i64 %9
%12 = tail call i32 @inplace_swap(i32* %10, i32* %11)
%13 = add nuw nsw i64 %8, 1
%14 = add nsw i64 %9, -1
%15 = icmp slt i64 %13, %14
br i1 %15, label %7, label %16
16: ; preds = %7, %2
ret void
}