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

/* Variables and functions */
int /*<<< orphan*/ add_to_set(struct graph *, int, int, int);
int current_edge_set(struct graph *, int, int);
int /*<<< orphan*/ remove_from_set(struct graph *, int, int);
int set_for_edge(struct graph *, int, int);
void update_set(struct graph *g, int u, int v) {
  int newset = set_for_edge(g, u, v);
  int oldset = current_edge_set(g, u, v);
  if (newset == oldset)
    return;
  remove_from_set(g, u, v);
  add_to_set(g, u, v, newset);
}


x86 assembly (clang, -O0):
<update_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <set_for_edge@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <current_edge_set@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1187 <update_set+0x47>
jmp    11a8 <update_set+0x68>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <remove_from_set@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1060 <add_to_set@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_set>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <set_for_edge@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <current_edge_set@plt>
cmp    %eax,%r15d
jne    1174 <update_set+0x34>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <remove_from_set@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <add_to_set@plt>

LLVM IR (-O0):
%struct.graph = type { i32 }
define void @update_set(%struct.graph* %0, i32 %1, i32 %2) {
%4 = alloca %struct.graph*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.graph* %0, %struct.graph** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load %struct.graph*, %struct.graph** %4
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @set_for_edge(%struct.graph* %9, i32 %10, i32 %11)
store i32 %12, i32* %7
%13 = load %struct.graph*, %struct.graph** %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @current_edge_set(%struct.graph* %13, i32 %14, i32 %15)
store i32 %16, i32* %8
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %3
br label %31
21: ; preds = %3
%22 = load %struct.graph*, %struct.graph** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @remove_from_set(%struct.graph* %22, i32 %23, i32 %24)
%26 = load %struct.graph*, %struct.graph** %4
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @add_to_set(%struct.graph* %26, i32 %27, i32 %28, i32 %29)
br label %31
31: ; preds = %21, %20
ret void
}

LLVM IR (-O2):
%struct.graph = type { i32 }
define void @update_set(%struct.graph* %0, i32 %1, i32 %2) {
%4 = tail call i32 @set_for_edge(%struct.graph* %0, i32 %1, i32 %2)
%5 = tail call i32 @current_edge_set(%struct.graph* %0, i32 %1, i32 %2)
%6 = icmp eq i32 %4, %5
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @remove_from_set(%struct.graph* %0, i32 %1, i32 %2)
%9 = tail call i32 @add_to_set(%struct.graph* %0, i32 %1, i32 %2, i32 %4)
br label %10
10: ; preds = %3, %7
ret void
}