#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 pnet_graph {
  int dummy;
};
struct net_node {
  int dummy;
};

/* Variables and functions */
struct net_node *pnet_get_module(char *);
int /*<<< orphan*/ pnet_graph_add_node(struct pnet_graph *, struct net_node *);
struct pnet_graph *pnet_graph_create();
int /*<<< orphan*/ pnet_graph_start(struct pnet_graph *);
int /*<<< orphan*/ pnet_node_link(struct net_node *, struct net_node *);
int bt_main(int argc, char **argv) {
  struct pnet_graph *graph;
  struct net_node *node_prev, *node_next;
  graph = pnet_graph_create();
  node_next = pnet_get_module("lego_blue_core");
  pnet_graph_add_node(graph, node_next);
  node_next = pnet_get_module("lego_direct");
  pnet_graph_add_node(graph, node_next);
  pnet_node_link(node_prev, node_next);
  node_prev = node_next;
  node_next = pnet_get_module("nxt direct handler");
  pnet_graph_add_node(graph, node_next);
  pnet_node_link(node_prev, node_next);
  pnet_graph_start(graph);
  return 0;
}


x86 assembly (clang, -O0):
<bt_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <pnet_graph_create@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8f(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <pnet_graph_add_node@plt>
lea    0xe81(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <pnet_graph_add_node@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <pnet_node_link@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe5b(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <pnet_graph_add_node@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <pnet_node_link@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pnet_graph_start@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bt_main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <pnet_graph_create@plt>
mov    %rax,%r14
lea    0xe9a(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <pnet_graph_add_node@plt>
lea    0xe92(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <pnet_graph_add_node@plt>
mov    %r15,%rsi
call   1030 <pnet_node_link@plt>
lea    0xe7c(%rip),%rdi
call   1060 <pnet_get_module@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <pnet_graph_add_node@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <pnet_node_link@plt>
mov    %r14,%rdi
call   1040 <pnet_graph_start@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pnet_graph = type { i32 }
%struct.net_node = type { i32 }
@.str = [15 x i8] c"lego_blue_core\00"
@.str.1 = [12 x i8] c"lego_direct\00"
@.str.2 = [19 x i8] c"nxt direct handler\00"
define i32 @bt_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.pnet_graph*
%6 = alloca %struct.net_node*
%7 = alloca %struct.net_node*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call %struct.pnet_graph* (...) @pnet_graph_create()
store %struct.pnet_graph* %8, %struct.pnet_graph** %5
%9 = call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store %struct.net_node* %9, %struct.net_node** %7
%10 = load %struct.pnet_graph*, %struct.pnet_graph** %5
%11 = load %struct.net_node*, %struct.net_node** %7
%12 = call i32 @pnet_graph_add_node(%struct.pnet_graph* %10, %struct.net_node* %11)
%13 = call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store %struct.net_node* %13, %struct.net_node** %7
%14 = load %struct.pnet_graph*, %struct.pnet_graph** %5
%15 = load %struct.net_node*, %struct.net_node** %7
%16 = call i32 @pnet_graph_add_node(%struct.pnet_graph* %14, %struct.net_node* %15)
%17 = load %struct.net_node*, %struct.net_node** %6
%18 = load %struct.net_node*, %struct.net_node** %7
%19 = call i32 @pnet_node_link(%struct.net_node* %17, %struct.net_node* %18)
%20 = load %struct.net_node*, %struct.net_node** %7
store %struct.net_node* %20, %struct.net_node** %6
%21 = call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store %struct.net_node* %21, %struct.net_node** %7
%22 = load %struct.pnet_graph*, %struct.pnet_graph** %5
%23 = load %struct.net_node*, %struct.net_node** %7
%24 = call i32 @pnet_graph_add_node(%struct.pnet_graph* %22, %struct.net_node* %23)
%25 = load %struct.net_node*, %struct.net_node** %6
%26 = load %struct.net_node*, %struct.net_node** %7
%27 = call i32 @pnet_node_link(%struct.net_node* %25, %struct.net_node* %26)
%28 = load %struct.pnet_graph*, %struct.pnet_graph** %5
%29 = call i32 @pnet_graph_start(%struct.pnet_graph* %28)
ret i32 0
}

LLVM IR (-O2):
%struct.pnet_graph = type { i32 }
%struct.net_node = type { i32 }
@.str = [15 x i8] c"lego_blue_core\00"
@.str.1 = [12 x i8] c"lego_direct\00"
@.str.2 = [19 x i8] c"nxt direct handler\00"
define i32 @bt_main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.pnet_graph* (...) @pnet_graph_create()
%4 = tail call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @pnet_graph_add_node(%struct.pnet_graph* %3, %struct.net_node* %4)
%6 = tail call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @pnet_graph_add_node(%struct.pnet_graph* %3, %struct.net_node* %6)
%8 = tail call i32 @pnet_node_link(%struct.net_node* undef, %struct.net_node* %6)
%9 = tail call %struct.net_node* @pnet_get_module(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @pnet_graph_add_node(%struct.pnet_graph* %3, %struct.net_node* %9)
%11 = tail call i32 @pnet_node_link(%struct.net_node* %6, %struct.net_node* %9)
%12 = tail call i32 @pnet_graph_start(%struct.pnet_graph* %3)
ret i32 0
}