#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;
};
typedef int /*<<< orphan*/ items;

/* Variables and functions */
int /*<<< orphan*/ free_tree(struct Node *);
int /*<<< orphan*/ insert(struct Node **, int);
int /*<<< orphan*/ test_tree_properties(struct Node *);
void test_insert_complex_2() {
  struct Node *root = NULL;
  int items[] = {50, 46, 92, 83, 16, 99, 43, 38, 26, 15, 39,
                 65, 45, 51, 79, 37, 35, 28, 60, 78, 76};
  for (size_t i = 0; i < sizeof(items) / sizeof(items[0]); i++) {
    insert(&root, items[i]);
  };
  test_tree_properties(root);
  free_tree(root);
  root = NULL;
}


x86 assembly (clang, -O0):
<test_insert_complex_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea5(%rip),%rsi
mov    $0x54,%edx
call   1050 <memcpy@plt>
movq   $0x0,-0x68(%rbp)
cmpq   $0x15,-0x68(%rbp)
jae    119a <test_insert_complex_2+0x5a>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    -0x8(%rbp),%rdi
call   1060 <insert@plt>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    116d <test_insert_complex_2+0x2d>
mov    -0x8(%rbp),%rdi
call   1040 <test_tree_properties@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free_tree@plt>
movq   $0x0,-0x8(%rbp)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_insert_complex_2>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x53,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x2b,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x26,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x1a,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x27,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x33,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x4f,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x25,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x1c,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x4e,%esi
call   1050 <insert@plt>
mov    %rbx,%rdi
mov    $0x4c,%esi
call   1050 <insert@plt>
mov    0x8(%rsp),%rdi
call   1040 <test_tree_properties@plt>
mov    0x8(%rsp),%rdi
call   1030 <free_tree@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@__const.test_insert_complex_2.items = [21 x i32] [i32 50, i32 46, i32 92, i32 83, i32 16, i32 99, i32 43, i32 38, i32 26, i32 15, i32 39, i32 65, i32 45, i32 51, i32 79, i32 37, i32 35, i32 28, i32 60, i32 78, i32 76]
define void @test_insert_complex_2() {
%1 = alloca %struct.Node*
%2 = alloca [21 x i32]
%3 = alloca i64
store %struct.Node* null, %struct.Node** %1
%4 = bitcast [21 x i32]* %2 to i8*
store i64 0, i64* %3
br label %5
5: ; preds = %13, %0
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 21
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i64, i64* %3
%10 = getelementptr inbounds [21 x i32], [21 x i32]* %2, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = call i32 @insert(%struct.Node** %1, i32 %11)
br label %13
13: ; preds = %8
%14 = load i64, i64* %3
%15 = add i64 %14, 1
store i64 %15, i64* %3
br label %5
16: ; preds = %5
%17 = load %struct.Node*, %struct.Node** %1
%18 = call i32 @test_tree_properties(%struct.Node* %17)
%19 = load %struct.Node*, %struct.Node** %1
%20 = call i32 @free_tree(%struct.Node* %19)
store %struct.Node* null, %struct.Node** %1
ret void
}

LLVM IR (-O2):
%struct.Node = type { i32 }
define void @test_insert_complex_2() {
%1 = alloca %struct.Node*
%2 = bitcast %struct.Node** %1 to i8*
store %struct.Node* null, %struct.Node** %1
%3 = call i32 @insert(%struct.Node** %1, i32 50)
%4 = call i32 @insert(%struct.Node** %1, i32 46)
%5 = call i32 @insert(%struct.Node** %1, i32 92)
%6 = call i32 @insert(%struct.Node** %1, i32 83)
%7 = call i32 @insert(%struct.Node** %1, i32 16)
%8 = call i32 @insert(%struct.Node** %1, i32 99)
%9 = call i32 @insert(%struct.Node** %1, i32 43)
%10 = call i32 @insert(%struct.Node** %1, i32 38)
%11 = call i32 @insert(%struct.Node** %1, i32 26)
%12 = call i32 @insert(%struct.Node** %1, i32 15)
%13 = call i32 @insert(%struct.Node** %1, i32 39)
%14 = call i32 @insert(%struct.Node** %1, i32 65)
%15 = call i32 @insert(%struct.Node** %1, i32 45)
%16 = call i32 @insert(%struct.Node** %1, i32 51)
%17 = call i32 @insert(%struct.Node** %1, i32 79)
%18 = call i32 @insert(%struct.Node** %1, i32 37)
%19 = call i32 @insert(%struct.Node** %1, i32 35)
%20 = call i32 @insert(%struct.Node** %1, i32 28)
%21 = call i32 @insert(%struct.Node** %1, i32 60)
%22 = call i32 @insert(%struct.Node** %1, i32 78)
%23 = call i32 @insert(%struct.Node** %1, i32 76)
%24 = load %struct.Node*, %struct.Node** %1
%25 = call i32 @test_tree_properties(%struct.Node* %24)
%26 = load %struct.Node*, %struct.Node** %1
%27 = call i32 @free_tree(%struct.Node* %26)
ret void
}