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

/* Variables and functions */
int /*<<< orphan*/ set_first_element(struct set *);
void *set_next_element(struct set *);
int /*<<< orphan*/ set_remove(struct set *, void *);
int set_size(struct set *);
void *set_pop(struct set *s) {
  if (set_size(s) < 1)
    return 0;
  void *element;
  set_first_element(s);
  element = set_next_element(s);
  if (!set_remove(s, element))
    return 0;
  else
    return element;
}


x86 assembly (clang, -O0):
<set_pop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <set_size@plt>
cmp    $0x1,%eax
jge    116b <set_pop+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11ac <set_pop+0x6c>
mov    -0x10(%rbp),%rdi
call   1050 <set_first_element@plt>
mov    -0x10(%rbp),%rdi
call   1040 <set_next_element@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <set_remove@plt>
cmp    $0x0,%eax
jne    11a4 <set_pop+0x64>
movq   $0x0,-0x8(%rbp)
jmp    11ac <set_pop+0x6c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pop>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <set_size@plt>
test   %eax,%eax
jle    117a <set_pop+0x3a>
mov    %rbx,%rdi
call   1050 <set_first_element@plt>
mov    %rbx,%rdi
call   1040 <set_next_element@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <set_remove@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovne %r14,%rax
jmp    117c <set_pop+0x3c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.set = type { i32 }
define i8* @set_pop(%struct.set* %0) {
%2 = alloca i8*
%3 = alloca %struct.set*
%4 = alloca i8*
store %struct.set* %0, %struct.set** %3
%5 = load %struct.set*, %struct.set** %3
%6 = call i32 @set_size(%struct.set* %5)
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* null, i8** %2
br label %21
9: ; preds = %1
%10 = load %struct.set*, %struct.set** %3
%11 = call i32 @set_first_element(%struct.set* %10)
%12 = load %struct.set*, %struct.set** %3
%13 = call i8* @set_next_element(%struct.set* %12)
store i8* %13, i8** %4
%14 = load %struct.set*, %struct.set** %3
%15 = load i8*, i8** %4
%16 = call i32 @set_remove(%struct.set* %14, i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %9
store i8* null, i8** %2
br label %21
19: ; preds = %9
%20 = load i8*, i8** %4
store i8* %20, i8** %2
br label %21
21: ; preds = %19, %18, %8
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
%struct.set = type { i32 }
define i8* @set_pop(%struct.set* %0) {
%2 = tail call i32 @set_size(%struct.set* %0)
%3 = icmp slt i32 %2, 1
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @set_first_element(%struct.set* %0)
%6 = tail call i8* @set_next_element(%struct.set* %0)
%7 = tail call i32 @set_remove(%struct.set* %0, i8* %6)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* null, i8* %6
br label %10
10: ; preds = %1, %4
%11 = phi i8* [ %9, %4 ], [ null, %1 ]
ret i8* %11
}