#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 */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fancySwap(int *, int *);
void testFancySwap(void) {
  int i1 = 123;
  int i2 = 321;
  fancySwap(&i1, &i2);
  assert(i1 == 321 && i2 == 123);
  int i3 = 543;
  int i4 = 555;
  fancySwap(&i3, &i4);
  assert(i3 == 555 && i4 == 543);
}


x86 assembly (clang, -O0):
<testFancySwap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x7b,-0x4(%rbp)
movl   $0x141,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <fancySwap@plt>
xor    %eax,%eax
cmpl   $0x141,-0x4(%rbp)
mov    %al,-0x11(%rbp)
jne    115f <testFancySwap+0x3f>
cmpl   $0x7b,-0x8(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x21f,-0xc(%rbp)
movl   $0x22b,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <fancySwap@plt>
xor    %eax,%eax
cmpl   $0x22b,-0xc(%rbp)
mov    %al,-0x12(%rbp)
jne    11a6 <testFancySwap+0x86>
cmpl   $0x21f,-0x10(%rbp)
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testFancySwap>:
sub    $0x18,%rsp
movl   $0x7b,0x14(%rsp)
movl   $0x141,0x10(%rsp)
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <fancySwap@plt>
mov    $0x141,%eax
xor    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
xor    $0x7b,%ecx
xor    %edi,%edi
or     %eax,%ecx
sete   %dil
call   1030 <assert@plt>
movl   $0x21f,0xc(%rsp)
movl   $0x22b,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <fancySwap@plt>
mov    $0x22b,%eax
xor    0xc(%rsp),%eax
mov    $0x21f,%ecx
xor    0x8(%rsp),%ecx
xor    %edi,%edi
or     %eax,%ecx
sete   %dil
call   1030 <assert@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @testFancySwap() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 123, i32* %1
store i32 321, i32* %2
%5 = call i32 @fancySwap(i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 321
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 123
br label %11
11: ; preds = %8, %0
%12 = phi i1 [ false, %0 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
store i32 543, i32* %3
store i32 555, i32* %4
%15 = call i32 @fancySwap(i32* %3, i32* %4)
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 555
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 543
br label %21
21: ; preds = %18, %11
%22 = phi i1 [ false, %11 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret void
}

LLVM IR (-O2):
define void @testFancySwap() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 123, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 321, i32* %2
%7 = call i32 @fancySwap(i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 321
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 123
%12 = select i1 %9, i1 %11, i1 false
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = bitcast i32* %3 to i8*
store i32 543, i32* %3
%16 = bitcast i32* %4 to i8*
store i32 555, i32* %4
%17 = call i32 @fancySwap(i32* %3, i32* %4)
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 555
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 543
%22 = select i1 %19, i1 %21, i1 false
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret void
}