#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 sockaddr_storage {
  int dummy;
};
struct patricia_node {
  int dummy;
};

/* Variables and functions */
int ENOENT;
int ptree_search_data_r_x(struct patricia_node *, void *, size_t,
                          struct sockaddr_storage *, size_t *, size_t);
int ptree_search_data_exact(void *str, size_t sstr,
                            struct sockaddr_storage *addr, size_t *alen,
                            struct patricia_node *root) {
  if (!root)
    return -ENOENT;
  return ptree_search_data_r_x(root, str, sstr, addr, alen, sstr * 8);
}


x86 assembly (clang, -O0):
<ptree_search_data_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    114a <ptree_search_data_exact+0x3a>
xor    %eax,%eax
mov    0x2e98(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    116e <ptree_search_data_exact+0x5e>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x18(%rbp),%r9
shl    $0x3,%r9
call   1030 <ptree_search_data_r_x@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptree_search_data_exact>:
test   %r8,%r8
je     1134 <ptree_search_data_exact+0x24>
mov    %rcx,%rax
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%rsi
lea    0x0(,%rdx,8),%r9
mov    %r8,%rdi
mov    %rax,%r8
jmp    1030 <ptree_search_data_r_x@plt>
mov    0x2e9d(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.patricia_node = type { i32 }
@ENOENT = global i32 0
define i32 @ptree_search_data_exact(i8* %0, i64 %1, %struct.sockaddr_storage* %2, i64* %3, %struct.patricia_node* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.sockaddr_storage*
%10 = alloca i64*
%11 = alloca %struct.patricia_node*
store i8* %0, i8** %7
store i64 %1, i64* %8
store %struct.sockaddr_storage* %2, %struct.sockaddr_storage** %9
store i64* %3, i64** %10
store %struct.patricia_node* %4, %struct.patricia_node** %11
%12 = load %struct.patricia_node*, %struct.patricia_node** %11
%13 = icmp ne %struct.patricia_node* %12, null
br i1 %13, label %17, label %14
14: ; preds = %5
%15 = load i32, i32* @ENOENT
%16 = sub nsw i32 0, %15
store i32 %16, i32* %6
br label %26
17: ; preds = %5
%18 = load %struct.patricia_node*, %struct.patricia_node** %11
%19 = load i8*, i8** %7
%20 = load i64, i64* %8
%21 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %9
%22 = load i64*, i64** %10
%23 = load i64, i64* %8
%24 = mul i64 %23, 8
%25 = call i32 @ptree_search_data_r_x(%struct.patricia_node* %18, i8* %19, i64 %20, %struct.sockaddr_storage* %21, i64* %22, i64 %24)
store i32 %25, i32* %6
br label %26
26: ; preds = %17, %14
%27 = load i32, i32* %6
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.patricia_node = type { i32 }
@ENOENT = global i32 0
define i32 @ptree_search_data_exact(i8* %0, i64 %1, %struct.sockaddr_storage* %2, i64* %3, %struct.patricia_node* %4) {
%6 = icmp eq %struct.patricia_node* %4, null
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = load i32, i32* @ENOENT
%9 = sub nsw i32 0, %8
br label %13
10: ; preds = %5
%11 = shl i64 %1, 3
%12 = tail call i32 @ptree_search_data_r_x(%struct.patricia_node* %4, i8* %0, i64 %1, %struct.sockaddr_storage* %2, i64* %3, i64 %11)
br label %13
13: ; preds = %10, %7
%14 = phi i32 [ %12, %10 ], [ %9, %7 ]
ret i32 %14
}