#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 */

/* Variables and functions */
scalar_t__ complain_null_pointer_p(void **);
void swap_pointer(void **ptr_a, void **ptr_b) {
  void *tmp;
  if (complain_null_pointer_p(ptr_a)) {
    return;
  } else if (complain_null_pointer_p(ptr_b)) {
    return;
  } else if (*ptr_a == *ptr_b) {
    return;
  } else {
    tmp = *ptr_a;
    *ptr_a = *ptr_b;
    *ptr_b = tmp;
  }
}


x86 assembly (clang, -O0):
<swap_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <complain_null_pointer_p@plt>
cmp    $0x0,%rax
je     1138 <swap_pointer+0x28>
jmp    1197 <swap_pointer+0x87>
mov    -0x10(%rbp),%rdi
call   1030 <complain_null_pointer_p@plt>
cmp    $0x0,%rax
je     1150 <swap_pointer+0x40>
jmp    1197 <swap_pointer+0x87>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1169 <swap_pointer+0x59>
jmp    1197 <swap_pointer+0x87>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1192 <swap_pointer+0x82>
jmp    1197 <swap_pointer+0x87>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_pointer>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <complain_null_pointer_p@plt>
test   %rax,%rax
jne    1142 <swap_pointer+0x32>
mov    %r14,%rdi
call   1030 <complain_null_pointer_p@plt>
test   %rax,%rax
jne    1142 <swap_pointer+0x32>
mov    (%rbx),%rax
mov    (%r14),%rcx
cmp    %rcx,%rax
je     1142 <swap_pointer+0x32>
mov    %rcx,(%rbx)
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @swap_pointer(i8** %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8*
store i8** %0, i8*** %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %3
%7 = call i64 @complain_null_pointer_p(i8** %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
br label %32
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = call i64 @complain_null_pointer_p(i8** %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
br label %32
15: ; preds = %10
%16 = load i8**, i8*** %3
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %4
%19 = load i8*, i8** %18
%20 = icmp eq i8* %17, %19
br i1 %20, label %21, label %22
21: ; preds = %15
br label %32
22: ; preds = %15
%23 = load i8**, i8*** %3
%24 = load i8*, i8** %23
store i8* %24, i8** %5
%25 = load i8**, i8*** %4
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %3
store i8* %26, i8** %27
%28 = load i8*, i8** %5
%29 = load i8**, i8*** %4
store i8* %28, i8** %29
br label %30
30: ; preds = %22
br label %31
31: ; preds = %30
br label %32
32: ; preds = %9, %14, %21, %31
ret void
}

LLVM IR (-O2):
define void @swap_pointer(i8** %0, i8** %1) {
%3 = tail call i64 @complain_null_pointer_p(i8** %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i64 @complain_null_pointer_p(i8** %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = load i8*, i8** %0
%10 = load i8*, i8** %1
%11 = icmp eq i8* %9, %10
br i1 %11, label %13, label %12
12: ; preds = %8
store i8* %10, i8** %0
store i8* %9, i8** %1
br label %13
13: ; preds = %8, %5, %2, %12
ret void
}