#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 */
short read_ZIGBEE_short(int);
int /*<<< orphan*/ write_ZIGBEE_short(int, short);
void set_reception_mode(short int r_mode) {
  short int temp = 0;
  switch (r_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x00);
    temp = temp & (!0x03);
    write_ZIGBEE_short(0x00, temp);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x00);
    temp = temp & (!0x01);
    temp = temp | 0x02;
    write_ZIGBEE_short(0x00, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x00);
    temp = temp & (!0x02);
    temp = temp | 0x01;
    write_ZIGBEE_short(0x00, temp);
  } break;
  }
}


x86 assembly (clang, -O0):
<set_reception_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movw   $0x0,-0x4(%rbp)
movswl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     116c <set_reception_mode+0x4c>
jmp    114a <set_reception_mode+0x2a>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1192 <set_reception_mode+0x72>
jmp    115b <set_reception_mode+0x3b>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11c3 <set_reception_mode+0xa3>
jmp    11ef <set_reception_mode+0xcf>
xor    %edi,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0x0,%eax
mov    %ax,-0x4(%rbp)
xor    %edi,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    11ef <set_reception_mode+0xcf>
xor    %edi,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0x0,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x2,%eax
mov    %ax,-0x4(%rbp)
xor    %edi,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    11ef <set_reception_mode+0xcf>
xor    %edi,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0x0,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x1,%eax
mov    %ax,-0x4(%rbp)
xor    %edi,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_reception_mode>:
add    $0xffffffff,%edi
cmp    $0x2,%edi
ja     114d <set_reception_mode+0x2d>
push   %rbx
shl    $0x4,%edi
movabs $0x100020000,%rbx
mov    %edi,%ecx
shr    %cl,%rbx
xor    %edi,%edi
call   1030 <read_ZIGBEE_short@plt>
movswl %bx,%esi
xor    %edi,%edi
pop    %rbx
jmp    1040 <write_ZIGBEE_short@plt>
ret

LLVM IR (-O0):
define void @set_reception_mode(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %2
store i16 0, i16* %3
%4 = load i16, i16* %2
%5 = sext i16 %4 to i32
switch i32 %5, label %38 [
i32 1, label %6
i32 2, label %14
i32 3, label %26
]
6: ; preds = %1
%7 = call signext i16 @read_ZIGBEE_short(i32 0)
store i16 %7, i16* %3
%8 = load i16, i16* %3
%9 = sext i16 %8 to i32
%10 = and i32 %9, 0
%11 = trunc i32 %10 to i16
store i16 %11, i16* %3
%12 = load i16, i16* %3
%13 = call i32 @write_ZIGBEE_short(i32 0, i16 signext %12)
br label %38
14: ; preds = %1
%15 = call signext i16 @read_ZIGBEE_short(i32 0)
store i16 %15, i16* %3
%16 = load i16, i16* %3
%17 = sext i16 %16 to i32
%18 = and i32 %17, 0
%19 = trunc i32 %18 to i16
store i16 %19, i16* %3
%20 = load i16, i16* %3
%21 = sext i16 %20 to i32
%22 = or i32 %21, 2
%23 = trunc i32 %22 to i16
store i16 %23, i16* %3
%24 = load i16, i16* %3
%25 = call i32 @write_ZIGBEE_short(i32 0, i16 signext %24)
br label %38
26: ; preds = %1
%27 = call signext i16 @read_ZIGBEE_short(i32 0)
store i16 %27, i16* %3
%28 = load i16, i16* %3
%29 = sext i16 %28 to i32
%30 = and i32 %29, 0
%31 = trunc i32 %30 to i16
store i16 %31, i16* %3
%32 = load i16, i16* %3
%33 = sext i16 %32 to i32
%34 = or i32 %33, 1
%35 = trunc i32 %34 to i16
store i16 %35, i16* %3
%36 = load i16, i16* %3
%37 = call i32 @write_ZIGBEE_short(i32 0, i16 signext %36)
br label %38
38: ; preds = %1, %26, %14, %6
ret void
}

LLVM IR (-O2):
define void @set_reception_mode(i16 signext %0) {
%2 = sext i16 %0 to i32
%3 = add nsw i32 %2, -1
%4 = icmp ult i32 %3, 3
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = zext i32 %3 to i48
%7 = shl nuw nsw i48 %6, 4
%8 = lshr i48 4295098368, %7
%9 = trunc i48 %8 to i16
%10 = tail call signext i16 @read_ZIGBEE_short(i32 0)
%11 = tail call i32 @write_ZIGBEE_short(i32 0, i16 signext %9)
br label %12
12: ; preds = %1, %5
ret void
}