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

/* Variables and functions */
int /*<<< orphan*/ free_tree(struct Node *);
int /*<<< orphan*/ insert(struct Node **, int);
int /*<<< orphan*/ remove_node(struct Node **, int);
int /*<<< orphan*/ test_tree_properties(struct Node *);
void test_remove_complex_6() {
  struct Node *root = NULL;
  int items[] = {63, 85, 26, 15, 19, 4, 73, 60, 83};
  for (size_t i = 0; i < sizeof(items) / sizeof(items[0]); i++) {
    insert(&root, items[i]);
  };
  test_tree_properties(root);
  int removable[] = {26, 19, 63, 4, 60, 15, 85};
  for (size_t i = 0; i < sizeof(removable) / sizeof(removable[0]); i++) {
    remove_node(&root, removable[i]);
  };
  test_tree_properties(root);
  free_tree(root);
  root = NULL;
}


x86 assembly (clang, -O0):
<test_remove_complex_6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movq   $0x0,-0x38(%rbp)
cmpq   $0x9,-0x38(%rbp)
jae    11aa <test_remove_complex_6+0x5a>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    -0x8(%rbp),%rdi
call   1070 <insert@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    117d <test_remove_complex_6+0x2d>
mov    -0x8(%rbp),%rdi
call   1040 <test_tree_properties@plt>
mov    0xe76(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe6e(%rip),%eax
mov    %eax,-0x48(%rbp)
movq   $0x0,-0x68(%rbp)
cmpq   $0x7,-0x68(%rbp)
jae    1212 <test_remove_complex_6+0xc2>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    -0x8(%rbp),%rdi
call   1060 <remove_node@plt>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    11e5 <test_remove_complex_6+0x95>
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_remove_complex_6>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3f,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x55,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x1a,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x49,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x53,%esi
call   1060 <insert@plt>
mov    0x8(%rsp),%rdi
call   1040 <test_tree_properties@plt>
mov    %rbx,%rdi
mov    $0x1a,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0x3f,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
call   1050 <remove_node@plt>
mov    %rbx,%rdi
mov    $0x55,%esi
call   1050 <remove_node@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_remove_complex_6.items = [9 x i32] [i32 63, i32 85, i32 26, i32 15, i32 19, i32 4, i32 73, i32 60, i32 83]
@__const.test_remove_complex_6.removable = [7 x i32] [i32 26, i32 19, i32 63, i32 4, i32 60, i32 15, i32 85]
define void @test_remove_complex_6() {
%1 = alloca %struct.Node*
%2 = alloca [9 x i32]
%3 = alloca i64
%4 = alloca [7 x i32]
%5 = alloca i64
store %struct.Node* null, %struct.Node** %1
%6 = bitcast [9 x i32]* %2 to i8*
store i64 0, i64* %3
br label %7
7: ; preds = %15, %0
%8 = load i64, i64* %3
%9 = icmp ult i64 %8, 9
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i64, i64* %3
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = call i32 @insert(%struct.Node** %1, i32 %13)
br label %15
15: ; preds = %10
%16 = load i64, i64* %3
%17 = add i64 %16, 1
store i64 %17, i64* %3
br label %7
18: ; preds = %7
%19 = load %struct.Node*, %struct.Node** %1
%20 = call i32 @test_tree_properties(%struct.Node* %19)
%21 = bitcast [7 x i32]* %4 to i8*
store i64 0, i64* %5
br label %22
22: ; preds = %30, %18
%23 = load i64, i64* %5
%24 = icmp ult i64 %23, 7
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i64, i64* %5
%27 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @remove_node(%struct.Node** %1, i32 %28)
br label %30
30: ; preds = %25
%31 = load i64, i64* %5
%32 = add i64 %31, 1
store i64 %32, i64* %5
br label %22
33: ; preds = %22
%34 = load %struct.Node*, %struct.Node** %1
%35 = call i32 @test_tree_properties(%struct.Node* %34)
%36 = load %struct.Node*, %struct.Node** %1
%37 = call i32 @free_tree(%struct.Node* %36)
store %struct.Node* null, %struct.Node** %1
ret void
}

LLVM IR (-O2):
%struct.Node = type { i32 }
define void @test_remove_complex_6() {
%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 63)
%4 = call i32 @insert(%struct.Node** %1, i32 85)
%5 = call i32 @insert(%struct.Node** %1, i32 26)
%6 = call i32 @insert(%struct.Node** %1, i32 15)
%7 = call i32 @insert(%struct.Node** %1, i32 19)
%8 = call i32 @insert(%struct.Node** %1, i32 4)
%9 = call i32 @insert(%struct.Node** %1, i32 73)
%10 = call i32 @insert(%struct.Node** %1, i32 60)
%11 = call i32 @insert(%struct.Node** %1, i32 83)
%12 = load %struct.Node*, %struct.Node** %1
%13 = call i32 @test_tree_properties(%struct.Node* %12)
%14 = call i32 @remove_node(%struct.Node** %1, i32 26)
%15 = call i32 @remove_node(%struct.Node** %1, i32 19)
%16 = call i32 @remove_node(%struct.Node** %1, i32 63)
%17 = call i32 @remove_node(%struct.Node** %1, i32 4)
%18 = call i32 @remove_node(%struct.Node** %1, i32 60)
%19 = call i32 @remove_node(%struct.Node** %1, i32 15)
%20 = call i32 @remove_node(%struct.Node** %1, i32 85)
%21 = load %struct.Node*, %struct.Node** %1
%22 = call i32 @test_tree_properties(%struct.Node* %21)
%23 = load %struct.Node*, %struct.Node** %1
%24 = call i32 @free_tree(%struct.Node* %23)
ret void
}