#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 gges_derivation_tree {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ output_node(int /*<<< orphan*/ *, int,
                               struct gges_derivation_tree *, char *, int *);
void gges_visualise_derivation_tree(FILE *f, struct gges_derivation_tree *dt,
                                    char *graphname, char *nodeprefix) {
  int i;
  if (dt == NULL)
    return;
  if (graphname == NULL) {
    fputs("digraph DERIVATION {\n", f);
  } else {
    fprintf(f, "digraph %s {\n", graphname);
  }
  fputs("    graph[ratio=fill,center=1];\n", f);
  fputs("    node[shape=none, fontsize=48];\n\n", f);
  i = 0;
  if (nodeprefix == NULL) {
    output_node(f, -1, dt, "N", &i);
  } else {
    output_node(f, -1, dt, nodeprefix, &i);
  }
  fputs("}\n", f);
}


x86 assembly (clang, -O0):
<gges_visualise_derivation_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <gges_visualise_derivation_tree+0x28>
jmp    120a <gges_visualise_derivation_tree+0xda>
cmpq   $0x0,-0x18(%rbp)
jne    1178 <gges_visualise_derivation_tree+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1040 <fputs@plt>
jmp    118c <gges_visualise_derivation_tree+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x8(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e0 <gges_visualise_derivation_tree+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xffffffff,%esi
lea    0xe98(%rip),%rcx
lea    -0x24(%rbp),%r8
call   1030 <output_node@plt>
jmp    11fa <gges_visualise_derivation_tree+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xffffffff,%esi
lea    -0x24(%rbp),%r8
call   1030 <output_node@plt>
mov    -0x8(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <fputs@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gges_visualise_derivation_tree>:
test   %rsi,%rsi
je     120c <gges_visualise_derivation_tree+0xdc>
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdx,%rdx
je     1161 <gges_visualise_derivation_tree+0x31>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fprintf@plt>
jmp    117a <gges_visualise_derivation_tree+0x4a>
lea    0xe98(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0xea3(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0xeab(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
movl   $0x0,0xc(%rsp)
test   %r15,%r15
je     11ce <gges_visualise_derivation_tree+0x9e>
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    %r14,%rdx
mov    %r15,%rcx
jmp    11e5 <gges_visualise_derivation_tree+0xb5>
lea    0xe95(%rip),%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    %r14,%rdx
call   1030 <output_node@plt>
lea    0xe7b(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.gges_derivation_tree = type { i32 }
@.str = [22 x i8] c"digraph DERIVATION {\0A\00"
@.str.1 = [14 x i8] c"digraph %s {\0A\00"
@.str.2 = [33 x i8] c" graph[ratio=fill,center=1];\0A\00"
@.str.3 = [37 x i8] c" node[shape=none, fontsize=48];\0A\0A\00"
@.str.4 = [2 x i8] c"N\00"
@.str.5 = [3 x i8] c"}\0A\00"
define void @gges_visualise_derivation_tree(i32* %0, %struct.gges_derivation_tree* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca %struct.gges_derivation_tree*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %5
store %struct.gges_derivation_tree* %1, %struct.gges_derivation_tree** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load %struct.gges_derivation_tree*, %struct.gges_derivation_tree** %6
%11 = icmp eq %struct.gges_derivation_tree* %10, null
br i1 %11, label %12, label %13
12: ; preds = %4
br label %42
13: ; preds = %4
%14 = load i8*, i8** %7
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32*, i32** %5
%18 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %17)
br label %23
19: ; preds = %13
%20 = load i32*, i32** %5
%21 = load i8*, i8** %7
%22 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16
%24 = load i32*, i32** %5
%25 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32* %26)
store i32 0, i32* %9
%28 = load i8*, i8** %8
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = load i32*, i32** %5
%32 = load %struct.gges_derivation_tree*, %struct.gges_derivation_tree** %6
%33 = call i32 @output_node(i32* %31, i32 -1, %struct.gges_derivation_tree* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %9)
br label %39
34: ; preds = %23
%35 = load i32*, i32** %5
%36 = load %struct.gges_derivation_tree*, %struct.gges_derivation_tree** %6
%37 = load i8*, i8** %8
%38 = call i32 @output_node(i32* %35, i32 -1, %struct.gges_derivation_tree* %36, i8* %37, i32* %9)
br label %39
39: ; preds = %34, %30
%40 = load i32*, i32** %5
%41 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %40)
br label %42
42: ; preds = %39, %12
ret void
}

LLVM IR (-O2):
%struct.gges_derivation_tree = type { i32 }
@.str = [22 x i8] c"digraph DERIVATION {\0A\00"
@.str.1 = [14 x i8] c"digraph %s {\0A\00"
@.str.2 = [33 x i8] c" graph[ratio=fill,center=1];\0A\00"
@.str.3 = [37 x i8] c" node[shape=none, fontsize=48];\0A\0A\00"
@.str.4 = [2 x i8] c"N\00"
@.str.5 = [3 x i8] c"}\0A\00"
define void @gges_visualise_derivation_tree(i32* %0, %struct.gges_derivation_tree* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp eq %struct.gges_derivation_tree* %1, null
br i1 %7, label %24, label %8
8: ; preds = %4
%9 = icmp eq i8* %2, null
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 21, i64 1, i32* %0)
br label %14
12: ; preds = %8
%13 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %14
14: ; preds = %12, %10
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i64 32, i64 1, i32* %0)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i64 36, i64 1, i32* %0)
store i32 0, i32* %5
%17 = icmp eq i8* %3, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @output_node(i32* %0, i32 -1, %struct.gges_derivation_tree* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %5)
br label %22
20: ; preds = %14
%21 = call i32 @output_node(i32* %0, i32 -1, %struct.gges_derivation_tree* %1, i8* %3, i32* %5)
br label %22
22: ; preds = %20, %18
%23 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %24
24: ; preds = %4, %22
ret void
}