#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 */
typedef int CARD32;
typedef int CARD16;

/* Variables and functions */
CARD32 ConvertMotifAction(CARD16 motif_action) {
  CARD32 olit_action;
  olit_action = (1 << 2);
  if (motif_action & (1 << 0))
    olit_action |= (1 << 0);
  else if (motif_action & (1 << 1))
    olit_action |= 0;
  else if (motif_action & (1 << 2))
    olit_action |= (1 << 10);
  else
    olit_action = 0;
  return olit_action;
}


x86 assembly (clang, -O0):
<ConvertMotifAction>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     112b <ConvertMotifAction+0x2b>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <ConvertMotifAction+0x78>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1148 <ConvertMotifAction+0x48>
mov    -0x8(%rbp),%eax
or     $0x0,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <ConvertMotifAction+0x73>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1167 <ConvertMotifAction+0x67>
mov    -0x8(%rbp),%eax
or     $0x400,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <ConvertMotifAction+0x6e>
movl   $0x0,-0x8(%rbp)
jmp    1173 <ConvertMotifAction+0x73>
jmp    1178 <ConvertMotifAction+0x78>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertMotifAction>:
mov    $0x5,%eax
test   $0x1,%dil
jne    1124 <ConvertMotifAction+0x24>
mov    $0x4,%eax
test   $0x2,%dil
jne    1124 <ConvertMotifAction+0x24>
shl    $0x1d,%edi
sar    $0x1f,%edi
and    $0x404,%edi
mov    %edi,%eax
ret

LLVM IR (-O0):
define i32 @ConvertMotifAction(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = or i32 %8, 1
store i32 %9, i32* %3
br label %27
10: ; preds = %1
%11 = load i32, i32* %2
%12 = and i32 %11, 2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %3
%16 = or i32 %15, 0
store i32 %16, i32* %3
br label %26
17: ; preds = %10
%18 = load i32, i32* %2
%19 = and i32 %18, 4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %3
%23 = or i32 %22, 1024
store i32 %23, i32* %3
br label %25
24: ; preds = %17
store i32 0, i32* %3
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25, %14
br label %27
27: ; preds = %26, %7
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @ConvertMotifAction(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = and i32 %0, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = and i32 %0, 4
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 0, i32 1028
br label %11
11: ; preds = %7, %4, %1
%12 = phi i32 [ 5, %1 ], [ 4, %4 ], [ %10, %7 ]
ret i32 %12
}