#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*/ __CrestCall(int, int);
int /*<<< orphan*/ __CrestLoad(int, unsigned long, long long);
int /*<<< orphan*/ __CrestReturn(int);
int /*<<< orphan*/ __CrestStore(int, unsigned long);
void swap(int *a, int *b) {
  int tmp;
  {
    __CrestCall(86, 4);
    __CrestLoad(87, (unsigned long)a, (long long)*a);
    __CrestStore(88, (unsigned long)(&tmp));
    tmp = *a;
    __CrestLoad(89, (unsigned long)b, (long long)*b);
    __CrestStore(90, (unsigned long)a);
    *a = *b;
    __CrestLoad(91, (unsigned long)(&tmp), (long long)tmp);
    __CrestStore(92, (unsigned long)b);
    *b = tmp;
    {
      __CrestReturn(93);
      return;
    }
  }
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x56,%edi
mov    $0x4,%esi
call   1050 <__CrestCall@plt>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
movslq (%rax),%rdx
mov    $0x57,%edi
call   1060 <__CrestLoad@plt>
lea    -0x14(%rbp),%rsi
mov    $0x58,%edi
call   1030 <__CrestStore@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq (%rax),%rdx
mov    $0x59,%edi
call   1060 <__CrestLoad@plt>
mov    -0x8(%rbp),%rsi
mov    $0x5a,%edi
call   1030 <__CrestStore@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x14(%rbp),%rsi
movslq -0x14(%rbp),%rdx
mov    $0x5b,%edi
call   1060 <__CrestLoad@plt>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <__CrestStore@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x5d,%edi
call   1040 <__CrestReturn@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x56,%edi
mov    $0x4,%esi
call   1050 <__CrestCall@plt>
movslq (%rbx),%rdx
mov    $0x57,%edi
mov    %rbx,%rsi
call   1060 <__CrestLoad@plt>
lea    0xc(%rsp),%r15
mov    $0x58,%edi
mov    %r15,%rsi
call   1030 <__CrestStore@plt>
mov    (%rbx),%eax
mov    %eax,0xc(%rsp)
movslq (%r14),%rdx
mov    $0x59,%edi
mov    %r14,%rsi
call   1060 <__CrestLoad@plt>
mov    $0x5a,%edi
mov    %rbx,%rsi
call   1030 <__CrestStore@plt>
mov    (%r14),%eax
mov    %eax,(%rbx)
movslq 0xc(%rsp),%rdx
mov    $0x5b,%edi
mov    %r15,%rsi
call   1060 <__CrestLoad@plt>
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <__CrestStore@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%r14)
mov    $0x5d,%edi
call   1040 <__CrestReturn@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @swap(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = call i32 @__CrestCall(i32 86, i32 4)
%7 = load i32*, i32** %3
%8 = ptrtoint i32* %7 to i64
%9 = load i32*, i32** %3
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = call i32 @__CrestLoad(i32 87, i64 %8, i64 %11)
%13 = ptrtoint i32* %5 to i64
%14 = call i32 @__CrestStore(i32 88, i64 %13)
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
store i32 %16, i32* %5
%17 = load i32*, i32** %4
%18 = ptrtoint i32* %17 to i64
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = call i32 @__CrestLoad(i32 89, i64 %18, i64 %21)
%23 = load i32*, i32** %3
%24 = ptrtoint i32* %23 to i64
%25 = call i32 @__CrestStore(i32 90, i64 %24)
%26 = load i32*, i32** %4
%27 = load i32, i32* %26
%28 = load i32*, i32** %3
store i32 %27, i32* %28
%29 = ptrtoint i32* %5 to i64
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = call i32 @__CrestLoad(i32 91, i64 %29, i64 %31)
%33 = load i32*, i32** %4
%34 = ptrtoint i32* %33 to i64
%35 = call i32 @__CrestStore(i32 92, i64 %34)
%36 = load i32, i32* %5
%37 = load i32*, i32** %4
store i32 %36, i32* %37
%38 = call i32 @__CrestReturn(i32 93)
ret void
}

LLVM IR (-O2):
define void @swap(i32* %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @__CrestCall(i32 86, i32 4)
%6 = ptrtoint i32* %0 to i64
%7 = load i32, i32* %0
%8 = sext i32 %7 to i64
%9 = tail call i32 @__CrestLoad(i32 87, i64 %6, i64 %8)
%10 = ptrtoint i32* %3 to i64
%11 = call i32 @__CrestStore(i32 88, i64 %10)
%12 = load i32, i32* %0
store i32 %12, i32* %3
%13 = ptrtoint i32* %1 to i64
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = call i32 @__CrestLoad(i32 89, i64 %13, i64 %15)
%17 = call i32 @__CrestStore(i32 90, i64 %6)
%18 = load i32, i32* %1
store i32 %18, i32* %0
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = call i32 @__CrestLoad(i32 91, i64 %10, i64 %20)
%22 = call i32 @__CrestStore(i32 92, i64 %13)
%23 = load i32, i32* %3
store i32 %23, i32* %1
%24 = call i32 @__CrestReturn(i32 93)
ret void
}