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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
struct trie_node *trie_node_get_negative(struct trie_node *);
struct trie_node *trie_node_get_parent(struct trie_node *);
struct trie_node *trie_node_get_chain_parent(struct trie_node *node) {
  assert(node != NULL);
  while (trie_node_get_negative(node)) {
    node = trie_node_get_negative(node);
  }
  return trie_node_get_parent(node);
}


x86 assembly (clang, -O0):
<trie_node_get_chain_parent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <trie_node_get_negative@plt>
cmp    $0x0,%rax
je     1173 <trie_node_get_chain_parent+0x43>
mov    -0x8(%rbp),%rdi
call   1030 <trie_node_get_negative@plt>
mov    %rax,-0x8(%rbp)
jmp    114e <trie_node_get_chain_parent+0x1e>
mov    -0x8(%rbp),%rdi
call   1050 <trie_node_get_parent@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trie_node_get_chain_parent>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <trie_node_get_negative@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     116a <trie_node_get_chain_parent+0x3a>
call   1030 <trie_node_get_negative@plt>
mov    %rax,%rbx
mov    %rax,%rdi
jmp    1150 <trie_node_get_chain_parent+0x20>
pop    %rbx
jmp    1050 <trie_node_get_parent@plt>

LLVM IR (-O0):
%struct.trie_node = type { i32 }
define %struct.trie_node* @trie_node_get_chain_parent(%struct.trie_node* %0) {
%2 = alloca %struct.trie_node*
store %struct.trie_node* %0, %struct.trie_node** %2
%3 = load %struct.trie_node*, %struct.trie_node** %2
%4 = icmp ne %struct.trie_node* %3, null
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
br label %7
7: ; preds = %11, %1
%8 = load %struct.trie_node*, %struct.trie_node** %2
%9 = call %struct.trie_node* @trie_node_get_negative(%struct.trie_node* %8)
%10 = icmp ne %struct.trie_node* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load %struct.trie_node*, %struct.trie_node** %2
%13 = call %struct.trie_node* @trie_node_get_negative(%struct.trie_node* %12)
store %struct.trie_node* %13, %struct.trie_node** %2
br label %7
14: ; preds = %7
%15 = load %struct.trie_node*, %struct.trie_node** %2
%16 = call %struct.trie_node* @trie_node_get_parent(%struct.trie_node* %15)
ret %struct.trie_node* %16
}

LLVM IR (-O2):
%struct.trie_node = type { i32 }
define %struct.trie_node* @trie_node_get_chain_parent(%struct.trie_node* %0) {
%2 = icmp ne %struct.trie_node* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call %struct.trie_node* @trie_node_get_negative(%struct.trie_node* %0)
%6 = icmp eq %struct.trie_node* %5, null
br i1 %6, label %12, label %7
7: ; preds = %1, %7
%8 = phi %struct.trie_node* [ %9, %7 ], [ %0, %1 ]
%9 = tail call %struct.trie_node* @trie_node_get_negative(%struct.trie_node* %8)
%10 = tail call %struct.trie_node* @trie_node_get_negative(%struct.trie_node* %9)
%11 = icmp eq %struct.trie_node* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %1
%13 = phi %struct.trie_node* [ %0, %1 ], [ %9, %7 ]
%14 = tail call %struct.trie_node* @trie_node_get_parent(%struct.trie_node* %13)
ret %struct.trie_node* %14
}