#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 confctl_var {
  int dummy;
};
struct confctl {
  int dummy;
};

/* Variables and functions */
struct confctl *confctl_new();
struct confctl_var *confctl_root(struct confctl *);
int /*<<< orphan*/ cv_merge_existing(struct confctl_var *,
                                     struct confctl_var *);
int /*<<< orphan*/ cv_merge_new(struct confctl_var *, struct confctl_var *);
void cc_merge(struct confctl **cc, struct confctl *merge) {
  struct confctl_var *root, *mergeroot;
  if (*cc == NULL)
    *cc = confctl_new();
  root = confctl_root(*cc);
  mergeroot = confctl_root(merge);
  cv_merge_existing(root, mergeroot);
  cv_merge_new(root, mergeroot);
}


x86 assembly (clang, -O0):
<cc_merge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    116f <cc_merge+0x2f>
mov    $0x0,%al
call   1050 <confctl_new@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <confctl_root@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <confctl_root@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <cv_merge_existing@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <cv_merge_new@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cc_merge>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
jne    1160 <cc_merge+0x20>
xor    %eax,%eax
call   1050 <confctl_new@plt>
mov    %rax,%rdi
mov    %rax,(%rbx)
call   1040 <confctl_root@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <confctl_root@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <cv_merge_existing@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <cv_merge_new@plt>

LLVM IR (-O0):
%struct.confctl = type { i32 }
%struct.confctl_var = type { i32 }
define void @cc_merge(%struct.confctl** %0, %struct.confctl* %1) {
%3 = alloca %struct.confctl**
%4 = alloca %struct.confctl*
%5 = alloca %struct.confctl_var*
%6 = alloca %struct.confctl_var*
store %struct.confctl** %0, %struct.confctl*** %3
store %struct.confctl* %1, %struct.confctl** %4
%7 = load %struct.confctl**, %struct.confctl*** %3
%8 = load %struct.confctl*, %struct.confctl** %7
%9 = icmp eq %struct.confctl* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call %struct.confctl* (...) @confctl_new()
%12 = load %struct.confctl**, %struct.confctl*** %3
store %struct.confctl* %11, %struct.confctl** %12
br label %13
13: ; preds = %10, %2
%14 = load %struct.confctl**, %struct.confctl*** %3
%15 = load %struct.confctl*, %struct.confctl** %14
%16 = call %struct.confctl_var* @confctl_root(%struct.confctl* %15)
store %struct.confctl_var* %16, %struct.confctl_var** %5
%17 = load %struct.confctl*, %struct.confctl** %4
%18 = call %struct.confctl_var* @confctl_root(%struct.confctl* %17)
store %struct.confctl_var* %18, %struct.confctl_var** %6
%19 = load %struct.confctl_var*, %struct.confctl_var** %5
%20 = load %struct.confctl_var*, %struct.confctl_var** %6
%21 = call i32 @cv_merge_existing(%struct.confctl_var* %19, %struct.confctl_var* %20)
%22 = load %struct.confctl_var*, %struct.confctl_var** %5
%23 = load %struct.confctl_var*, %struct.confctl_var** %6
%24 = call i32 @cv_merge_new(%struct.confctl_var* %22, %struct.confctl_var* %23)
ret void
}

LLVM IR (-O2):
%struct.confctl = type { i32 }
%struct.confctl_var = type { i32 }
define void @cc_merge(%struct.confctl** nocapture %0, %struct.confctl* %1) {
%3 = load %struct.confctl*, %struct.confctl** %0
%4 = icmp eq %struct.confctl* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call %struct.confctl* (...) @confctl_new()
store %struct.confctl* %6, %struct.confctl** %0
br label %7
7: ; preds = %5, %2
%8 = phi %struct.confctl* [ %6, %5 ], [ %3, %2 ]
%9 = tail call %struct.confctl_var* @confctl_root(%struct.confctl* %8)
%10 = tail call %struct.confctl_var* @confctl_root(%struct.confctl* %1)
%11 = tail call i32 @cv_merge_existing(%struct.confctl_var* %9, %struct.confctl_var* %10)
%12 = tail call i32 @cv_merge_new(%struct.confctl_var* %9, %struct.confctl_var* %10)
ret void
}