#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
void read_pivots(int p, int pv[]) {
  int i;
  printf("  give %d top pivots : ", p);
  for (i = 0; i < p; i++)
    scanf("%d", &pv[i]);
  printf("  give %d bottom pivots : ", p);
  for (i = p; i < 2 * p; i++)
    scanf("%d", &pv[i]);
}


x86 assembly (clang, -O0):
<read_pivots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117a <read_pivots+0x5a>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb1(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <read_pivots+0x25>
mov    -0x4(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11c9 <read_pivots+0xa9>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe62(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <read_pivots+0x6f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_pivots>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%r15d
lea    0xeca(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
test   %r15d,%r15d
jle    1165 <read_pivots+0x45>
mov    %r15d,%r13d
lea    0xecb(%rip),%r12
mov    %r14,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1150 <read_pivots+0x30>
lea    0xeaf(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    (%r15,%r15,1),%eax
cmp    %r15d,%eax
jle    11a5 <read_pivots+0x85>
movslq %r15d,%rax
lea    (%r14,%rax,4),%rbx
lea    0xe8d(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x4,%rbx
add    $0xffffffff,%r15d
jne    1190 <read_pivots+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c" give %d top pivots : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c" give %d bottom pivots : \00"
define void @read_pivots(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = load i32, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
store i32 %24, i32* %5
br label %25
25: ; preds = %36, %21
%26 = load i32, i32* %5
%27 = load i32, i32* %3
%28 = mul nsw i32 2, %27
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %39
30: ; preds = %25
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %25
39: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c" give %d top pivots : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c" give %d bottom pivots : \00"
define void @read_pivots(i32 %0, i32* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %11, %7 ]
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%11 = add nuw nsw i64 %8, 1
%12 = icmp eq i64 %11, %6
br i1 %12, label %13, label %7
13: ; preds = %7, %2
%14 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%15 = shl i32 %0, 1
%16 = icmp sgt i32 %15, %0
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = sext i32 %0 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %18, %17 ], [ %23, %19 ]
%21 = getelementptr inbounds i32, i32* %1, i64 %20
%22 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = add nsw i64 %20, 1
%24 = trunc i64 %23 to i32
%25 = icmp eq i32 %15, %24
br i1 %25, label %26, label %19
26: ; preds = %19, %13
ret void
}