#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 PQdelmax();
int /*<<< orphan*/ PQempty();
int /*<<< orphan*/ PQinit(int);
int /*<<< orphan*/ PQinsert(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i;
  srand(time(NULL));
  PQinit(20);
  for (i = 0; i <= 20; ++i) {
    PQinsert(rand() % 20);
  }
  while (!PQempty()) {
    printf("%d ", PQdelmax());
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    $0x14,%edi
call   1080 <PQinit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     11de <main+0x5e>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <PQinsert@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b0 <main+0x30>
jmp    11e3 <main+0x63>
mov    $0x0,%al
call   1060 <PQempty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ff <main+0x7f>
jmp    121b <main+0x9b>
mov    $0x0,%al
call   1030 <PQdelmax@plt>
mov    %eax,%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e3 <main+0x63>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    $0x14,%edi
call   1090 <PQinit@plt>
mov    $0x15,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   1050 <PQinsert@plt>
add    $0xffffffff,%ebx
jne    11b0 <main+0x20>
xor    %eax,%eax
call   1070 <PQempty@plt>
test   %eax,%eax
jne    121e <main+0x8e>
lea    0xe0e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <PQdelmax@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <PQempty@plt>
test   %eax,%eax
je     1200 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = call i32 @PQinit(i32 20)
store i32 0, i32* %2
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 20
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 20
%12 = call i32 @PQinsert(i32 %11)
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
br label %17
17: ; preds = %21, %16
%18 = call i32 (...) @PQempty()
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = call i32 (...) @PQdelmax()
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %17
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @PQinit(i32 20)
br label %7
4: ; preds = %7
%5 = tail call i32 (...) @PQempty()
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %19
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %12, %7 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 20
%11 = tail call i32 @PQinsert(i32 %10)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, 21
br i1 %13, label %4, label %7
14: ; preds = %4, %14
%15 = tail call i32 (...) @PQdelmax()
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = tail call i32 (...) @PQempty()
%18 = icmp eq i32 %17, 0
br i1 %18, label %14, label %19
19: ; preds = %14, %4
%20 = tail call i32 @putchar(i32 10)
ret i32 0
}