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

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ mdea_get(struct mdea_node *, char *, struct mdea_node **, char **);
scalar_t__ mdea_node_from_file_path(char *, struct mdea_node **, char **);
scalar_t__ mdea_node_from_string(char *, struct mdea_node **, char **);
scalar_t__ mdea_node_to_file_desc(struct mdea_node *, int /*<<< orphan*/,
                                  char **);
int mdea_node_to_file_path(struct mdea_node *, char *, char **);
struct mdea_node *mdea_object_node();
scalar_t__ mdea_set(struct mdea_node **, char *, struct mdea_node *, char **);
scalar_t__ strcmp(char *, char *);
int test(int argc, char *argv[], char **error) {
  if (argc <= 1)
    return -1;
  if (strcmp(argv[1], "get") == 0) {
    struct mdea_node *root, *node;
    if (argc != 4)
      return -1;
    if (mdea_node_from_file_path(argv[3], &root, error) != 0)
      return -1;
    if (mdea_get(root, argv[2], &node, error) != 0)
      return -1;
    if (mdea_node_to_file_desc(node, STDOUT_FILENO, error) != 0)
      return -1;
    return 0;
  }
  if (strcmp(argv[1], "set") == 0) {
    struct mdea_node *root, *node;
    if (argc != 5)
      return -1;
    if (mdea_node_from_file_path(argv[4], &root, NULL) != 0)
      root = mdea_object_node();
    if (mdea_node_from_string(argv[3], &node, error) != 0)
      return -1;
    if (mdea_set(&root, argv[2], node, error) != 0)
      return -1;
    return mdea_node_to_file_path(root, argv[4], error);
  }
  return -1;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11a9 <test+0x29>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    126f <test+0xef>
cmpl   $0x4,-0x8(%rbp)
je     11dd <test+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rsi
call   1030 <mdea_node_from_file_path@plt>
cmp    $0x0,%rax
je     1208 <test+0x88>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%rdx
call   1090 <mdea_get@plt>
cmp    $0x0,%rax
je     1237 <test+0xb7>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x28(%rbp),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1040 <mdea_node_to_file_desc@plt>
cmp    $0x0,%rax
je     1263 <test+0xe3>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
movl   $0x0,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd86(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1344 <test+0x1c4>
cmpl   $0x5,-0x8(%rbp)
je     12a3 <test+0x123>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <mdea_node_from_file_path@plt>
cmp    $0x0,%rax
je     12cd <test+0x14d>
mov    $0x0,%al
call   1050 <mdea_object_node@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rsi
call   1070 <mdea_node_from_string@plt>
cmp    $0x0,%rax
je     12f8 <test+0x178>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    -0x30(%rbp),%rdi
call   1060 <mdea_set@plt>
cmp    $0x0,%rax
je     1327 <test+0x1a7>
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <test+0x1cb>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
mov    -0x18(%rbp),%rdx
call   10a0 <mdea_node_to_file_path@plt>
mov    %eax,-0x4(%rbp)
jmp    134b <test+0x1cb>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xffffffff,%r15d
cmp    $0x2,%edi
jl     12a6 <test+0x126>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe54(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     124e <test+0xce>
mov    0x8(%rbx),%rdi
lea    0xe3f(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12a6 <test+0x126>
mov    $0xffffffff,%r15d
cmp    $0x5,%ebp
jne    12a6 <test+0x126>
mov    0x20(%rbx),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <mdea_node_from_file_path@plt>
test   %rax,%rax
je     1203 <test+0x83>
xor    %eax,%eax
call   1050 <mdea_object_node@plt>
mov    %rax,0x8(%rsp)
mov    0x18(%rbx),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1070 <mdea_node_from_string@plt>
test   %rax,%rax
jne    12a6 <test+0x126>
mov    0x10(%rbx),%rsi
mov    0x10(%rsp),%rdx
lea    0x8(%rsp),%rdi
mov    %r14,%rcx
call   1060 <mdea_set@plt>
test   %rax,%rax
jne    12a6 <test+0x126>
mov    0x8(%rsp),%rdi
mov    0x20(%rbx),%rsi
mov    %r14,%rdx
call   10a0 <mdea_node_to_file_path@plt>
mov    %eax,%r15d
jmp    12a6 <test+0x126>
mov    $0xffffffff,%r15d
cmp    $0x4,%ebp
jne    12a6 <test+0x126>
mov    0x18(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    %r14,%rdx
call   1030 <mdea_node_from_file_path@plt>
test   %rax,%rax
jne    12a6 <test+0x126>
mov    0x8(%rsp),%rdi
mov    0x10(%rbx),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rcx
call   1090 <mdea_get@plt>
test   %rax,%rax
jne    12a6 <test+0x126>
mov    0x10(%rsp),%rdi
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdx
call   1040 <mdea_node_to_file_desc@plt>
neg    %rax
sbb    %r15d,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mdea_node = type { i32 }
@.str = [4 x i8] c"get\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [4 x i8] c"set\00"
define i32 @test(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca %struct.mdea_node*
%9 = alloca %struct.mdea_node*
%10 = alloca %struct.mdea_node*
%11 = alloca %struct.mdea_node*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %93
15: ; preds = %3
%16 = load i8**, i8*** %6
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %50
21: ; preds = %15
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 4
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 -1, i32* %4
br label %93
25: ; preds = %21
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %7
%30 = call i64 @mdea_node_from_file_path(i8* %28, %struct.mdea_node** %8, i8** %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 -1, i32* %4
br label %93
33: ; preds = %25
%34 = load %struct.mdea_node*, %struct.mdea_node** %8
%35 = load i8**, i8*** %6
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = load i8**, i8*** %7
%39 = call i64 @mdea_get(%struct.mdea_node* %34, i8* %37, %struct.mdea_node** %9, i8** %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33
store i32 -1, i32* %4
br label %93
42: ; preds = %33
%43 = load %struct.mdea_node*, %struct.mdea_node** %9
%44 = load i32, i32* @STDOUT_FILENO
%45 = load i8**, i8*** %7
%46 = call i64 @mdea_node_to_file_desc(%struct.mdea_node* %43, i32 %44, i8** %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %42
store i32 -1, i32* %4
br label %93
49: ; preds = %42
store i32 0, i32* %4
br label %93
50: ; preds = %15
%51 = load i8**, i8*** %6
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %92
56: ; preds = %50
%57 = load i32, i32* %5
%58 = icmp ne i32 %57, 5
br i1 %58, label %59, label %60
59: ; preds = %56
store i32 -1, i32* %4
br label %93
60: ; preds = %56
%61 = load i8**, i8*** %6
%62 = getelementptr inbounds i8*, i8** %61, i64 4
%63 = load i8*, i8** %62
%64 = call i64 @mdea_node_from_file_path(i8* %63, %struct.mdea_node** %10, i8** null)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call %struct.mdea_node* (...) @mdea_object_node()
store %struct.mdea_node* %67, %struct.mdea_node** %10
br label %68
68: ; preds = %66, %60
%69 = load i8**, i8*** %6
%70 = getelementptr inbounds i8*, i8** %69, i64 3
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %7
%73 = call i64 @mdea_node_from_string(i8* %71, %struct.mdea_node** %11, i8** %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %68
store i32 -1, i32* %4
br label %93
76: ; preds = %68
%77 = load i8**, i8*** %6
%78 = getelementptr inbounds i8*, i8** %77, i64 2
%79 = load i8*, i8** %78
%80 = load %struct.mdea_node*, %struct.mdea_node** %11
%81 = load i8**, i8*** %7
%82 = call i64 @mdea_set(%struct.mdea_node** %10, i8* %79, %struct.mdea_node* %80, i8** %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %76
store i32 -1, i32* %4
br label %93
85: ; preds = %76
%86 = load %struct.mdea_node*, %struct.mdea_node** %10
%87 = load i8**, i8*** %6
%88 = getelementptr inbounds i8*, i8** %87, i64 4
%89 = load i8*, i8** %88
%90 = load i8**, i8*** %7
%91 = call i32 @mdea_node_to_file_path(%struct.mdea_node* %86, i8* %89, i8** %90)
store i32 %91, i32* %4
br label %93
92: ; preds = %50
store i32 -1, i32* %4
br label %93
93: ; preds = %92, %85, %84, %75, %59, %49, %48, %41, %32, %24, %14
%94 = load i32, i32* %4
ret i32 %94
}

LLVM IR (-O2):
%struct.mdea_node = type { i32 }
@.str = [4 x i8] c"get\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [4 x i8] c"set\00"
define i32 @test(i32 %0, i8** nocapture %1, i8** %2) {
%4 = alloca %struct.mdea_node*
%5 = alloca %struct.mdea_node*
%6 = alloca %struct.mdea_node*
%7 = alloca %struct.mdea_node*
%8 = icmp slt i32 %0, 2
br i1 %8, label %69, label %9
9: ; preds = %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %37
14: ; preds = %9
%15 = bitcast %struct.mdea_node** %4 to i8*
%16 = bitcast %struct.mdea_node** %5 to i8*
%17 = icmp eq i32 %0, 4
br i1 %17, label %18, label %35
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = call i64 @mdea_node_from_file_path(i8* %20, %struct.mdea_node** %4, i8** %2)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %18
%24 = load %struct.mdea_node*, %struct.mdea_node** %4
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @mdea_get(%struct.mdea_node* %24, i8* %26, %struct.mdea_node** %5, i8** %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load %struct.mdea_node*, %struct.mdea_node** %5
%31 = load i32, i32* @STDOUT_FILENO
%32 = call i64 @mdea_node_to_file_desc(%struct.mdea_node* %30, i32 %31, i8** %2)
%33 = icmp ne i64 %32, 0
%34 = sext i1 %33 to i32
br label %35
35: ; preds = %29, %23, %18, %14
%36 = phi i32 [ -1, %14 ], [ -1, %18 ], [ -1, %23 ], [ %34, %29 ]
br label %69
37: ; preds = %9
%38 = load i8*, i8** %10
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %69
41: ; preds = %37
%42 = bitcast %struct.mdea_node** %6 to i8*
%43 = bitcast %struct.mdea_node** %7 to i8*
%44 = icmp eq i32 %0, 5
br i1 %44, label %45, label %67
45: ; preds = %41
%46 = getelementptr inbounds i8*, i8** %1, i64 4
%47 = load i8*, i8** %46
%48 = call i64 @mdea_node_from_file_path(i8* %47, %struct.mdea_node** %6, i8** null)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = call %struct.mdea_node* (...) @mdea_object_node()
store %struct.mdea_node* %51, %struct.mdea_node** %6
br label %52
52: ; preds = %50, %45
%53 = getelementptr inbounds i8*, i8** %1, i64 3
%54 = load i8*, i8** %53
%55 = call i64 @mdea_node_from_string(i8* %54, %struct.mdea_node** %7, i8** %2)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %52
%58 = getelementptr inbounds i8*, i8** %1, i64 2
%59 = load i8*, i8** %58
%60 = load %struct.mdea_node*, %struct.mdea_node** %7
%61 = call i64 @mdea_set(%struct.mdea_node** %6, i8* %59, %struct.mdea_node* %60, i8** %2)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %57
%64 = load %struct.mdea_node*, %struct.mdea_node** %6
%65 = load i8*, i8** %46
%66 = call i32 @mdea_node_to_file_path(%struct.mdea_node* %64, i8* %65, i8** %2)
br label %67
67: ; preds = %57, %52, %41, %63
%68 = phi i32 [ %66, %63 ], [ -1, %41 ], [ -1, %52 ], [ -1, %57 ]
br label %69
69: ; preds = %37, %3, %67, %35
%70 = phi i32 [ %36, %35 ], [ %68, %67 ], [ -1, %3 ], [ -1, %37 ]
ret i32 %70
}