#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 rooted_tree {
  int dummy;
};
struct rnode {
  int dummy;
};
struct llist {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroy_llist(struct llist *);
struct rnode *lca(struct rooted_tree *, struct llist *);
struct llist *shallow_copy(struct llist *);
struct rnode *lca_from_nodes(struct rooted_tree *tree,
                             struct llist *descendants) {
  struct rnode *result;
  struct llist *copy = shallow_copy(descendants);
  if (NULL == copy)
    return NULL;
  result = lca(tree, copy);
  if (NULL == result)
    return NULL;
  destroy_llist(copy);
  return result;
}


x86 assembly (clang, -O0):
<lca_from_nodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <shallow_copy@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    1166 <lca_from_nodes+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <lca_from_nodes+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <lca@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1190 <lca_from_nodes+0x60>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <lca_from_nodes+0x71>
mov    -0x28(%rbp),%rdi
call   1030 <destroy_llist@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lca_from_nodes>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <shallow_copy@plt>
test   %rax,%rax
je     1164 <lca_from_nodes+0x34>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <lca@plt>
test   %rax,%rax
je     1164 <lca_from_nodes+0x34>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <destroy_llist@plt>
jmp    1167 <lca_from_nodes+0x37>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rnode = type { i32 }
%struct.rooted_tree = type { i32 }
%struct.llist = type { i32 }
define %struct.rnode* @lca_from_nodes(%struct.rooted_tree* %0, %struct.llist* %1) {
%3 = alloca %struct.rnode*
%4 = alloca %struct.rooted_tree*
%5 = alloca %struct.llist*
%6 = alloca %struct.rnode*
%7 = alloca %struct.llist*
store %struct.rooted_tree* %0, %struct.rooted_tree** %4
store %struct.llist* %1, %struct.llist** %5
%8 = load %struct.llist*, %struct.llist** %5
%9 = call %struct.llist* @shallow_copy(%struct.llist* %8)
store %struct.llist* %9, %struct.llist** %7
%10 = load %struct.llist*, %struct.llist** %7
%11 = icmp eq %struct.llist* null, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store %struct.rnode* null, %struct.rnode** %3
br label %24
13: ; preds = %2
%14 = load %struct.rooted_tree*, %struct.rooted_tree** %4
%15 = load %struct.llist*, %struct.llist** %7
%16 = call %struct.rnode* @lca(%struct.rooted_tree* %14, %struct.llist* %15)
store %struct.rnode* %16, %struct.rnode** %6
%17 = load %struct.rnode*, %struct.rnode** %6
%18 = icmp eq %struct.rnode* null, %17
br i1 %18, label %19, label %20
19: ; preds = %13
store %struct.rnode* null, %struct.rnode** %3
br label %24
20: ; preds = %13
%21 = load %struct.llist*, %struct.llist** %7
%22 = call i32 @destroy_llist(%struct.llist* %21)
%23 = load %struct.rnode*, %struct.rnode** %6
store %struct.rnode* %23, %struct.rnode** %3
br label %24
24: ; preds = %20, %19, %12
%25 = load %struct.rnode*, %struct.rnode** %3
ret %struct.rnode* %25
}

LLVM IR (-O2):
%struct.rnode = type { i32 }
%struct.rooted_tree = type { i32 }
%struct.llist = type { i32 }
define %struct.rnode* @lca_from_nodes(%struct.rooted_tree* %0, %struct.llist* %1) {
%3 = tail call %struct.llist* @shallow_copy(%struct.llist* %1)
%4 = icmp eq %struct.llist* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call %struct.rnode* @lca(%struct.rooted_tree* %0, %struct.llist* %3)
%7 = icmp eq %struct.rnode* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @destroy_llist(%struct.llist* %3)
br label %10
10: ; preds = %5, %2, %8
%11 = phi %struct.rnode* [ %6, %8 ], [ null, %2 ], [ null, %5 ]
ret %struct.rnode* %11
}