#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 connect_info {
  int dummy;
};
struct connect_head {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ SLIST_EMPTY(struct connect_head *);
struct connect_info *SLIST_FIRST(struct connect_head *);
int /*<<< orphan*/ SLIST_REMOVE_HEAD(struct connect_head *,
                                     struct connect_head *);
int /*<<< orphan*/ free(struct connect_info *);
int free_connections(struct connect_head *list) {
  struct connect_info *info;
  while (!SLIST_EMPTY(list)) {
    info = SLIST_FIRST(list);
    SLIST_REMOVE_HEAD(list, list);
    free(info);
  }
  return 0;
}


x86 assembly (clang, -O0):
<free_connections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <SLIST_EMPTY@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116a <free_connections+0x2a>
jmp    1192 <free_connections+0x52>
mov    -0x8(%rbp),%rdi
call   1040 <SLIST_FIRST@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <SLIST_REMOVE_HEAD@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    114c <free_connections+0xc>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_connections>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
call   1060 <SLIST_EMPTY@plt>
test   %eax,%eax
jne    117c <free_connections+0x3c>
mov    %rbx,%rdi
call   1040 <SLIST_FIRST@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1050 <SLIST_REMOVE_HEAD@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
jmp    1150 <free_connections+0x10>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.connect_head = type { i32 }
%struct.connect_info = type { i32 }
define i32 @free_connections(%struct.connect_head* %0) {
%2 = alloca %struct.connect_head*
%3 = alloca %struct.connect_info*
store %struct.connect_head* %0, %struct.connect_head** %2
br label %4
4: ; preds = %9, %1
%5 = load %struct.connect_head*, %struct.connect_head** %2
%6 = call i32 @SLIST_EMPTY(%struct.connect_head* %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load %struct.connect_head*, %struct.connect_head** %2
%11 = call %struct.connect_info* @SLIST_FIRST(%struct.connect_head* %10)
store %struct.connect_info* %11, %struct.connect_info** %3
%12 = load %struct.connect_head*, %struct.connect_head** %2
%13 = load %struct.connect_head*, %struct.connect_head** %2
%14 = call i32 @SLIST_REMOVE_HEAD(%struct.connect_head* %12, %struct.connect_head* %13)
%15 = load %struct.connect_info*, %struct.connect_info** %3
%16 = call i32 @free(%struct.connect_info* %15)
br label %4
17: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
%struct.connect_head = type { i32 }
%struct.connect_info = type { i32 }
define i32 @free_connections(%struct.connect_head* %0) {
%2 = tail call i32 @SLIST_EMPTY(%struct.connect_head* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1, %4
%5 = tail call %struct.connect_info* @SLIST_FIRST(%struct.connect_head* %0)
%6 = tail call i32 @SLIST_REMOVE_HEAD(%struct.connect_head* %0, %struct.connect_head* %0)
%7 = tail call i32 @free(%struct.connect_info* %5)
%8 = tail call i32 @SLIST_EMPTY(%struct.connect_head* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %4, %1
ret i32 0
}