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

/* Variables and functions */
int /*<<< orphan*/ free(struct sock_addr **);
int /*<<< orphan*/ sock_addr_free(struct sock_addr *);
void sock_addr_freelist(struct sock_addr **sas) {
  struct sock_addr **p;
  if (sas == NULL)
    return;
  for (p = sas; *p != NULL; p++)
    sock_addr_free(*p);
  free(sas);
}


x86 assembly (clang, -O0):
<sock_addr_freelist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <sock_addr_freelist+0x1c>
jmp    1178 <sock_addr_freelist+0x58>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     116f <sock_addr_freelist+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <sock_addr_free@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <sock_addr_freelist+0x24>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sock_addr_freelist>:
test   %rdi,%rdi
je     1160 <sock_addr_freelist+0x40>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1151 <sock_addr_freelist+0x31>
lea    0x8(%r14),%rbx
nopl   0x0(%rax,%rax,1)
call   1040 <sock_addr_free@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <sock_addr_freelist+0x20>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
ret

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

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