#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 */
int /*<<< orphan*/ confctl_var_delete(struct confctl_var *);
struct confctl_var *confctl_var_first_child(struct confctl_var *);
scalar_t__ confctl_var_is_implicit_container(struct confctl_var *);
int /*<<< orphan*/ confctl_var_name(struct confctl_var *);
struct confctl_var *confctl_var_next(struct confctl_var *);
int /*<<< orphan*/ *confctl_var_value(struct confctl_var *);
int /*<<< orphan*/ errx(int, char *);
scalar_t__ strcmp(int /*<<< orphan*/, int /*<<< orphan*/);
void cv_remove(struct confctl_var *cv, struct confctl_var *remove) {
  struct confctl_var *child, *removechild, *next;
  if (confctl_var_value(remove) != NULL)
    errx(1, "variable to remove must not specify a value");
  if (strcmp(confctl_var_name(remove), confctl_var_name(cv)) != 0)
    return;
  if (confctl_var_first_child(remove) == NULL) {
    confctl_var_delete(cv);
    return;
  }
  child = confctl_var_first_child(cv);
  while (child != NULL) {
    next = confctl_var_next(child);
    for (removechild = confctl_var_first_child(remove); removechild != NULL;
         removechild = confctl_var_next(removechild))
      cv_remove(child, removechild);
    child = next;
  }
  if (confctl_var_is_implicit_container(cv) &&
      confctl_var_first_child(cv) == NULL)
    confctl_var_delete(cv);
}


x86 assembly (clang, -O0):
<cv_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <confctl_var_value@plt>
cmp    $0x0,%rax
je     11c4 <cv_remove+0x34>
mov    $0x1,%edi
lea    0xe41(%rip),%rsi
call   1040 <errx@plt>
mov    -0x10(%rbp),%rdi
call   1080 <confctl_var_name@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <confctl_var_name@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11f2 <cv_remove+0x62>
jmp    12ab <cv_remove+0x11b>
mov    -0x10(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
cmp    $0x0,%rax
jne    1213 <cv_remove+0x83>
mov    -0x8(%rbp),%rdi
call   1090 <confctl_var_delete@plt>
jmp    12ab <cv_remove+0x11b>
mov    -0x8(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     127c <cv_remove+0xec>
mov    -0x18(%rbp),%rdi
call   10a0 <confctl_var_next@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     126f <cv_remove+0xdf>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <cv_remove@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <confctl_var_next@plt>
mov    %rax,-0x20(%rbp)
jmp    1245 <cv_remove+0xb5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1220 <cv_remove+0x90>
mov    -0x8(%rbp),%rdi
call   1050 <confctl_var_is_implicit_container@plt>
cmp    $0x0,%rax
je     12ab <cv_remove+0x11b>
mov    -0x8(%rbp),%rdi
call   1030 <confctl_var_first_child@plt>
cmp    $0x0,%rax
jne    12ab <cv_remove+0x11b>
mov    -0x8(%rbp),%rdi
call   1090 <confctl_var_delete@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cv_remove>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   10b0 <confctl_var_value@plt>
test   %rax,%rax
je     11bd <cv_remove+0x2d>
lea    0xe4d(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
mov    %r15,%rdi
call   1080 <confctl_var_name@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1080 <confctl_var_name@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11e7 <cv_remove+0x57>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
call   1030 <confctl_var_first_child@plt>
test   %rax,%rax
je     127f <cv_remove+0xef>
mov    %r14,%rdi
call   1030 <confctl_var_first_child@plt>
test   %rax,%rax
je     125d <cv_remove+0xcd>
mov    %rax,%r13
jmp    1218 <cv_remove+0x88>
nopw   0x0(%rax,%rax,1)
mov    %r12,%r13
test   %r12,%r12
je     125d <cv_remove+0xcd>
mov    %r13,%rdi
call   10a0 <confctl_var_next@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1030 <confctl_var_first_child@plt>
test   %rax,%rax
je     1210 <cv_remove+0x80>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <cv_remove@plt>
mov    %rbx,%rdi
call   10a0 <confctl_var_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1240 <cv_remove+0xb0>
jmp    1210 <cv_remove+0x80>
mov    %r14,%rdi
call   1050 <confctl_var_is_implicit_container@plt>
test   %rax,%rax
je     11dd <cv_remove+0x4d>
mov    %r14,%rdi
call   1030 <confctl_var_first_child@plt>
test   %rax,%rax
jne    11dd <cv_remove+0x4d>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1090 <confctl_var_delete@plt>

LLVM IR (-O0):
%struct.confctl_var = type { i32 }
@.str = [44 x i8] c"variable to remove must not specify a value\00"
define void @cv_remove(%struct.confctl_var* %0, %struct.confctl_var* %1) {
%3 = alloca %struct.confctl_var*
%4 = alloca %struct.confctl_var*
%5 = alloca %struct.confctl_var*
%6 = alloca %struct.confctl_var*
%7 = alloca %struct.confctl_var*
store %struct.confctl_var* %0, %struct.confctl_var** %3
store %struct.confctl_var* %1, %struct.confctl_var** %4
%8 = load %struct.confctl_var*, %struct.confctl_var** %4
%9 = call i32* @confctl_var_value(%struct.confctl_var* %8)
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @errx(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load %struct.confctl_var*, %struct.confctl_var** %4
%15 = call i32 @confctl_var_name(%struct.confctl_var* %14)
%16 = load %struct.confctl_var*, %struct.confctl_var** %3
%17 = call i32 @confctl_var_name(%struct.confctl_var* %16)
%18 = call i64 @strcmp(i32 %15, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
br label %61
21: ; preds = %13
%22 = load %struct.confctl_var*, %struct.confctl_var** %4
%23 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %22)
%24 = icmp eq %struct.confctl_var* %23, null
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load %struct.confctl_var*, %struct.confctl_var** %3
%27 = call i32 @confctl_var_delete(%struct.confctl_var* %26)
br label %61
28: ; preds = %21
%29 = load %struct.confctl_var*, %struct.confctl_var** %3
%30 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %29)
store %struct.confctl_var* %30, %struct.confctl_var** %5
br label %31
31: ; preds = %48, %28
%32 = load %struct.confctl_var*, %struct.confctl_var** %5
%33 = icmp ne %struct.confctl_var* %32, null
br i1 %33, label %34, label %50
34: ; preds = %31
%35 = load %struct.confctl_var*, %struct.confctl_var** %5
%36 = call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %35)
store %struct.confctl_var* %36, %struct.confctl_var** %7
%37 = load %struct.confctl_var*, %struct.confctl_var** %4
%38 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %37)
store %struct.confctl_var* %38, %struct.confctl_var** %6
br label %39
39: ; preds = %45, %34
%40 = load %struct.confctl_var*, %struct.confctl_var** %6
%41 = icmp ne %struct.confctl_var* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load %struct.confctl_var*, %struct.confctl_var** %5
%44 = load %struct.confctl_var*, %struct.confctl_var** %6
br label %45
45: ; preds = %42
%46 = load %struct.confctl_var*, %struct.confctl_var** %6
%47 = call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %46)
store %struct.confctl_var* %47, %struct.confctl_var** %6
br label %39
48: ; preds = %39
%49 = load %struct.confctl_var*, %struct.confctl_var** %7
store %struct.confctl_var* %49, %struct.confctl_var** %5
br label %31
50: ; preds = %31
%51 = load %struct.confctl_var*, %struct.confctl_var** %3
%52 = call i64 @confctl_var_is_implicit_container(%struct.confctl_var* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load %struct.confctl_var*, %struct.confctl_var** %3
%56 = call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %55)
%57 = icmp eq %struct.confctl_var* %56, null
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load %struct.confctl_var*, %struct.confctl_var** %3
%60 = call i32 @confctl_var_delete(%struct.confctl_var* %59)
br label %61
61: ; preds = %20, %25, %58, %54, %50
ret void
}

