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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
struct node *get_first_node(struct diagram *);
struct node *get_next_node(struct node *);
int /*<<< orphan*/ print_node(struct node *);
int /*<<< orphan*/ puts(char *);
void print_nodes(struct diagram *diag) {
  assert(diag != NULL);
  puts("nodes:");
  struct node *node = get_first_node(diag);
  while (node != NULL) {
    print_node(node);
    node = get_next_node(node);
  }
}


x86 assembly (clang, -O0):
<print_nodes>:
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   1050 <assert@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rdi
call   1060 <get_first_node@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ad <print_nodes+0x5d>
mov    -0x10(%rbp),%rdi
call   1070 <print_node@plt>
mov    -0x10(%rbp),%rdi
call   1040 <get_next_node@plt>
mov    %rax,-0x10(%rbp)
jmp    1187 <print_nodes+0x37>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_nodes>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <get_first_node@plt>
test   %rax,%rax
je     1198 <print_nodes+0x48>
mov    %rax,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <print_node@plt>
mov    %rbx,%rdi
call   1040 <get_next_node@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <print_nodes+0x30>
pop    %rbx
ret

LLVM IR (-O0):
%struct.diagram = type { i32 }
%struct.node = type { i32 }
@.str = [7 x i8] c"nodes:\00"
define void @print_nodes(%struct.diagram* %0) {
%2 = alloca %struct.diagram*
%3 = alloca %struct.node*
store %struct.diagram* %0, %struct.diagram** %2
%4 = load %struct.diagram*, %struct.diagram** %2
%5 = icmp ne %struct.diagram* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = load %struct.diagram*, %struct.diagram** %2
%10 = call %struct.node* @get_first_node(%struct.diagram* %9)
store %struct.node* %10, %struct.node** %3
br label %11
11: ; preds = %14, %1
%12 = load %struct.node*, %struct.node** %3
%13 = icmp ne %struct.node* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load %struct.node*, %struct.node** %3
%16 = call i32 @print_node(%struct.node* %15)
%17 = load %struct.node*, %struct.node** %3
%18 = call %struct.node* @get_next_node(%struct.node* %17)
store %struct.node* %18, %struct.node** %3
br label %11
19: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.diagram = type { i32 }
%struct.node = type { i32 }
@.str = [7 x i8] c"nodes:\00"
define void @print_nodes(%struct.diagram* %0) {
%2 = icmp ne %struct.diagram* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = tail call %struct.node* @get_first_node(%struct.diagram* %0)
%7 = icmp eq %struct.node* %6, null
br i1 %7, label %13, label %8
8: ; preds = %1, %8
%9 = phi %struct.node* [ %11, %8 ], [ %6, %1 ]
%10 = tail call i32 @print_node(%struct.node* %9)
%11 = tail call %struct.node* @get_next_node(%struct.node* %9)
%12 = icmp eq %struct.node* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %1
ret void
}