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

/* Variables and functions */
int /*<<< orphan*/ __assert_ptr_equals(char *, int, void *, void *);
struct radix_tree *alloc_radix_tree(int, int);
int /*<<< orphan*/ free_radix_tree(struct radix_tree *);
int /*<<< orphan*/ radix_tree_insert(struct radix_tree *, int, void *);
void *radix_tree_lookup_prev(struct radix_tree *, int);
void test_radix_tree_lookup_previous_in_the_same_node(void) {
  struct radix_tree *tree;
  void *result;
  tree = alloc_radix_tree(8, 16);
  radix_tree_insert(tree, 1, (void *)0xcafebabe);
  result = radix_tree_lookup_prev(tree, 100);
  __assert_ptr_equals("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/headius/jato/refs/"
                      "heads/master/test/unit/vm/radix-tree-test.c",
                      66, ((void *)0xcafebabe), (result));
  free_radix_tree(tree);
}


x86 assembly (clang, -O0):
<test_radix_tree_lookup_previous_in_the_same_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x8,%edi
mov    $0x10,%esi
call   1040 <alloc_radix_tree@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0xcafebabe,%edx
call   1050 <radix_tree_insert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
call   1060 <radix_tree_lookup_prev@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xe65(%rip),%rdi
mov    $0x42,%esi
mov    $0xcafebabe,%edx
call   1070 <__assert_ptr_equals@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free_radix_tree@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_radix_tree_lookup_previous_in_the_same_node>:
push   %rbx
mov    $0x8,%edi
mov    $0x10,%esi
call   1040 <alloc_radix_tree@plt>
mov    %rax,%rbx
mov    $0xcafebabe,%edx
mov    %rax,%rdi
mov    $0x1,%esi
call   1050 <radix_tree_insert@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <radix_tree_lookup_prev@plt>
lea    0xe77(%rip),%rdi
mov    $0xcafebabe,%edx
mov    $0x42,%esi
mov    %rax,%rcx
call   1070 <__assert_ptr_equals@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free_radix_tree@plt>

LLVM IR (-O0):
%struct.radix_tree = type { i32 }
@.str = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/headius/jato/refs/heads/master/test/unit/vm/radix-tree-test.c\00"
define void @test_radix_tree_lookup_previous_in_the_same_node() {
%1 = alloca %struct.radix_tree*
%2 = alloca i8*
%3 = call %struct.radix_tree* @alloc_radix_tree(i32 8, i32 16)
store %struct.radix_tree* %3, %struct.radix_tree** %1
%4 = load %struct.radix_tree*, %struct.radix_tree** %1
%5 = call i32 @radix_tree_insert(%struct.radix_tree* %4, i32 1, i8* inttoptr (i64 3405691582 to i8*))
%6 = load %struct.radix_tree*, %struct.radix_tree** %1
%7 = call i8* @radix_tree_lookup_prev(%struct.radix_tree* %6, i32 100)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str, i64 0, i64 0), i32 66, i8* inttoptr (i64 3405691582 to i8*), i8* %8)
%10 = load %struct.radix_tree*, %struct.radix_tree** %1
%11 = call i32 @free_radix_tree(%struct.radix_tree* %10)
ret void
}

LLVM IR (-O2):
%struct.radix_tree = type { i32 }
@.str = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/headius/jato/refs/heads/master/test/unit/vm/radix-tree-test.c\00"
define void @test_radix_tree_lookup_previous_in_the_same_node() {
%1 = tail call %struct.radix_tree* @alloc_radix_tree(i32 8, i32 16)
%2 = tail call i32 @radix_tree_insert(%struct.radix_tree* %1, i32 1, i8* inttoptr (i64 3405691582 to i8*))
%3 = tail call i8* @radix_tree_lookup_prev(%struct.radix_tree* %1, i32 100)
%4 = tail call i32 @__assert_ptr_equals(i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str, i64 0, i64 0), i32 66, i8* inttoptr (i64 3405691582 to i8*), i8* %3)
%5 = tail call i32 @free_radix_tree(%struct.radix_tree* %1)
ret void
}