#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_frame_format_filter(short int fff_mode) {
  short int temp = 0;
  switch (fff_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x0D);
    temp = temp & (!0x0E);
    write_ZIGBEE_short(0x0D, temp);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x0D);
    temp = temp & (!0x06);
    temp = temp | 0x08;
    write_ZIGBEE_short(0x0D, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x0D);
    temp = temp & (!0x0A);
    temp = temp | 0x04;
    write_ZIGBEE_short(0x0D, temp);
  } break;
  case 4: {
    temp = read_ZIGBEE_short(0x0D);
    temp = temp & (!0x0C);
    temp = temp | 0x02;
    write_ZIGBEE_short(0x0D, temp);
  } break;
  }
}


x86 assembly (clang, -O0):
<set_frame_format_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movw   $0x0,-0x4(%rbp)
movswl -0x2(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     122b <set_frame_format_filter+0x10b>
mov    -0x10(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xd,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0x0,%eax
mov    %ax,-0x4(%rbp)
mov    $0xd,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    122b <set_frame_format_filter+0x10b>
mov    $0xd,%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     $0x8,%eax
mov    %ax,-0x4(%rbp)
mov    $0xd,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    122b <set_frame_format_filter+0x10b>
mov    $0xd,%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     $0x4,%eax
mov    %ax,-0x4(%rbp)
mov    $0xd,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    122b <set_frame_format_filter+0x10b>
mov    $0xd,%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)
mov    $0xd,%edi
movswl -0x4(%rbp),%esi
call   1040 <write_ZIGBEE_short@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_frame_format_filter>:
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1153 <set_frame_format_filter+0x33>
push   %rbx
shl    $0x4,%edi
movabs $0x2000400080000,%rbx
mov    %edi,%ecx
shr    %cl,%rbx
mov    $0xd,%edi
call   1030 <read_ZIGBEE_short@plt>
movswl %bx,%esi
mov    $0xd,%edi
pop    %rbx
jmp    1040 <write_ZIGBEE_short@plt>
ret

LLVM IR (-O0):
define void @set_frame_format_filter(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 %50 [
i32 1, label %6
i32 2, label %14
i32 3, label %26
i32 4, label %38
]
6: ; preds = %1
%7 = call signext i16 @read_ZIGBEE_short(i32 13)
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 13, i16 signext %12)
br label %50
14: ; preds = %1
%15 = call signext i16 @read_ZIGBEE_short(i32 13)
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, 8
%23 = trunc i32 %22 to i16
store i16 %23, i16* %3
%24 = load i16, i16* %3
%25 = call i32 @write_ZIGBEE_short(i32 13, i16 signext %24)
br label %50
26: ; preds = %1
%27 = call signext i16 @read_ZIGBEE_short(i32 13)
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, 4
%35 = trunc i32 %34 to i16
store i16 %35, i16* %3
%36 = load i16, i16* %3
%37 = call i32 @write_ZIGBEE_short(i32 13, i16 signext %36)
br label %50
38: ; preds = %1
%39 = call signext i16 @read_ZIGBEE_short(i32 13)
store i16 %39, i16* %3
%40 = load i16, i16* %3
%41 = sext i16 %40 to i32
%42 = and i32 %41, 0
%43 = trunc i32 %42 to i16
store i16 %43, i16* %3
%44 = load i16, i16* %3
%45 = sext i16 %44 to i32
%46 = or i32 %45, 2
%47 = trunc i32 %46 to i16
store i16 %47, i16* %3
%48 = load i16, i16* %3
%49 = call i32 @write_ZIGBEE_short(i32 13, i16 signext %48)
br label %50
50: ; preds = %1, %38, %26, %14, %6
ret void
}

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