#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 *);
int /*<<< orphan*/ trie_node_set_parent(struct trie_node *, struct trie_node *);
void trie_node_set_chain_parent(struct trie_node *node,
                                struct trie_node *parent) {
  assert(node != NULL);
  while (trie_node_get_negative(node)) {
    node = trie_node_get_negative(node);
  }
  trie_node_set_parent(node, parent);
}


x86 assembly (clang, -O0):
<trie_node_set_chain_parent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <trie_node_get_negative@plt>
cmp    $0x0,%rax
je     1177 <trie_node_set_chain_parent+0x47>
mov    -0x8(%rbp),%rdi
call   1030 <trie_node_get_negative@plt>
mov    %rax,-0x8(%rbp)
jmp    1152 <trie_node_set_chain_parent+0x22>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <trie_node_set_parent@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trie_node_set_chain_parent>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
nopl   0x0(%rax,%rax,1)
call   1030 <trie_node_get_negative@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     116a <trie_node_set_chain_parent+0x3a>
call   1030 <trie_node_get_negative@plt>
mov    %rax,%rbx
mov    %rax,%rdi
jmp    1150 <trie_node_set_chain_parent+0x20>
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <trie_node_set_parent@plt>

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

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