struct list_node *list_pop(struct list_node *head) {
  struct list_node *next = list_first(head);
  do {
    if (next == head) {
      kprintf("[ASSERT] (%s:%d) failed.\n", __func__, 86);
    }
  } while (0);
  list_del(next);
  return next;
}


x86 assembly (clang, -O0):
<list_pop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <list_first@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1175 <list_pop+0x45>
lea    0xe9e(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x56,%edx
mov    $0x0,%al
call   1050 <kprintf@plt>
jmp    117a <list_pop+0x4a>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <list_del@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_pop>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <list_first@plt>
movslq %eax,%r14
cmp    %rbx,%r14
jne    1160 <list_pop+0x30>
lea    0xeb3(%rip),%rdi
lea    0xec6(%rip),%rsi
mov    $0x56,%edx
xor    %eax,%eax
call   1050 <kprintf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <list_del@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.list_node = type opaque
@.str = [26 x i8] c"[ASSERT] (%s:%d) failed.\0A\00"
@__func__.list_pop = [9 x i8] c"list_pop\00"
define %struct.list_node* @list_pop(%struct.list_node* %0) {
%2 = alloca %struct.list_node*
%3 = alloca %struct.list_node*
store %struct.list_node* %0, %struct.list_node** %2
%4 = load %struct.list_node*, %struct.list_node** %2
%5 = call i32 (%struct.list_node*, ...) bitcast (i32 (...)* @list_first to i32 (%struct.list_node*, ...)*)(%struct.list_node* %4)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to %struct.list_node*
store %struct.list_node* %7, %struct.list_node** %3
br label %8
8: ; preds = %1
%9 = load %struct.list_node*, %struct.list_node** %3
%10 = load %struct.list_node*, %struct.list_node** %2
%11 = icmp eq %struct.list_node* %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @kprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.list_pop, i64 0, i64 0), i32 86)
br label %14
14: ; preds = %12, %8
br label %15
15: ; preds = %14
%16 = load %struct.list_node*, %struct.list_node** %3
%17 = call i32 (%struct.list_node*, ...) bitcast (i32 (...)* @list_del to i32 (%struct.list_node*, ...)*)(%struct.list_node* %16)
%18 = load %struct.list_node*, %struct.list_node** %3
ret %struct.list_node* %18
}

LLVM IR (-O2):
%struct.list_node = type opaque
@.str = [26 x i8] c"[ASSERT] (%s:%d) failed.\0A\00"
@__func__.list_pop = [9 x i8] c"list_pop\00"
define %struct.list_node* @list_pop(%struct.list_node* %0) {
%2 = tail call i32 (%struct.list_node*, ...) bitcast (i32 (...)* @list_first to i32 (%struct.list_node*, ...)*)(%struct.list_node* %0)
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to %struct.list_node*
%5 = icmp eq %struct.list_node* %4, %0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @kprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.list_pop, i64 0, i64 0), i32 86)
br label %8
8: ; preds = %6, %1
%9 = tail call i32 (%struct.list_node*, ...) bitcast (i32 (...)* @list_del to i32 (%struct.list_node*, ...)*)(%struct.list_node* %4)
ret %struct.list_node* %4
}