#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 tree {
  int dummy;
};
typedef struct node node;

/* Variables and functions */
struct node *tree_min_node(struct tree *);
struct node *tree_next_node(struct tree *, struct node *);
__attribute__((unused)) void tree_apply_node(struct tree *t,
                                             void (*cb)(struct node *)) {
  {
    struct node *e;
    for (e = tree_min_node(t); e != NULL; e = tree_next_node(t, e)) {
      cb(e);
    }
  };
}


x86 assembly (clang, -O0):
<tree_apply_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <tree_min_node@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1168 <tree_apply_node+0x48>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rdi
call   *%rax
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <tree_next_node@plt>
mov    %rax,-0x18(%rbp)
jmp    113d <tree_apply_node+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tree_apply_node>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <tree_min_node@plt>
test   %rax,%rax
je     1159 <tree_apply_node+0x39>
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <tree_next_node@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1140 <tree_apply_node+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tree = type { i32 }
%struct.node = type opaque
define void @tree_apply_node(%struct.tree* %0, void (%struct.node*)* %1) {
%3 = alloca %struct.tree*
%4 = alloca void (%struct.node*)*
%5 = alloca %struct.node*
store %struct.tree* %0, %struct.tree** %3
store void (%struct.node*)* %1, void (%struct.node*)** %4
%6 = load %struct.tree*, %struct.tree** %3
%7 = call %struct.node* @tree_min_node(%struct.tree* %6)
store %struct.node* %7, %struct.node** %5
br label %8
8: ; preds = %14, %2
%9 = load %struct.node*, %struct.node** %5
%10 = icmp ne %struct.node* %9, null
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load void (%struct.node*)*, void (%struct.node*)** %4
%13 = load %struct.node*, %struct.node** %5
br label %14
14: ; preds = %11
%15 = load %struct.tree*, %struct.tree** %3
%16 = load %struct.node*, %struct.node** %5
%17 = call %struct.node* @tree_next_node(%struct.tree* %15, %struct.node* %16)
store %struct.node* %17, %struct.node** %5
br label %8
18: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.tree = type { i32 }
%struct.node = type opaque
define void @tree_apply_node(%struct.tree* %0, void (%struct.node*)* nocapture %1) {
%3 = tail call %struct.node* @tree_min_node(%struct.tree* %0)
%4 = icmp eq %struct.node* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2, %5
%6 = phi %struct.node* [ %7, %5 ], [ %3, %2 ]
tail call void %1(%struct.node* %6)
%7 = tail call %struct.node* @tree_next_node(%struct.tree* %0, %struct.node* %6)
%8 = icmp eq %struct.node* %7, null
br i1 %8, label %9, label %5
9: ; preds = %5, %2
ret void
}