#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 */
typedef void bucket_loop;
struct bucket_list {
  int dummy;
};

/* Variables and functions */
void *init_bucket_loop(struct bucket_list *);
void *next_bucket_loop(void *);
int /*<<< orphan*/ objunref(void *);
int /*<<< orphan*/ remove_bucket_loop(void *);
void empty_buckets(void *data) {
  struct bucket_list *blist = data;
  struct bucket_loop *bloop;
  void *entry;
  bloop = init_bucket_loop(blist);
  while (bloop && (entry = next_bucket_loop(bloop))) {
    remove_bucket_loop(bloop);
    objunref(entry);
  }
  objunref(bloop);
}


x86 assembly (clang, -O0):
<empty_buckets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <init_bucket_loop@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     1188 <empty_buckets+0x48>
mov    -0x18(%rbp),%rdi
call   1060 <next_bucket_loop@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1198 <empty_buckets+0x58>
jmp    11af <empty_buckets+0x6f>
mov    -0x18(%rbp),%rdi
call   1040 <remove_bucket_loop@plt>
mov    -0x20(%rbp),%rdi
call   1050 <objunref@plt>
jmp    1161 <empty_buckets+0x21>
mov    -0x18(%rbp),%rdi
call   1050 <objunref@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<empty_buckets>:
push   %r14
push   %rbx
push   %rax
call   1030 <init_bucket_loop@plt>
mov    %rax,%r14
test   %rax,%rax
je     1190 <empty_buckets+0x50>
mov    %r14,%rdi
call   1060 <next_bucket_loop@plt>
test   %rax,%rax
je     1190 <empty_buckets+0x50>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <remove_bucket_loop@plt>
mov    %rbx,%rdi
call   1050 <objunref@plt>
mov    %r14,%rdi
call   1060 <next_bucket_loop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <empty_buckets+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <objunref@plt>

LLVM IR (-O0):
%struct.bucket_list = type { i32 }
%struct.bucket_loop = type opaque
define void @empty_buckets(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.bucket_list*
%4 = alloca %struct.bucket_loop*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to %struct.bucket_list*
store %struct.bucket_list* %7, %struct.bucket_list** %3
%8 = load %struct.bucket_list*, %struct.bucket_list** %3
%9 = call i8* @init_bucket_loop(%struct.bucket_list* %8)
%10 = bitcast i8* %9 to %struct.bucket_loop*
store %struct.bucket_loop* %10, %struct.bucket_loop** %4
br label %11
11: ; preds = %21, %1
%12 = load %struct.bucket_loop*, %struct.bucket_loop** %4
%13 = icmp ne %struct.bucket_loop* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load %struct.bucket_loop*, %struct.bucket_loop** %4
%16 = bitcast %struct.bucket_loop* %15 to i8*
%17 = call i8* @next_bucket_loop(i8* %16)
store i8* %17, i8** %5
%18 = icmp ne i8* %17, null
br label %19
19: ; preds = %14, %11
%20 = phi i1 [ false, %11 ], [ %18, %14 ]
br i1 %20, label %21, label %27
21: ; preds = %19
%22 = load %struct.bucket_loop*, %struct.bucket_loop** %4
%23 = bitcast %struct.bucket_loop* %22 to i8*
%24 = call i32 @remove_bucket_loop(i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @objunref(i8* %25)
br label %11
27: ; preds = %19
%28 = load %struct.bucket_loop*, %struct.bucket_loop** %4
%29 = bitcast %struct.bucket_loop* %28 to i8*
%30 = call i32 @objunref(i8* %29)
ret void
}

LLVM IR (-O2):
%struct.bucket_list = type { i32 }
define void @empty_buckets(i8* %0) {
%2 = bitcast i8* %0 to %struct.bucket_list*
%3 = tail call i8* @init_bucket_loop(%struct.bucket_list* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i8* @next_bucket_loop(i8* %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %5, %8
%9 = phi i8* [ %12, %8 ], [ %6, %5 ]
%10 = tail call i32 @remove_bucket_loop(i8* %3)
%11 = tail call i32 @objunref(i8* %9)
%12 = tail call i8* @next_bucket_loop(i8* %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %8
14: ; preds = %8, %5, %1
%15 = tail call i32 @objunref(i8* %3)
ret void
}