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


x86 assembly (clang, -O0):
<sortii2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jg     1157 <sortii2+0x37>
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11d2 <sortii2+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <sortii1@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11cd <sortii2+0xad>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
jmp    1186 <sortii2+0x66>
jmp    11d2 <sortii2+0xb2>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sortii2>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%esi
jg     1143 <sortii2+0x23>
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>
mov    %rdx,%rbx
mov    %esi,%ebp
call   1040 <sortii1@plt>
mov    %ebp,%eax
lea    (%rbx,%rax,4),%rax
add    $0xfffffffffffffffc,%rax
cmp    %rbx,%rax
jbe    117a <sortii2+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 <sortii2+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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