#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;
};

/* Variables and functions */
struct confctl_var *confctl_var_first_child(struct confctl_var *);
int /*<<< orphan*/ confctl_var_move(struct confctl_var *, struct confctl_var *);
int /*<<< orphan*/ confctl_var_name(struct confctl_var *);
struct confctl_var *confctl_var_next(struct confctl_var *);
scalar_t__ cv_marked(struct confctl_var *);
scalar_t__ strcmp(int /*<<< orphan*/, int /*<<< orphan*/);
bool cv_merge_new(struct confctl_var *cv, struct confctl_var *newcv) {
  struct confctl_var *child, *newchild, *next, *newnext;
  bool found;
  if (cv_marked(newcv))
    return (true);
  if (strcmp(confctl_var_name(cv), confctl_var_name(newcv)) != 0)
    return (false);
  newchild = confctl_var_first_child(newcv);
  while (newchild != NULL) {
    newnext = confctl_var_next(newchild);
    found = false;
    child = confctl_var_first_child(cv);
    while (child != NULL) {
      next = confctl_var_next(child);
      found = cv_merge_new(child, newchild);
      if (found)
        break;
      child = next;
    }
    if (!found)
      confctl_var_move(newchild, cv);
    newchild = newnext;
  }
  return (true);
}


x86 assembly (clang, -O0):
<cv_merge_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <cv_marked@plt>
cmp    $0x0,%rax
je     119f <cv_merge_new+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    127c <cv_merge_new+0x10c>
mov    -0x10(%rbp),%rdi
call   1070 <confctl_var_name@plt>
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <confctl_var_name@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%esi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11d4 <cv_merge_new+0x64>
movl   $0x0,-0x4(%rbp)
jmp    127c <cv_merge_new+0x10c>
mov    -0x18(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1275 <cv_merge_new+0x105>
mov    -0x28(%rbp),%rdi
call   1080 <confctl_var_next@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1251 <cv_merge_new+0xe1>
mov    -0x20(%rbp),%rdi
call   1080 <confctl_var_next@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <cv_merge_new@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1244 <cv_merge_new+0xd4>
jmp    1251 <cv_merge_new+0xe1>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    120d <cv_merge_new+0x9d>
cmpl   $0x0,-0x3c(%rbp)
jne    1268 <cv_merge_new+0xf8>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <confctl_var_move@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e1 <cv_merge_new+0x71>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cv_merge_new>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <cv_marked@plt>
test   %rax,%rax
je     1192 <cv_merge_new+0x22>
mov    $0x1,%eax
jmp    11b7 <cv_merge_new+0x47>
mov    %r14,%rdi
call   1070 <confctl_var_name@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <confctl_var_name@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11c0 <cv_merge_new+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <confctl_var_first_child@plt>
test   %rax,%rax
je     118b <cv_merge_new+0x1b>
mov    %rax,%r15
jmp    11f0 <cv_merge_new+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <confctl_var_move@plt>
test   %r15,%r15
je     118b <cv_merge_new+0x1b>
mov    %r15,%r12
mov    %r15,%rdi
call   1080 <confctl_var_next@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <confctl_var_first_child@plt>
mov    %rax,%rbx
nopl   0x0(%rax)
test   %rbx,%rbx
je     11e0 <cv_merge_new+0x70>
mov    %rbx,%rdi
call   1080 <confctl_var_next@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <cv_merge_new@plt>
mov    %rbp,%rbx
test   %eax,%eax
je     1210 <cv_merge_new+0xa0>
jmp    11eb <cv_merge_new+0x7b>

LLVM IR (-O0):
%struct.confctl_var = type { i32 }
define i32 @cv_merge_new(%struct.confctl_var* %0, %struct.confctl_var* %1) {
%3 = alloca i32
%4 = alloca %struct.confctl_var*
%5 = alloca %struct.confctl_var*
%6 = alloca %struct.confctl_var*
%7 = alloca %struct.confctl_var*
%8 = alloca %struct.confctl_var*
%9 = alloca %struct.confctl_var*
%10 = alloca i32
store %struct.confctl_var* %0, %struct.confctl_var** %4
store %struct.confctl_var* %1, %struct.confctl_var** %5
%11 = load %struct.confctl_var*, %struct.confctl_var** %5
%12 = call i64 @cv_marked(%struct.confctl_var* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %58
15: ; preds = %2
%16 = load %struct.confctl_var*, %struct.confctl_var** %4
%17 = call i32 @confctl_var_name(%struct.confctl_var* %16)
%18 = load %struct.confctl_var*, %struct.confctl_var** %5
%19 = call i32 @confctl_var_name(%struct.confctl_var* %18)
%20 = call i64 @strcmp(i32 %17, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 0, i32* %3
br label %58
23: ; preds = %15
%24 = load %struct.confctl_var*, %struct.confctl_var** %5
%25 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %24)
store %struct.confctl_var* %25, %struct.confctl_var** %7
br label %26
26: ; preds = %55, %23
%27 = load %struct.confctl_var*, %struct.confctl_var** %7
%28 = icmp ne %struct.confctl_var* %27, null
br i1 %28, label %29, label %57
29: ; preds = %26
%30 = load %struct.confctl_var*, %struct.confctl_var** %7
%31 = call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %30)
store %struct.confctl_var* %31, %struct.confctl_var** %9
store i32 0, i32* %10
%32 = load %struct.confctl_var*, %struct.confctl_var** %4
%33 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %32)
store %struct.confctl_var* %33, %struct.confctl_var** %6
br label %34
34: ; preds = %46, %29
%35 = load %struct.confctl_var*, %struct.confctl_var** %6
%36 = icmp ne %struct.confctl_var* %35, null
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = load %struct.confctl_var*, %struct.confctl_var** %6
%39 = call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %38)
store %struct.confctl_var* %39, %struct.confctl_var** %8
%40 = load %struct.confctl_var*, %struct.confctl_var** %6
%41 = load %struct.confctl_var*, %struct.confctl_var** %7
%42 = call i32 @cv_merge_new(%struct.confctl_var* %40, %struct.confctl_var* %41)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %37
br label %48
46: ; preds = %37
%47 = load %struct.confctl_var*, %struct.confctl_var** %8
store %struct.confctl_var* %47, %struct.confctl_var** %6
br label %34
48: ; preds = %45, %34
%49 = load i32, i32* %10
%50 = icmp ne i32 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %48
%52 = load %struct.confctl_var*, %struct.confctl_var** %7
%53 = load %struct.confctl_var*, %struct.confctl_var** %4
%54 = call i32 @confctl_var_move(%struct.confctl_var* %52, %struct.confctl_var* %53)
br label %55
55: ; preds = %51, %48
%56 = load %struct.confctl_var*, %struct.confctl_var** %9
store %struct.confctl_var* %56, %struct.confctl_var** %7
br label %26
57: ; preds = %26
store i32 1, i32* %3
br label %58
58: ; preds = %57, %22, %14
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
%struct.confctl_var = type { i32 }
define i32 @cv_merge_new(%struct.confctl_var* %0, %struct.confctl_var* %1) {
%3 = tail call i64 @cv_marked(%struct.confctl_var* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %28
5: ; preds = %2
%6 = tail call i32 @confctl_var_name(%struct.confctl_var* %0)
%7 = tail call i32 @confctl_var_name(%struct.confctl_var* %1)
%8 = tail call i64 @strcmp(i32 %6, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %5
%11 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %1)
%12 = icmp eq %struct.confctl_var* %11, null
br i1 %12, label %28, label %13
13: ; preds = %10, %26
%14 = phi %struct.confctl_var* [ %15, %26 ], [ %11, %10 ]
%15 = tail call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %14)
%16 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %0)
br label %17
17: ; preds = %20, %13
%18 = phi %struct.confctl_var* [ %16, %13 ], [ %21, %20 ]
%19 = icmp eq %struct.confctl_var* %18, null
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %18)
%22 = tail call i32 @cv_merge_new(%struct.confctl_var* %18, %struct.confctl_var* %14)
%23 = icmp eq i32 %22, 0
br i1 %23, label %17, label %26
24: ; preds = %17
%25 = tail call i32 @confctl_var_move(%struct.confctl_var* %14, %struct.confctl_var* %0)
br label %26
26: ; preds = %20, %24
%27 = icmp eq %struct.confctl_var* %15, null
br i1 %27, label %28, label %13
28: ; preds = %26, %10, %5, %2
%29 = phi i32 [ 1, %2 ], [ 0, %5 ], [ 1, %10 ], [ 1, %26 ]
ret i32 %29
}