#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*/ __CrestApply2(int, int /*<<< orphan*/, long long);
int /*<<< orphan*/ __CrestCall(int, int);
int /*<<< orphan*/ __CrestLoad(int, unsigned long, long long);
int /*<<< orphan*/ __CrestReturn(int);
int /*<<< orphan*/ __CrestStore(int, unsigned long);
int inc(int x) {
  {
    __CrestCall(2, 1);
    __CrestStore(1, (unsigned long)(&x));
    __CrestLoad(5, (unsigned long)(&x), (long long)x);
    __CrestLoad(4, (unsigned long)0, (long long)1);
    __CrestApply2(3, 0, (long long)(x + 1));
    __CrestStore(6, (unsigned long)(&x));
    x++;
    {
      __CrestLoad(7, (unsigned long)(&x), (long long)x);
      __CrestReturn(8);
      return (x);
    }
  }
}


x86 assembly (clang, -O0):
<inc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1060 <__CrestCall@plt>
lea    -0x4(%rbp),%rsi
mov    $0x1,%edi
call   1040 <__CrestStore@plt>
lea    -0x4(%rbp),%rsi
movslq -0x4(%rbp),%rdx
mov    $0x5,%edi
call   1070 <__CrestLoad@plt>
mov    $0x4,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
call   1070 <__CrestLoad@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdx
mov    $0x3,%edi
xor    %esi,%esi
call   1030 <__CrestApply2@plt>
lea    -0x4(%rbp),%rsi
mov    $0x6,%edi
call   1040 <__CrestStore@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rsi
movslq -0x4(%rbp),%rdx
mov    $0x7,%edi
call   1070 <__CrestLoad@plt>
mov    $0x8,%edi
call   1050 <__CrestReturn@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inc>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1060 <__CrestCall@plt>
lea    0xc(%rsp),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <__CrestStore@plt>
movslq 0xc(%rsp),%rdx
mov    $0x5,%edi
mov    %rbx,%rsi
call   1070 <__CrestLoad@plt>
mov    $0x1,%edx
mov    $0x4,%edi
xor    %esi,%esi
call   1070 <__CrestLoad@plt>
movslq 0xc(%rsp),%rdx
add    $0x1,%rdx
mov    $0x3,%edi
xor    %esi,%esi
call   1030 <__CrestApply2@plt>
mov    $0x6,%edi
mov    %rbx,%rsi
call   1040 <__CrestStore@plt>
movslq 0xc(%rsp),%rdx
add    $0x1,%rdx
mov    %edx,0xc(%rsp)
mov    $0x7,%edi
mov    %rbx,%rsi
call   1070 <__CrestLoad@plt>
mov    $0x8,%edi
call   1050 <__CrestReturn@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @inc(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @__CrestCall(i32 2, i32 1)
%4 = ptrtoint i32* %2 to i64
%5 = call i32 @__CrestStore(i32 1, i64 %4)
%6 = ptrtoint i32* %2 to i64
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = call i32 @__CrestLoad(i32 5, i64 %6, i64 %8)
%10 = call i32 @__CrestLoad(i32 4, i64 0, i64 1)
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = call i32 @__CrestApply2(i32 3, i32 0, i64 %13)
%15 = ptrtoint i32* %2 to i64
%16 = call i32 @__CrestStore(i32 6, i64 %15)
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
%19 = ptrtoint i32* %2 to i64
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = call i32 @__CrestLoad(i32 7, i64 %19, i64 %21)
%23 = call i32 @__CrestReturn(i32 8)
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @inc(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = tail call i32 @__CrestCall(i32 2, i32 1)
%4 = ptrtoint i32* %2 to i64
%5 = call i32 @__CrestStore(i32 1, i64 %4)
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = call i32 @__CrestLoad(i32 5, i64 %4, i64 %7)
%9 = call i32 @__CrestLoad(i32 4, i64 0, i64 1)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = call i32 @__CrestApply2(i32 3, i32 0, i64 %12)
%14 = call i32 @__CrestStore(i32 6, i64 %4)
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = sext i32 %16 to i64
%18 = call i32 @__CrestLoad(i32 7, i64 %4, i64 %17)
%19 = call i32 @__CrestReturn(i32 8)
%20 = load i32, i32* %2
ret i32 %20
}