#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 libvirtentry {
  int dummy;
};

/* Variables and functions */
struct libvirtentry **newentries();
struct libvirtentry **combine(struct libvirtentry **a,
                              struct libvirtentry **b) {
  struct libvirtentry **new = newentries();
  struct libvirtentry **start = new;
  while (*a != NULL) {
    *(new ++) = *(a++);
    *new = NULL;
  }
  while (*b != NULL) {
    *(new ++) = *(b++);
    *new = NULL;
  }
  return start;
}


x86 assembly (clang, -O0):
<combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <newentries@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1175 <combine+0x65>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    1133 <combine+0x23>
jmp    117a <combine+0x6a>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11bc <combine+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    117a <combine+0x6a>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <newentries@plt>
mov    (%rbx),%rdx
mov    %rax,%rcx
test   %rdx,%rdx
je     115e <combine+0x4e>
add    $0x8,%rbx
mov    %rax,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x8(%rsi),%rcx
mov    %rdx,(%rsi)
movq   $0x0,0x8(%rsi)
mov    (%rbx),%rdx
add    $0x8,%rbx
mov    %rcx,%rsi
test   %rdx,%rdx
jne    1140 <combine+0x30>
mov    (%r14),%rdx
test   %rdx,%rdx
je     118a <combine+0x7a>
mov    $0x8,%esi
nopl   0x0(%rax,%rax,1)
mov    %rdx,-0x8(%rcx,%rsi,1)
movq   $0x0,(%rcx,%rsi,1)
mov    (%r14,%rsi,1),%rdx
add    $0x8,%rsi
test   %rdx,%rdx
jne    1170 <combine+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.libvirtentry = type { i32 }
define %struct.libvirtentry** @combine(%struct.libvirtentry** %0, %struct.libvirtentry** %1) {
%3 = alloca %struct.libvirtentry**
%4 = alloca %struct.libvirtentry**
%5 = alloca %struct.libvirtentry**
%6 = alloca %struct.libvirtentry**
store %struct.libvirtentry** %0, %struct.libvirtentry*** %3
store %struct.libvirtentry** %1, %struct.libvirtentry*** %4
%7 = call %struct.libvirtentry** (...) @newentries()
store %struct.libvirtentry** %7, %struct.libvirtentry*** %5
%8 = load %struct.libvirtentry**, %struct.libvirtentry*** %5
store %struct.libvirtentry** %8, %struct.libvirtentry*** %6
br label %9
9: ; preds = %13, %2
%10 = load %struct.libvirtentry**, %struct.libvirtentry*** %3
%11 = load %struct.libvirtentry*, %struct.libvirtentry** %10
%12 = icmp ne %struct.libvirtentry* %11, null
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load %struct.libvirtentry**, %struct.libvirtentry*** %3
%15 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %14, i32 1
store %struct.libvirtentry** %15, %struct.libvirtentry*** %3
%16 = load %struct.libvirtentry*, %struct.libvirtentry** %14
%17 = load %struct.libvirtentry**, %struct.libvirtentry*** %5
%18 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %17, i32 1
store %struct.libvirtentry** %18, %struct.libvirtentry*** %5
store %struct.libvirtentry* %16, %struct.libvirtentry** %17
%19 = load %struct.libvirtentry**, %struct.libvirtentry*** %5
store %struct.libvirtentry* null, %struct.libvirtentry** %19
br label %9
20: ; preds = %9
br label %21
21: ; preds = %25, %20
%22 = load %struct.libvirtentry**, %struct.libvirtentry*** %4
%23 = load %struct.libvirtentry*, %struct.libvirtentry** %22
%24 = icmp ne %struct.libvirtentry* %23, null
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load %struct.libvirtentry**, %struct.libvirtentry*** %4
%27 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %26, i32 1
store %struct.libvirtentry** %27, %struct.libvirtentry*** %4
%28 = load %struct.libvirtentry*, %struct.libvirtentry** %26
%29 = load %struct.libvirtentry**, %struct.libvirtentry*** %5
%30 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %29, i32 1
store %struct.libvirtentry** %30, %struct.libvirtentry*** %5
store %struct.libvirtentry* %28, %struct.libvirtentry** %29
%31 = load %struct.libvirtentry**, %struct.libvirtentry*** %5
store %struct.libvirtentry* null, %struct.libvirtentry** %31
br label %21
32: ; preds = %21
%33 = load %struct.libvirtentry**, %struct.libvirtentry*** %6
ret %struct.libvirtentry** %33
}

LLVM IR (-O2):
%struct.libvirtentry = type { i32 }
define %struct.libvirtentry** @combine(%struct.libvirtentry** nocapture %0, %struct.libvirtentry** nocapture %1) {
%3 = tail call %struct.libvirtentry** (...) @newentries()
%4 = load %struct.libvirtentry*, %struct.libvirtentry** %0
%5 = icmp eq %struct.libvirtentry* %4, null
br i1 %5, label %6, label %10
6: ; preds = %10, %2
%7 = phi %struct.libvirtentry** [ %3, %2 ], [ %15, %10 ]
%8 = load %struct.libvirtentry*, %struct.libvirtentry** %1
%9 = icmp eq %struct.libvirtentry* %8, null
br i1 %9, label %26, label %18
10: ; preds = %2, %10
%11 = phi %struct.libvirtentry* [ %16, %10 ], [ %4, %2 ]
%12 = phi %struct.libvirtentry** [ %14, %10 ], [ %0, %2 ]
%13 = phi %struct.libvirtentry** [ %15, %10 ], [ %3, %2 ]
%14 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %12, i64 1
%15 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %13, i64 1
store %struct.libvirtentry* %11, %struct.libvirtentry** %13
store %struct.libvirtentry* null, %struct.libvirtentry** %15
%16 = load %struct.libvirtentry*, %struct.libvirtentry** %14
%17 = icmp eq %struct.libvirtentry* %16, null
br i1 %17, label %6, label %10
18: ; preds = %6, %18
%19 = phi %struct.libvirtentry* [ %24, %18 ], [ %8, %6 ]
%20 = phi %struct.libvirtentry** [ %23, %18 ], [ %7, %6 ]
%21 = phi %struct.libvirtentry** [ %22, %18 ], [ %1, %6 ]
%22 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %21, i64 1
%23 = getelementptr inbounds %struct.libvirtentry*, %struct.libvirtentry** %20, i64 1
store %struct.libvirtentry* %19, %struct.libvirtentry** %20
store %struct.libvirtentry* null, %struct.libvirtentry** %23
%24 = load %struct.libvirtentry*, %struct.libvirtentry** %22
%25 = icmp eq %struct.libvirtentry* %24, null
br i1 %25, label %26, label %18
26: ; preds = %18, %6
ret %struct.libvirtentry** %3
}