#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 routing_table {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct routing_table *pirq_alloc_read_table();
int /*<<< orphan*/ pirq_free_table(struct routing_table *);
int /*<<< orphan*/ pirq_unparse_routing_table(struct routing_table *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct routing_table *table;
  table = pirq_alloc_read_table();
  if (!table) {
    fprintf(stderr, "NULL table\n");
    return 1;
  }
  pirq_unparse_routing_table(table);
  pirq_free_table(table);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <pirq_alloc_read_table@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <main+0x4d>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a6 <main+0x66>
mov    -0x18(%rbp),%rdi
call   1030 <pirq_unparse_routing_table@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pirq_free_table@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <pirq_alloc_read_table@plt>
test   %rax,%rax
je     1166 <main+0x26>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <pirq_unparse_routing_table@plt>
mov    %rbx,%rdi
call   1040 <pirq_free_table@plt>
jmp    1180 <main+0x40>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.routing_table = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"NULL table\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.routing_table*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.routing_table* (...) @pirq_alloc_read_table()
store %struct.routing_table* %7, %struct.routing_table** %6
%8 = load %struct.routing_table*, %struct.routing_table** %6
%9 = icmp ne %struct.routing_table* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %18
13: ; preds = %2
%14 = load %struct.routing_table*, %struct.routing_table** %6
%15 = call i32 @pirq_unparse_routing_table(%struct.routing_table* %14)
%16 = load %struct.routing_table*, %struct.routing_table** %6
%17 = call i32 @pirq_free_table(%struct.routing_table* %16)
store i32 0, i32* %3
br label %18
18: ; preds = %13, %10
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.routing_table = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"NULL table\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.routing_table* (...) @pirq_alloc_read_table()
%4 = icmp eq %struct.routing_table* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %2
%9 = tail call i32 @pirq_unparse_routing_table(%struct.routing_table* %3)
%10 = tail call i32 @pirq_free_table(%struct.routing_table* %3)
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ 0, %8 ], [ 1, %5 ]
ret i32 %12
}