#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 path_node {
  int dummy;
};
struct inter {
  int dummy;
};
struct dlist_root {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dlist_root_empty(struct dlist_root *);
scalar_t__ dlist_root_pop(struct dlist_root *);
int /*<<< orphan*/ path_node_free(struct path_node *, struct inter *);
void path_destruct(struct dlist_root *self, struct inter *inter) {
  while (!dlist_root_empty(self)) {
    struct path_node *curr = (struct path_node *)dlist_root_pop(self);
    path_node_free(curr, inter);
  }
}


x86 assembly (clang, -O0):
<path_destruct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <dlist_root_empty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115e <path_destruct+0x2e>
jmp    117d <path_destruct+0x4d>
mov    -0x8(%rbp),%rdi
call   1040 <dlist_root_pop@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <path_node_free@plt>
jmp    1140 <path_destruct+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_destruct>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
call   1050 <dlist_root_empty@plt>
test   %eax,%eax
jne    1161 <path_destruct+0x31>
mov    %rbx,%rdi
call   1040 <dlist_root_pop@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <path_node_free@plt>
mov    %rbx,%rdi
jmp    1140 <path_destruct+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dlist_root = type { i32 }
%struct.inter = type { i32 }
%struct.path_node = type { i32 }
define void @path_destruct(%struct.dlist_root* %0, %struct.inter* %1) {
%3 = alloca %struct.dlist_root*
%4 = alloca %struct.inter*
%5 = alloca %struct.path_node*
store %struct.dlist_root* %0, %struct.dlist_root** %3
store %struct.inter* %1, %struct.inter** %4
br label %6
6: ; preds = %11, %2
%7 = load %struct.dlist_root*, %struct.dlist_root** %3
%8 = call i32 @dlist_root_empty(%struct.dlist_root* %7)
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load %struct.dlist_root*, %struct.dlist_root** %3
%13 = call i64 @dlist_root_pop(%struct.dlist_root* %12)
%14 = inttoptr i64 %13 to %struct.path_node*
store %struct.path_node* %14, %struct.path_node** %5
%15 = load %struct.path_node*, %struct.path_node** %5
%16 = load %struct.inter*, %struct.inter** %4
%17 = call i32 @path_node_free(%struct.path_node* %15, %struct.inter* %16)
br label %6
18: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.dlist_root = type { i32 }
%struct.inter = type { i32 }
%struct.path_node = type { i32 }
define void @path_destruct(%struct.dlist_root* %0, %struct.inter* %1) {
%3 = tail call i32 @dlist_root_empty(%struct.dlist_root* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2, %5
%6 = tail call i64 @dlist_root_pop(%struct.dlist_root* %0)
%7 = inttoptr i64 %6 to %struct.path_node*
%8 = tail call i32 @path_node_free(%struct.path_node* %7, %struct.inter* %1)
%9 = tail call i32 @dlist_root_empty(%struct.dlist_root* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %5, %2
ret void
}