#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*/ _quick_sort(int *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
void quick_sort(int *pdata, int count) {
  int begin, end;
  printf(
      "please input the begin pos and the end pos which you want to sort:\n");
  scanf("%d %d", &begin, &end);
  while (begin > count - 1 || end > count - 1 || begin > end || begin < 0 ||
         end < 0) {
    printf("input error, please input again:\n");
    scanf("%d %d", &begin, &end);
  }
  _quick_sort(pdata, begin, end);
}


x86 assembly (clang, -O0):
<quick_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jg     11b5 <quick_sort+0x85>
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jg     11b5 <quick_sort+0x85>
mov    -0x10(%rbp),%ecx
mov    $0x1,%al
cmp    -0x14(%rbp),%ecx
mov    %al,-0x15(%rbp)
jg     11b5 <quick_sort+0x85>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jl     11b5 <quick_sort+0x85>
cmpl   $0x0,-0x14(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11c5 <quick_sort+0x95>
jmp    11ea <quick_sort+0xba>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
jmp    115f <quick_sort+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <_quick_sort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quick_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%r13
lea    0xee7(%rip),%rbx
jmp    1178 <quick_sort+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    %ebp,%esi
jge    1170 <quick_sort+0x40>
mov    (%rsp),%edx
cmp    %ebp,%edx
jge    1170 <quick_sort+0x40>
mov    %edx,%eax
or     %esi,%eax
cmp    %edx,%esi
jg     1170 <quick_sort+0x40>
test   %eax,%eax
js     1170 <quick_sort+0x40>
mov    %r14,%rdi
call   1050 <_quick_sort@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"please input the begin pos and the end pos which you want to sort:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [34 x i8] c"input error, please input again:\0A\00"
define void @quick_sort(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
%7 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
br label %9
9: ; preds = %31, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = icmp sgt i32 %10, %12
br i1 %13, label %29, label %14
14: ; preds = %9
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = icmp sgt i32 %15, %17
br i1 %18, label %29, label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = icmp sgt i32 %20, %21
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 0
br label %29
29: ; preds = %26, %23, %19, %14, %9
%30 = phi i1 [ true, %23 ], [ true, %19 ], [ true, %14 ], [ true, %9 ], [ %28, %26 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
br label %9
34: ; preds = %29
%35 = load i32*, i32** %3
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = call i32 @_quick_sort(i32* %35, i32 %36, i32 %37)
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@str = [67 x i8] c"please input the begin pos and the end pos which you want to sort:\00"
@str.3 = [33 x i8] c"input error, please input again:\00"
define void @quick_sort(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %20, %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, %1
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, %1
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = icmp sgt i32 %10, %13
%17 = or i32 %13, %10
%18 = icmp slt i32 %17, 0
%19 = or i1 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %8, %12, %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.3, i64 0, i64 0))
br label %8
22: ; preds = %15
%23 = call i32 @_quick_sort(i32* %0, i32 %10, i32 %13)
ret void
}