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


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

x86 assembly (clang, -O2):
<dbl>:
push   %rbx
sub    $0x10,%rsp
mov    %di,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>
mov    $0x2,%edx
mov    $0x5,%edi
xor    %esi,%esi
call   1070 <__CrestLoad@plt>
movswq 0xc(%rsp),%rdx
mov    $0x4,%edi
mov    %rbx,%rsi
call   1070 <__CrestLoad@plt>
movswq 0xc(%rsp),%rdx
add    %rdx,%rdx
mov    $0x3,%edi
mov    $0x2,%esi
call   1030 <__CrestApply2@plt>
lea    0xe(%rsp),%rbx
mov    $0x6,%edi
mov    %rbx,%rsi
call   1040 <__CrestStore@plt>
movzwl 0xc(%rsp),%eax
add    %eax,%eax
mov    %ax,0xe(%rsp)
movswq %ax,%rdx
mov    $0x7,%edi
mov    %rbx,%rsi
call   1070 <__CrestLoad@plt>
mov    $0x8,%edi
call   1050 <__CrestReturn@plt>
movzwl 0xe(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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