#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_node {
  int dummy;
};
struct mdea_input {
  int dummy;
};
struct mdea_emitter {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mdea_emitter_destroy(struct mdea_emitter *);
struct mdea_input *mdea_file_input(int);
int /*<<< orphan*/ mdea_input_destroy(struct mdea_input *);
struct mdea_parser *mdea_json_parser(struct mdea_input *);
struct mdea_emitter *mdea_node_emitter(struct mdea_node **);
int mdea_parse(struct mdea_parser *, struct mdea_emitter *, char **);
int /*<<< orphan*/ mdea_parser_destroy(struct mdea_parser *);
int mdea_node_from_file_desc(int file, struct mdea_node **node, char **error) {
  struct mdea_input *i = mdea_file_input(file);
  struct mdea_parser *p = mdea_json_parser(i);
  struct mdea_emitter *e = mdea_node_emitter(node);
  int ret = mdea_parse(p, e, error);
  mdea_parser_destroy(p);
  mdea_emitter_destroy(e);
  mdea_input_destroy(i);
  return ret;
}


x86 assembly (clang, -O0):
<mdea_node_from_file_desc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <mdea_file_input@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <mdea_json_parser@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <mdea_node_emitter@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <mdea_parse@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <mdea_parser_destroy@plt>
mov    -0x30(%rbp),%rdi
call   1070 <mdea_emitter_destroy@plt>
mov    -0x20(%rbp),%rdi
call   1060 <mdea_input_destroy@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdea_node_from_file_desc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
call   1080 <mdea_file_input@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <mdea_json_parser@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1090 <mdea_node_emitter@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <mdea_parse@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1040 <mdea_parser_destroy@plt>
mov    %rbx,%rdi
call   1070 <mdea_emitter_destroy@plt>
mov    %r12,%rdi
call   1060 <mdea_input_destroy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mdea_node = type { i32 }
%struct.mdea_input = type { i32 }
%struct.mdea_parser = type { i32 }
%struct.mdea_emitter = type { i32 }
define i32 @mdea_node_from_file_desc(i32 %0, %struct.mdea_node** %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.mdea_node**
%6 = alloca i8**
%7 = alloca %struct.mdea_input*
%8 = alloca %struct.mdea_parser*
%9 = alloca %struct.mdea_emitter*
%10 = alloca i32
store i32 %0, i32* %4
store %struct.mdea_node** %1, %struct.mdea_node*** %5
store i8** %2, i8*** %6
%11 = load i32, i32* %4
%12 = call %struct.mdea_input* @mdea_file_input(i32 %11)
store %struct.mdea_input* %12, %struct.mdea_input** %7
%13 = load %struct.mdea_input*, %struct.mdea_input** %7
%14 = call %struct.mdea_parser* @mdea_json_parser(%struct.mdea_input* %13)
store %struct.mdea_parser* %14, %struct.mdea_parser** %8
%15 = load %struct.mdea_node**, %struct.mdea_node*** %5
%16 = call %struct.mdea_emitter* @mdea_node_emitter(%struct.mdea_node** %15)
store %struct.mdea_emitter* %16, %struct.mdea_emitter** %9
%17 = load %struct.mdea_parser*, %struct.mdea_parser** %8
%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** %8
%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_input*, %struct.mdea_input** %7
%26 = call i32 @mdea_input_destroy(%struct.mdea_input* %25)
%27 = load i32, i32* %10
ret i32 %27
}

LLVM IR (-O2):
%struct.mdea_node = type { i32 }
%struct.mdea_input = type { i32 }
%struct.mdea_parser = type { i32 }
%struct.mdea_emitter = type { i32 }
define i32 @mdea_node_from_file_desc(i32 %0, %struct.mdea_node** %1, i8** %2) {
%4 = tail call %struct.mdea_input* @mdea_file_input(i32 %0)
%5 = tail call %struct.mdea_parser* @mdea_json_parser(%struct.mdea_input* %4)
%6 = tail call %struct.mdea_emitter* @mdea_node_emitter(%struct.mdea_node** %1)
%7 = tail call i32 @mdea_parse(%struct.mdea_parser* %5, %struct.mdea_emitter* %6, i8** %2)
%8 = tail call i32 @mdea_parser_destroy(%struct.mdea_parser* %5)
%9 = tail call i32 @mdea_emitter_destroy(%struct.mdea_emitter* %6)
%10 = tail call i32 @mdea_input_destroy(%struct.mdea_input* %4)
ret i32 %7
}