#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*/ free(struct set **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_add(struct set *, int);
int /*<<< orphan*/ set_fprint(struct set *, int /*<<< orphan*/);
int /*<<< orphan*/ set_free(struct set *);
struct set *set_new();
int /*<<< orphan*/ set_remove(struct set *, int);
int /*<<< orphan*/ set_subset(struct set *, int, struct set ***, int *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  struct set *S = set_new();
  set_add(S, 1);
  set_add(S, 2);
  set_add(S, 3);
  set_add(S, 4);
  set_fprint(S, stdout);
  printf("\n");
  set_remove(S, 1);
  set_fprint(S, stdout);
  printf("\n");
  struct set **subsets = NULL;
  int subsets_n;
  int i;
  set_subset(S, 2, &subsets, &subsets_n);
  for (i = 0; i < subsets_n; i++) {
    set_fprint(subsets[i], stdout);
    printf("\n");
    set_free(subsets[i]);
  }
  free(subsets);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <set_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <set_add@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <set_add@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <set_add@plt>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <set_add@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
call   1090 <set_fprint@plt>
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1080 <set_remove@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   1090 <set_fprint@plt>
lea    0xde2(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1040 <set_subset@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1299 <main+0x119>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
call   1090 <set_fprint@plt>
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <set_free@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1248 <main+0xc8>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <set_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
call   10a0 <set_add@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   10a0 <set_add@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   10a0 <set_add@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   10a0 <set_add@plt>
mov    0x2e12(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1090 <set_fprint@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1080 <set_remove@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1090 <set_fprint@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %r14,%rdi
mov    $0x2,%esi
call   1050 <set_subset@plt>
cmpl   $0x0,0x4(%rsp)
jle    1267 <main+0xe7>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
mov    (%r15),%esi
call   1090 <set_fprint@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1060 <set_free@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xb0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.set = type { i32 }
@stdout = global i32 0
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.set*
%7 = alloca %struct.set**
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call %struct.set* (...) @set_new()
store %struct.set* %10, %struct.set** %6
%11 = load %struct.set*, %struct.set** %6
%12 = call i32 @set_add(%struct.set* %11, i32 1)
%13 = load %struct.set*, %struct.set** %6
%14 = call i32 @set_add(%struct.set* %13, i32 2)
%15 = load %struct.set*, %struct.set** %6
%16 = call i32 @set_add(%struct.set* %15, i32 3)
%17 = load %struct.set*, %struct.set** %6
%18 = call i32 @set_add(%struct.set* %17, i32 4)
%19 = load %struct.set*, %struct.set** %6
%20 = load i32, i32* @stdout
%21 = call i32 @set_fprint(%struct.set* %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = load %struct.set*, %struct.set** %6
%24 = call i32 @set_remove(%struct.set* %23, i32 1)
%25 = load %struct.set*, %struct.set** %6
%26 = load i32, i32* @stdout
%27 = call i32 @set_fprint(%struct.set* %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store %struct.set** null, %struct.set*** %7
%29 = load %struct.set*, %struct.set** %6
%30 = call i32 @set_subset(%struct.set* %29, i32 2, %struct.set*** %7, i32* %8)
store i32 0, i32* %9
br label %31
31: ; preds = %50, %2
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %53
35: ; preds = %31
%36 = load %struct.set**, %struct.set*** %7
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds %struct.set*, %struct.set** %36, i64 %38
%40 = load %struct.set*, %struct.set** %39
%41 = load i32, i32* @stdout
%42 = call i32 @set_fprint(%struct.set* %40, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%44 = load %struct.set**, %struct.set*** %7
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.set*, %struct.set** %44, i64 %46
%48 = load %struct.set*, %struct.set** %47
%49 = call i32 @set_free(%struct.set* %48)
br label %50
50: ; preds = %35
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %31
53: ; preds = %31
%54 = load %struct.set**, %struct.set*** %7
%55 = call i32 @free(%struct.set** %54)
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
%struct.set = type { i32 }
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.set**
%4 = alloca i32
%5 = tail call %struct.set* (...) @set_new()
%6 = tail call i32 @set_add(%struct.set* %5, i32 1)
%7 = tail call i32 @set_add(%struct.set* %5, i32 2)
%8 = tail call i32 @set_add(%struct.set* %5, i32 3)
%9 = tail call i32 @set_add(%struct.set* %5, i32 4)
%10 = load i32, i32* @stdout
%11 = tail call i32 @set_fprint(%struct.set* %5, i32 %10)
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32 @set_remove(%struct.set* %5, i32 1)
%14 = load i32, i32* @stdout
%15 = tail call i32 @set_fprint(%struct.set* %5, i32 %14)
%16 = tail call i32 @putchar(i32 10)
%17 = bitcast %struct.set*** %3 to i8*
store %struct.set** null, %struct.set*** %3
%18 = bitcast i32* %4 to i8*
%19 = call i32 @set_subset(%struct.set* %5, i32 2, %struct.set*** %3, i32* %4)
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %2, %22
%23 = phi i64 [ %34, %22 ], [ 0, %2 ]
%24 = load %struct.set**, %struct.set*** %3
%25 = getelementptr inbounds %struct.set*, %struct.set** %24, i64 %23
%26 = load %struct.set*, %struct.set** %25
%27 = load i32, i32* @stdout
%28 = call i32 @set_fprint(%struct.set* %26, i32 %27)
%29 = call i32 @putchar(i32 10)
%30 = load %struct.set**, %struct.set*** %3
%31 = getelementptr inbounds %struct.set*, %struct.set** %30, i64 %23
%32 = load %struct.set*, %struct.set** %31
%33 = call i32 @set_free(%struct.set* %32)
%34 = add nuw nsw i64 %23, 1
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %22, label %38
38: ; preds = %22, %2
%39 = load %struct.set**, %struct.set*** %3
%40 = call i32 @free(%struct.set** %39)
ret i32 0
}