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

/* Variables and functions */
int /*<<< orphan*/ addchild(struct exptree *, struct exptree *, int);
int /*<<< orphan*/ deallocate(struct exptree *);
struct exptree *initexptree();
struct exptree *addnewchild(struct exptree *t, int pos) {
  struct exptree *child;
  child = initexptree();
  if (!addchild(t, child, pos)) {
    deallocate(child);
    return NULL;
  }
  return child;
}


x86 assembly (clang, -O0):
<addnewchild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    $0x0,%al
call   1030 <initexptree@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <addchild@plt>
cmp    $0x0,%eax
jne    1179 <addnewchild+0x49>
mov    -0x20(%rbp),%rdi
call   1050 <deallocate@plt>
movq   $0x0,-0x8(%rbp)
jmp    1181 <addnewchild+0x51>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addnewchild>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
xor    %eax,%eax
call   1030 <initexptree@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r14d,%edx
call   1040 <addchild@plt>
test   %eax,%eax
jne    1160 <addnewchild+0x30>
mov    %rbx,%rdi
call   1050 <deallocate@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.exptree = type { i32 }
define %struct.exptree* @addnewchild(%struct.exptree* %0, i32 %1) {
%3 = alloca %struct.exptree*
%4 = alloca %struct.exptree*
%5 = alloca i32
%6 = alloca %struct.exptree*
store %struct.exptree* %0, %struct.exptree** %4
store i32 %1, i32* %5
%7 = call %struct.exptree* (...) @initexptree()
store %struct.exptree* %7, %struct.exptree** %6
%8 = load %struct.exptree*, %struct.exptree** %4
%9 = load %struct.exptree*, %struct.exptree** %6
%10 = load i32, i32* %5
%11 = call i32 @addchild(%struct.exptree* %8, %struct.exptree* %9, i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load %struct.exptree*, %struct.exptree** %6
%15 = call i32 @deallocate(%struct.exptree* %14)
store %struct.exptree* null, %struct.exptree** %3
br label %18
16: ; preds = %2
%17 = load %struct.exptree*, %struct.exptree** %6
store %struct.exptree* %17, %struct.exptree** %3
br label %18
18: ; preds = %16, %13
%19 = load %struct.exptree*, %struct.exptree** %3
ret %struct.exptree* %19
}

LLVM IR (-O2):
%struct.exptree = type { i32 }
define %struct.exptree* @addnewchild(%struct.exptree* %0, i32 %1) {
%3 = tail call %struct.exptree* (...) @initexptree()
%4 = tail call i32 @addchild(%struct.exptree* %0, %struct.exptree* %3, i32 %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @deallocate(%struct.exptree* %3)
br label %8
8: ; preds = %2, %6
%9 = phi %struct.exptree* [ null, %6 ], [ %3, %2 ]
ret %struct.exptree* %9
}