#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sorti1(int *, int);
int /*<<< orphan*/ stderr;
void sorti2(int a[], int n) {
  int *p, *q, w;
  if (n <= 1) {
    fprintf(stderr, "Error : n <= 1  in sorti2()\n");
    return;
  }
  sorti1(a, n);
  p = a;
  q = a + n - 1;
  while (p < q) {
    w = *p;
    *p++ = *q;
    *q-- = w;
  }
  return;
}


x86 assembly (clang, -O0):
<sorti2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     1153 <sorti2+0x33>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11ca <sorti2+0xaa>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <sorti1@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11c5 <sorti2+0xa5>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
jmp    117e <sorti2+0x5e>
jmp    11ca <sorti2+0xaa>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorti2>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%esi
jg     1143 <sorti2+0x23>
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <sorti1@plt>
mov    %ebp,%eax
lea    (%rbx,%rax,4),%rax
add    $0xfffffffffffffffc,%rax
cmp    %rbx,%rax
jbe    117a <sorti2+0x5a>
add    $0x4,%rbx
mov    -0x4(%rbx),%ecx
mov    (%rax),%edx
mov    %edx,-0x4(%rbx)
mov    %ecx,(%rax)
add    $0xfffffffffffffffc,%rax
lea    0x4(%rbx),%rcx
cmp    %rax,%rbx
mov    %rcx,%rbx
jb     1160 <sorti2+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Error : n <= 1 in sorti2()\0A\00"
define void @sorti2(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %38
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @sorti1(i32* %14, i32 %15)
%17 = load i32*, i32** %3
store i32* %17, i32** %5
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = getelementptr inbounds i32, i32* %21, i64 -1
store i32* %22, i32** %6
br label %23
23: ; preds = %27, %13
%24 = load i32*, i32** %5
%25 = load i32*, i32** %6
%26 = icmp ult i32* %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
store i32 %29, i32* %7
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %5
store i32 %31, i32* %32
%34 = load i32, i32* %7
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i32 -1
store i32* %36, i32** %6
store i32 %34, i32* %35
br label %23
37: ; preds = %23
br label %38
38: ; preds = %37, %10
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error : n <= 1 in sorti2()\0A\00"
define void @sorti2(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %21
7: ; preds = %2
%8 = tail call i32 @sorti1(i32* %0, i32 %1)
%9 = zext i32 %1 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = getelementptr inbounds i32, i32* %10, i64 -1
%12 = icmp ugt i32* %11, %0
br i1 %12, label %13, label %21
13: ; preds = %7, %13
%14 = phi i32* [ %19, %13 ], [ %11, %7 ]
%15 = phi i32* [ %18, %13 ], [ %0, %7 ]
%16 = load i32, i32* %15
%17 = load i32, i32* %14
%18 = getelementptr inbounds i32, i32* %15, i64 1
store i32 %17, i32* %15
store i32 %16, i32* %14
%19 = getelementptr inbounds i32, i32* %14, i64 -1
%20 = icmp ult i32* %18, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %7, %4
ret void
}