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

/* Variables and functions */
int stringset_add_stringset(struct stringset *, struct stringset const *);
struct stringset *stringset_alloc();
int /*<<< orphan*/ stringset_free(struct stringset *);
int stringset_remove_stringset(struct stringset *, struct stringset const *);
struct stringset *stringset_alloc_difference(struct stringset const *first,
                                             struct stringset const *second) {
  struct stringset *stringset = stringset_alloc();
  if (!stringset)
    return NULL;
  int result = stringset_add_stringset(stringset, first);
  if (-1 == result) {
    stringset_free(stringset);
    return NULL;
  }
  result = stringset_remove_stringset(stringset, second);
  if (-1 == result) {
    stringset_free(stringset);
    return NULL;
  }
  return stringset;
}


x86 assembly (clang, -O0):
<stringset_alloc_difference>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <stringset_alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1173 <stringset_alloc_difference+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11e3 <stringset_alloc_difference+0xa3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <stringset_add_stringset@plt>
mov    %eax,-0x24(%rbp)
mov    $0xffffffff,%eax
cmp    -0x24(%rbp),%eax
jne    11a7 <stringset_alloc_difference+0x67>
mov    -0x20(%rbp),%rdi
call   1040 <stringset_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e3 <stringset_alloc_difference+0xa3>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <stringset_remove_stringset@plt>
mov    %eax,-0x24(%rbp)
mov    $0xffffffff,%eax
cmp    -0x24(%rbp),%eax
jne    11db <stringset_alloc_difference+0x9b>
mov    -0x20(%rbp),%rdi
call   1040 <stringset_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e3 <stringset_alloc_difference+0xa3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringset_alloc_difference>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <stringset_alloc@plt>
test   %rax,%rax
je     1182 <stringset_alloc_difference+0x42>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <stringset_add_stringset@plt>
cmp    $0xffffffff,%eax
je     117a <stringset_alloc_difference+0x3a>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <stringset_remove_stringset@plt>
cmp    $0xffffffff,%eax
jne    1184 <stringset_alloc_difference+0x44>
mov    %rbx,%rdi
call   1040 <stringset_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stringset = type { i32 }
define %struct.stringset* @stringset_alloc_difference(%struct.stringset* %0, %struct.stringset* %1) {
%3 = alloca %struct.stringset*
%4 = alloca %struct.stringset*
%5 = alloca %struct.stringset*
%6 = alloca %struct.stringset*
%7 = alloca i32
store %struct.stringset* %0, %struct.stringset** %4
store %struct.stringset* %1, %struct.stringset** %5
%8 = call %struct.stringset* (...) @stringset_alloc()
store %struct.stringset* %8, %struct.stringset** %6
%9 = load %struct.stringset*, %struct.stringset** %6
%10 = icmp ne %struct.stringset* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store %struct.stringset* null, %struct.stringset** %3
br label %32
12: ; preds = %2
%13 = load %struct.stringset*, %struct.stringset** %6
%14 = load %struct.stringset*, %struct.stringset** %4
%15 = call i32 @stringset_add_stringset(%struct.stringset* %13, %struct.stringset* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp eq i32 -1, %16
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load %struct.stringset*, %struct.stringset** %6
%20 = call i32 @stringset_free(%struct.stringset* %19)
store %struct.stringset* null, %struct.stringset** %3
br label %32
21: ; preds = %12
%22 = load %struct.stringset*, %struct.stringset** %6
%23 = load %struct.stringset*, %struct.stringset** %5
%24 = call i32 @stringset_remove_stringset(%struct.stringset* %22, %struct.stringset* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp eq i32 -1, %25
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load %struct.stringset*, %struct.stringset** %6
%29 = call i32 @stringset_free(%struct.stringset* %28)
store %struct.stringset* null, %struct.stringset** %3
br label %32
30: ; preds = %21
%31 = load %struct.stringset*, %struct.stringset** %6
store %struct.stringset* %31, %struct.stringset** %3
br label %32
32: ; preds = %30, %27, %18, %11
%33 = load %struct.stringset*, %struct.stringset** %3
ret %struct.stringset* %33
}

LLVM IR (-O2):
%struct.stringset = type { i32 }
define %struct.stringset* @stringset_alloc_difference(%struct.stringset* %0, %struct.stringset* %1) {
%3 = tail call %struct.stringset* (...) @stringset_alloc()
%4 = icmp eq %struct.stringset* %3, null
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 @stringset_add_stringset(%struct.stringset* %3, %struct.stringset* %0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @stringset_remove_stringset(%struct.stringset* %3, %struct.stringset* %1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %8, %5
%12 = tail call i32 @stringset_free(%struct.stringset* %3)
br label %13
13: ; preds = %11, %8, %2
%14 = phi %struct.stringset* [ null, %2 ], [ %3, %8 ], [ null, %11 ]
ret %struct.stringset* %14
}