#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 ttrie__iterator {
  int dummy;
};
struct ttrie__frame {
  int dummy;
};

/* Variables and functions */
struct ttrie__frame *ttrie__walk_nodes(struct ttrie__iterator *, int *);
struct ttrie__frame *next_down_node(struct ttrie__iterator *iter) {
  int frame_yield_type;
  struct ttrie__frame *f;
  while (true) {
    f = ttrie__walk_nodes(iter, &frame_yield_type);
    if (f == NULL) {
      return NULL;
    } else if (frame_yield_type == 9) {
      return f;
    }
  }
}


x86 assembly (clang, -O0):
<next_down_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <ttrie__walk_nodes@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1145 <next_down_node+0x35>
movq   $0x0,-0x8(%rbp)
jmp    1166 <next_down_node+0x56>
cmpl   $0x9,-0x14(%rbp)
jne    115c <next_down_node+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1166 <next_down_node+0x56>
jmp    1161 <next_down_node+0x51>
jmp    111c <next_down_node+0xc>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_down_node>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <ttrie__walk_nodes@plt>
test   %rax,%rax
je     1137 <next_down_node+0x27>
cmpl   $0x9,0x4(%rsp)
jne    1120 <next_down_node+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ttrie__frame = type { i32 }
%struct.ttrie__iterator = type { i32 }
define %struct.ttrie__frame* @next_down_node(%struct.ttrie__iterator* %0) {
%2 = alloca %struct.ttrie__frame*
%3 = alloca %struct.ttrie__iterator*
%4 = alloca i32
%5 = alloca %struct.ttrie__frame*
store %struct.ttrie__iterator* %0, %struct.ttrie__iterator** %3
br label %6
6: ; preds = %1, %18
%7 = load %struct.ttrie__iterator*, %struct.ttrie__iterator** %3
%8 = call %struct.ttrie__frame* @ttrie__walk_nodes(%struct.ttrie__iterator* %7, i32* %4)
store %struct.ttrie__frame* %8, %struct.ttrie__frame** %5
%9 = load %struct.ttrie__frame*, %struct.ttrie__frame** %5
%10 = icmp eq %struct.ttrie__frame* %9, null
br i1 %10, label %11, label %12
11: ; preds = %6
store %struct.ttrie__frame* null, %struct.ttrie__frame** %2
br label %19
12: ; preds = %6
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 9
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load %struct.ttrie__frame*, %struct.ttrie__frame** %5
store %struct.ttrie__frame* %16, %struct.ttrie__frame** %2
br label %19
17: ; preds = %12
br label %18
18: ; preds = %17
br label %6
19: ; preds = %15, %11
%20 = load %struct.ttrie__frame*, %struct.ttrie__frame** %2
ret %struct.ttrie__frame* %20
}

LLVM IR (-O2):
%struct.ttrie__frame = type { i32 }
%struct.ttrie__iterator = type { i32 }
define %struct.ttrie__frame* @next_down_node(%struct.ttrie__iterator* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = call %struct.ttrie__frame* @ttrie__walk_nodes(%struct.ttrie__iterator* %0, i32* %2)
%6 = icmp eq %struct.ttrie__frame* %5, null
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 9
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %4
10: ; preds = %4
ret %struct.ttrie__frame* %5
}