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

/* Variables and functions */
int /*<<< orphan*/ delete_node(struct personal_data *, int);
struct personal_data *find_node(struct personal_data *, int);
int /*<<< orphan*/ insert_node(struct personal_data *, struct personal_data *,
                               int);
swap_nodes(struct personal_data *root, int a, int b) {
  int temp;
  struct personal_data *node_a;
  struct personal_data *node_b;
  struct personal_data *temp_node;
  if (a > b) {
    temp = a;
    a = b;
    b = temp;
  }
  node_b = find_node(root, b);
  delete_node(root, b);
  node_a = find_node(root, a);
  delete_node(root, a);
  insert_node(root, node_b, a);
  insert_node(root, node_a, b);
}


x86 assembly (clang, -O0):
<swap_nodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1160 <swap_nodes+0x30>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <find_node@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <delete_node@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <find_node@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <delete_node@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <insert_node@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <insert_node@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_nodes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rdi,%rbx
cmp    %edx,%esi
mov    %edx,%r14d
cmovg  %esi,%r14d
cmovle %esi,%ebp
mov    %r14d,%esi
call   1030 <find_node@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <delete_node@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <find_node@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <delete_node@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <insert_node@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <insert_node@plt>

LLVM IR (-O0):
%struct.personal_data = type { i32 }
define i32 @swap_nodes(%struct.personal_data* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.personal_data*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.personal_data*
%10 = alloca %struct.personal_data*
%11 = alloca %struct.personal_data*
store %struct.personal_data* %0, %struct.personal_data** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* %6
store i32 %16, i32* %8
%17 = load i32, i32* %7
store i32 %17, i32* %6
%18 = load i32, i32* %8
store i32 %18, i32* %7
br label %19
19: ; preds = %15, %3
%20 = load %struct.personal_data*, %struct.personal_data** %5
%21 = load i32, i32* %7
%22 = call %struct.personal_data* @find_node(%struct.personal_data* %20, i32 %21)
store %struct.personal_data* %22, %struct.personal_data** %10
%23 = load %struct.personal_data*, %struct.personal_data** %5
%24 = load i32, i32* %7
%25 = call i32 @delete_node(%struct.personal_data* %23, i32 %24)
%26 = load %struct.personal_data*, %struct.personal_data** %5
%27 = load i32, i32* %6
%28 = call %struct.personal_data* @find_node(%struct.personal_data* %26, i32 %27)
store %struct.personal_data* %28, %struct.personal_data** %9
%29 = load %struct.personal_data*, %struct.personal_data** %5
%30 = load i32, i32* %6
%31 = call i32 @delete_node(%struct.personal_data* %29, i32 %30)
%32 = load %struct.personal_data*, %struct.personal_data** %5
%33 = load %struct.personal_data*, %struct.personal_data** %10
%34 = load i32, i32* %6
%35 = call i32 @insert_node(%struct.personal_data* %32, %struct.personal_data* %33, i32 %34)
%36 = load %struct.personal_data*, %struct.personal_data** %5
%37 = load %struct.personal_data*, %struct.personal_data** %9
%38 = load i32, i32* %7
%39 = call i32 @insert_node(%struct.personal_data* %36, %struct.personal_data* %37, i32 %38)
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
%struct.personal_data = type { i32 }
define i32 @swap_nodes(%struct.personal_data* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
%5 = select i1 %4, i32 %1, i32 %2
%6 = select i1 %4, i32 %2, i32 %1
%7 = tail call %struct.personal_data* @find_node(%struct.personal_data* %0, i32 %5)
%8 = tail call i32 @delete_node(%struct.personal_data* %0, i32 %5)
%9 = tail call %struct.personal_data* @find_node(%struct.personal_data* %0, i32 %6)
%10 = tail call i32 @delete_node(%struct.personal_data* %0, i32 %6)
%11 = tail call i32 @insert_node(%struct.personal_data* %0, %struct.personal_data* %7, i32 %6)
%12 = tail call i32 @insert_node(%struct.personal_data* %0, %struct.personal_data* %9, i32 %5)
ret i32 undef
}