#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 Node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ find_node(struct Node *, int);
int /*<<< orphan*/ free_tree(struct Node *);
int /*<<< orphan*/ insert(struct Node **, int);
int /*<<< orphan*/ test_parent(struct Node *, int /*<<< orphan*/);
int /*<<< orphan*/ test_tree_properties(struct Node *);
void test_insert_sequential_ascending() {
  struct Node *root = NULL;
  const int size = 100;
  for (int i = 1; i <= size; i++) {
    insert(&root, i);
    test_parent(root, find_node(root, i));
  }
  test_tree_properties(root);
  free_tree(root);
  root = NULL;
}


x86 assembly (clang, -O0):
<test_insert_sequential_ascending>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jg     11b1 <test_insert_sequential_ascending+0x61>
mov    -0x10(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1060 <insert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <find_node@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1070 <test_parent@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <test_insert_sequential_ascending+0x1e>
mov    -0x8(%rbp),%rdi
call   1050 <test_tree_properties@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free_tree@plt>
movq   $0x0,-0x8(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_insert_sequential_ascending>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
mov    $0x1,%ebx
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <insert@plt>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <find_node@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1070 <test_parent@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1170 <test_insert_sequential_ascending+0x20>
mov    0x8(%rsp),%rdi
call   1050 <test_tree_properties@plt>
mov    0x8(%rsp),%rdi
call   1030 <free_tree@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
define void @test_insert_sequential_ascending() {
%1 = alloca %struct.Node*
%2 = alloca i32
%3 = alloca i32
store %struct.Node* null, %struct.Node** %1
store i32 100, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 100
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call i32 @insert(%struct.Node** %1, i32 %8)
%10 = load %struct.Node*, %struct.Node** %1
%11 = load %struct.Node*, %struct.Node** %1
%12 = load i32, i32* %3
%13 = call i32 @find_node(%struct.Node* %11, i32 %12)
%14 = call i32 @test_parent(%struct.Node* %10, i32 %13)
br label %15
15: ; preds = %7
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %4
18: ; preds = %4
%19 = load %struct.Node*, %struct.Node** %1
%20 = call i32 @test_tree_properties(%struct.Node* %19)
%21 = load %struct.Node*, %struct.Node** %1
%22 = call i32 @free_tree(%struct.Node* %21)
store %struct.Node* null, %struct.Node** %1
ret void
}

LLVM IR (-O2):
%struct.Node = type { i32 }
define void @test_insert_sequential_ascending() {
%1 = alloca %struct.Node*
%2 = bitcast %struct.Node** %1 to i8*
store %struct.Node* null, %struct.Node** %1
br label %8
3: ; preds = %8
%4 = load %struct.Node*, %struct.Node** %1
%5 = call i32 @test_tree_properties(%struct.Node* %4)
%6 = load %struct.Node*, %struct.Node** %1
%7 = call i32 @free_tree(%struct.Node* %6)
ret void
8: ; preds = %0, %8
%9 = phi i32 [ 1, %0 ], [ %14, %8 ]
%10 = call i32 @insert(%struct.Node** %1, i32 %9)
%11 = load %struct.Node*, %struct.Node** %1
%12 = call i32 @find_node(%struct.Node* %11, i32 %9)
%13 = call i32 @test_parent(%struct.Node* %11, i32 %12)
%14 = add nuw nsw i32 %9, 1
%15 = icmp eq i32 %14, 101
br i1 %15, label %3, label %8
}