#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 */
struct qnode {
  int dummy;
};
struct node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ count_leaves(struct node *, int *);
int /*<<< orphan*/ destroy_tree(struct node *);
int /*<<< orphan*/ insert(int, struct node **);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int n;
  int input;
  struct node *root = NULL;
  struct qnode *front = NULL;
  struct qnode *rear = NULL;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &input);
    insert(input, &root);
  }
  n = 0;
  count_leaves(root, &n);
  printf("%d", n);
  destroy_tree(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe7b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11c3 <main+0x73>
lea    0xe57(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1070 <insert@plt>
jmp    118e <main+0x3e>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <count_leaves@plt>
mov    -0x14(%rbp),%esi
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <destroy_tree@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    117e <main+0x2e>
xor    %edi,%edi
jmp    11b3 <main+0x63>
lea    0xe7b(%rip),%r14
lea    0x1c(%rsp),%r15
lea    0x10(%rsp),%rbx
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x1c(%rsp),%edi
mov    %rbx,%rsi
call   1070 <insert@plt>
subl   $0x1,0xc(%rsp)
jae    1190 <main+0x40>
mov    0x10(%rsp),%rdi
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1030 <count_leaves@plt>
mov    0xc(%rsp),%esi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
call   1050 <destroy_tree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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