#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*/ add_node(int);
int del_root();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char c;
  int N, weight;
  scanf("%d", &N);
  while (N--) {
    getchar();
    scanf("%c", &c);
    if (c == 'A') {
      scanf("%d", &weight);
      add_node(weight);
    } else
      printf("%d\n", del_root());
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11e4 <main+0x94>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe70(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jne    11ca <main+0x7a>
lea    0xe4e(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1060 <add_node@plt>
jmp    11df <main+0x8f>
mov    $0x0,%al
call   1040 <del_root@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    1171 <main+0x21>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
subl   $0x1,0x8(%rsp)
jb     11f0 <main+0xa0>
lea    0xe85(%rip),%r14
lea    0x7(%rsp),%rbx
lea    0xe76(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe70(%rip),%r13
jmp    11b8 <main+0x68>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <del_root@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     11f0 <main+0xa0>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x41,0x7(%rsp)
jne    11a0 <main+0x50>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <add_node@plt>
subl   $0x1,0x8(%rsp)
jae    11b8 <main+0x68>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %3
%8 = add nsw i32 %7, -1
store i32 %8, i32* %3
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = call i32 (...) @getchar()
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 65
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %4
%19 = call i32 @add_node(i32 %18)
br label %23
20: ; preds = %10
%21 = call i32 (...) @del_root()
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %16
br label %6
24: ; preds = %6
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp eq i32 %7, 0
br i1 %9, label %26, label %10
10: ; preds = %0, %22
%11 = call i32 (...) @getchar()
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 65
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = call i32 @add_node(i32 %17)
br label %22
19: ; preds = %10
%20 = call i32 (...) @del_root()
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %2
%24 = add nsw i32 %23, -1
store i32 %24, i32* %2
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %10
26: ; preds = %22, %0
ret i32 0
}