#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 addrinfo {
  struct addrinfo *ai_canonname;
  struct addrinfo *ai_next;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct addrinfo *);
void freeaddrinfo(struct addrinfo *ai) {
  struct addrinfo *next;
  do {
    next = ai->ai_next;
    free(ai->ai_canonname);
    free(ai);
  } while (NULL != (ai = next));
}


x86 assembly (clang, -O0):
<freeaddrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    111c <freeaddrinfo+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeaddrinfo>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
mov    0x8(%rbx),%r14
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rbx
test   %r14,%r14
jne    1120 <freeaddrinfo+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.addrinfo = type { %struct.addrinfo*, %struct.addrinfo* }
define void @freeaddrinfo(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
%3 = alloca %struct.addrinfo*
store %struct.addrinfo* %0, %struct.addrinfo** %2
br label %4
4: ; preds = %14, %1
%5 = load %struct.addrinfo*, %struct.addrinfo** %2
%6 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 1
%7 = load %struct.addrinfo*, %struct.addrinfo** %6
store %struct.addrinfo* %7, %struct.addrinfo** %3
%8 = load %struct.addrinfo*, %struct.addrinfo** %2
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 0
%10 = load %struct.addrinfo*, %struct.addrinfo** %9
%11 = call i32 @free(%struct.addrinfo* %10)
%12 = load %struct.addrinfo*, %struct.addrinfo** %2
%13 = call i32 @free(%struct.addrinfo* %12)
br label %14
14: ; preds = %4
%15 = load %struct.addrinfo*, %struct.addrinfo** %3
store %struct.addrinfo* %15, %struct.addrinfo** %2
%16 = icmp ne %struct.addrinfo* null, %15
br i1 %16, label %4, label %17
17: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.addrinfo*, %struct.addrinfo* }
define void @freeaddrinfo(%struct.addrinfo* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi %struct.addrinfo* [ %0, %1 ], [ %5, %2 ]
%4 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 1
%5 = load %struct.addrinfo*, %struct.addrinfo** %4
%6 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
%7 = load %struct.addrinfo*, %struct.addrinfo** %6
%8 = tail call i32 @free(%struct.addrinfo* %7)
%9 = tail call i32 @free(%struct.addrinfo* %3)
%10 = icmp eq %struct.addrinfo* %5, null
br i1 %10, label %11, label %2
11: ; preds = %2
ret void
}