LLVM IR (-O2):
%struct.confctl_var = type { i32 }
@.str = [44 x i8] c"variable to remove must not specify a value\00"
define void @cv_remove(%struct.confctl_var* %0, %struct.confctl_var* %1) {
%3 = tail call i32* @confctl_var_value(%struct.confctl_var* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @confctl_var_name(%struct.confctl_var* %1)
%9 = tail call i32 @confctl_var_name(%struct.confctl_var* %0)
%10 = tail call i64 @strcmp(i32 %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %7
%13 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %1)
%14 = icmp eq %struct.confctl_var* %13, null
br i1 %14, label %35, label %15
15: ; preds = %12
%16 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %0)
%17 = icmp eq %struct.confctl_var* %16, null
br i1 %17, label %29, label %20
18: ; preds = %25, %20
%19 = icmp eq %struct.confctl_var* %22, null
br i1 %19, label %29, label %20
20: ; preds = %15, %18
%21 = phi %struct.confctl_var* [ %22, %18 ], [ %16, %15 ]
%22 = tail call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %21)
%23 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %1)
%24 = icmp eq %struct.confctl_var* %23, null
br i1 %24, label %18, label %25
25: ; preds = %20, %25
%26 = phi %struct.confctl_var* [ %27, %25 ], [ %23, %20 ]
tail call void @cv_remove(%struct.confctl_var* %21, %struct.confctl_var* %26)
%27 = tail call %struct.confctl_var* @confctl_var_next(%struct.confctl_var* %26)
%28 = icmp eq %struct.confctl_var* %27, null
br i1 %28, label %18, label %25
29: ; preds = %18, %15
%30 = tail call i64 @confctl_var_is_implicit_container(%struct.confctl_var* %0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call %struct.confctl_var* @confctl_var_first_child(%struct.confctl_var* %0)
%34 = icmp eq %struct.confctl_var* %33, null
br i1 %34, label %35, label %37
35: ; preds = %32, %12
%36 = tail call i32 @confctl_var_delete(%struct.confctl_var* %0)
br label %37
37: ; preds = %35, %29, %32, %7
ret void
}