#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 mdea_parser {
  int dummy;
};
struct mdea_output {
  int dummy;
};
struct mdea_node {
  int dummy;
};
struct mdea_emitter {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mdea_emitter_destroy(struct mdea_emitter *);
struct mdea_output *mdea_file_output(int);
struct mdea_emitter *mdea_json_emitter(struct mdea_output *);
struct mdea_parser *mdea_node_parser(struct mdea_node *);
int /*<<< orphan*/ mdea_output_destroy(struct mdea_output *);
int mdea_parse(struct mdea_parser *, struct mdea_emitter *, char **);
int /*<<< orphan*/ mdea_parser_destroy(struct mdea_parser *);
int mdea_node_to_file_desc(struct mdea_node *node, int file, char **error) {
  struct mdea_parser *p = mdea_node_parser(node);
  struct mdea_output *o = mdea_file_output(file);
  struct mdea_emitter *e = mdea_json_emitter(o);
  int ret = mdea_parse(p, e, error);
  mdea_parser_destroy(p);
  mdea_emitter_destroy(e);
  mdea_output_destroy(o);
  return ret;
}


x86 assembly (clang, -O0):
<mdea_node_to_file_desc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <mdea_node_parser@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1090 <mdea_file_output@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <mdea_json_emitter@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <mdea_parse@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <mdea_parser_destroy@plt>
mov    -0x30(%rbp),%rdi
call   1080 <mdea_emitter_destroy@plt>
mov    -0x28(%rbp),%rdi
call   1050 <mdea_output_destroy@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdea_node_to_file_desc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
call   1070 <mdea_node_parser@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1090 <mdea_file_output@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <mdea_json_emitter@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <mdea_parse@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <mdea_parser_destroy@plt>
mov    %rbp,%rdi
call   1080 <mdea_emitter_destroy@plt>
mov    %r15,%rdi
call   1050 <mdea_output_destroy@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mdea_node = type { i32 }
%struct.mdea_parser = type { i32 }
%struct.mdea_output = type { i32 }
%struct.mdea_emitter = type { i32 }
define i32 @mdea_node_to_file_desc(%struct.mdea_node* %0, i32 %1, i8** %2) {
%4 = alloca %struct.mdea_node*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca %struct.mdea_parser*
%8 = alloca %struct.mdea_output*
%9 = alloca %struct.mdea_emitter*
%10 = alloca i32
store %struct.mdea_node* %0, %struct.mdea_node** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%11 = load %struct.mdea_node*, %struct.mdea_node** %4
%12 = call %struct.mdea_parser* @mdea_node_parser(%struct.mdea_node* %11)
store %struct.mdea_parser* %12, %struct.mdea_parser** %7
%13 = load i32, i32* %5
%14 = call %struct.mdea_output* @mdea_file_output(i32 %13)
store %struct.mdea_output* %14, %struct.mdea_output** %8
%15 = load %struct.mdea_output*, %struct.mdea_output** %8
%16 = call %struct.mdea_emitter* @mdea_json_emitter(%struct.mdea_output* %15)
store %struct.mdea_emitter* %16, %struct.mdea_emitter** %9
%17 = load %struct.mdea_parser*, %struct.mdea_parser** %7
%18 = load %struct.mdea_emitter*, %struct.mdea_emitter** %9
%19 = load i8**, i8*** %6
%20 = call i32 @mdea_parse(%struct.mdea_parser* %17, %struct.mdea_emitter* %18, i8** %19)
store i32 %20, i32* %10
%21 = load %struct.mdea_parser*, %struct.mdea_parser** %7
%22 = call i32 @mdea_parser_destroy(%struct.mdea_parser* %21)
%23 = load %struct.mdea_emitter*, %struct.mdea_emitter** %9
%24 = call i32 @mdea_emitter_destroy(%struct.mdea_emitter* %23)
%25 = load %struct.mdea_output*, %struct.mdea_output** %8
%26 = call i32 @mdea_output_destroy(%struct.mdea_output* %25)
%27 = load i32, i32* %10
ret i32 %27
}

LLVM IR (-O2):
%struct.mdea_node = type { i32 }
%struct.mdea_parser = type { i32 }
%struct.mdea_output = type { i32 }
%struct.mdea_emitter = type { i32 }
define i32 @mdea_node_to_file_desc(%struct.mdea_node* %0, i32 %1, i8** %2) {
%4 = tail call %struct.mdea_parser* @mdea_node_parser(%struct.mdea_node* %0)
%5 = tail call %struct.mdea_output* @mdea_file_output(i32 %1)
%6 = tail call %struct.mdea_emitter* @mdea_json_emitter(%struct.mdea_output* %5)
%7 = tail call i32 @mdea_parse(%struct.mdea_parser* %4, %struct.mdea_emitter* %6, i8** %2)
%8 = tail call i32 @mdea_parser_destroy(%struct.mdea_parser* %4)
%9 = tail call i32 @mdea_emitter_destroy(%struct.mdea_emitter* %6)
%10 = tail call i32 @mdea_output_destroy(%struct.mdea_output* %5)
ret i32 %7
}