#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, int);
void set_CCA_mode(short int CCA_mode) {
  short int temp = 0;
  switch (CCA_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x80;
    temp = temp & 0xDF;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x40;
    temp = temp & 0x7F;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0xC0;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  }
}


x86 assembly (clang, -O0):
<set_CCA_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_CCA_mode+0x4c>
jmp    114a <set_CCA_mode+0x2a>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11b6 <set_CCA_mode+0x96>
jmp    115b <set_CCA_mode+0x3b>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     1221 <set_CCA_mode+0x101>
jmp    128d <set_CCA_mode+0x16d>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x80,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0xdf,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3f,%edi
mov    $0x60,%esi
call   1040 <write_ZIGBEE_short@plt>
jmp    128d <set_CCA_mode+0x16d>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x40,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0x7f,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x38,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0xfb,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
jmp    128d <set_CCA_mode+0x16d>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0xc0,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
or     $0x38,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
and    $0xfb,%eax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3f,%edi
mov    $0x60,%esi
call   1040 <write_ZIGBEE_short@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_CCA_mode>:
push   %rax
cmp    $0x3,%edi
je     1149 <set_CCA_mode+0x29>
cmp    $0x2,%edi
je     1191 <set_CCA_mode+0x71>
cmp    $0x1,%edi
jne    11c8 <set_CCA_mode+0xa8>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
and    $0x5f,%eax
lea    0x80(%rax),%esi
jmp    1177 <set_CCA_mode+0x57>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
or     $0xc0,%eax
movswl %ax,%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
and    $0xc3,%eax
lea    0x38(%rax),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3f,%edi
mov    $0x60,%esi
pop    %rax
jmp    1040 <write_ZIGBEE_short@plt>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
and    $0x3f,%eax
lea    0x40(%rax),%esi
mov    $0x3a,%edi
call   1040 <write_ZIGBEE_short@plt>
mov    $0x3a,%edi
call   1030 <read_ZIGBEE_short@plt>
and    $0xc3,%eax
lea    0x38(%rax),%esi
mov    $0x3a,%edi
pop    %rax
jmp    1040 <write_ZIGBEE_short@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @set_CCA_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 %67 [
i32 1, label %6
i32 2, label %20
i32 3, label %45
]
6: ; preds = %1
%7 = call signext i16 @read_ZIGBEE_short(i32 58)
store i16 %7, i16* %3
%8 = load i16, i16* %3
%9 = sext i16 %8 to i32
%10 = or i32 %9, 128
%11 = trunc i32 %10 to i16
store i16 %11, i16* %3
%12 = load i16, i16* %3
%13 = sext i16 %12 to i32
%14 = and i32 %13, 223
%15 = trunc i32 %14 to i16
store i16 %15, i16* %3
%16 = load i16, i16* %3
%17 = sext i16 %16 to i32
%18 = call i32 @write_ZIGBEE_short(i32 58, i32 %17)
%19 = call i32 @write_ZIGBEE_short(i32 63, i32 96)
br label %67
20: ; preds = %1
%21 = call signext i16 @read_ZIGBEE_short(i32 58)
store i16 %21, i16* %3
%22 = load i16, i16* %3
%23 = sext i16 %22 to i32
%24 = or i32 %23, 64
%25 = trunc i32 %24 to i16
store i16 %25, i16* %3
%26 = load i16, i16* %3
%27 = sext i16 %26 to i32
%28 = and i32 %27, 127
%29 = trunc i32 %28 to i16
store i16 %29, i16* %3
%30 = load i16, i16* %3
%31 = sext i16 %30 to i32
%32 = call i32 @write_ZIGBEE_short(i32 58, i32 %31)
%33 = call signext i16 @read_ZIGBEE_short(i32 58)
store i16 %33, i16* %3
%34 = load i16, i16* %3
%35 = sext i16 %34 to i32
%36 = or i32 %35, 56
%37 = trunc i32 %36 to i16
store i16 %37, i16* %3
%38 = load i16, i16* %3
%39 = sext i16 %38 to i32
%40 = and i32 %39, 251
%41 = trunc i32 %40 to i16
store i16 %41, i16* %3
%42 = load i16, i16* %3
%43 = sext i16 %42 to i32
%44 = call i32 @write_ZIGBEE_short(i32 58, i32 %43)
br label %67
45: ; preds = %1
%46 = call signext i16 @read_ZIGBEE_short(i32 58)
store i16 %46, i16* %3
%47 = load i16, i16* %3
%48 = sext i16 %47 to i32
%49 = or i32 %48, 192
%50 = trunc i32 %49 to i16
store i16 %50, i16* %3
%51 = load i16, i16* %3
%52 = sext i16 %51 to i32
%53 = call i32 @write_ZIGBEE_short(i32 58, i32 %52)
%54 = call signext i16 @read_ZIGBEE_short(i32 58)
store i16 %54, i16* %3
%55 = load i16, i16* %3
%56 = sext i16 %55 to i32
%57 = or i32 %56, 56
%58 = trunc i32 %57 to i16
store i16 %58, i16* %3
%59 = load i16, i16* %3
%60 = sext i16 %59 to i32
%61 = and i32 %60, 251
%62 = trunc i32 %61 to i16
store i16 %62, i16* %3
%63 = load i16, i16* %3
%64 = sext i16 %63 to i32
%65 = call i32 @write_ZIGBEE_short(i32 58, i32 %64)
%66 = call i32 @write_ZIGBEE_short(i32 63, i32 96)
br label %67
67: ; preds = %1, %45, %20, %6
ret void
}

LLVM IR (-O2):
define void @set_CCA_mode(i16 signext %0) {
%2 = sext i16 %0 to i32
switch i32 %2, label %32 [
i32 1, label %3
i32 2, label %10
i32 3, label %21
]
3: ; preds = %1
%4 = tail call signext i16 @read_ZIGBEE_short(i32 58)
%5 = and i16 %4, 95
%6 = or i16 %5, 128
%7 = zext i16 %6 to i32
%8 = tail call i32 @write_ZIGBEE_short(i32 58, i32 %7)
%9 = tail call i32 @write_ZIGBEE_short(i32 63, i32 96)
br label %32
10: ; preds = %1
%11 = tail call signext i16 @read_ZIGBEE_short(i32 58)
%12 = and i16 %11, 63
%13 = or i16 %12, 64
%14 = zext i16 %13 to i32
%15 = tail call i32 @write_ZIGBEE_short(i32 58, i32 %14)
%16 = tail call signext i16 @read_ZIGBEE_short(i32 58)
%17 = and i16 %16, 195
%18 = or i16 %17, 56
%19 = zext i16 %18 to i32
%20 = tail call i32 @write_ZIGBEE_short(i32 58, i32 %19)
br label %32
21: ; preds = %1
%22 = tail call signext i16 @read_ZIGBEE_short(i32 58)
%23 = or i16 %22, 192
%24 = sext i16 %23 to i32
%25 = tail call i32 @write_ZIGBEE_short(i32 58, i32 %24)
%26 = tail call signext i16 @read_ZIGBEE_short(i32 58)
%27 = and i16 %26, 195
%28 = or i16 %27, 56
%29 = zext i16 %28 to i32
%30 = tail call i32 @write_ZIGBEE_short(i32 58, i32 %29)
%31 = tail call i32 @write_ZIGBEE_short(i32 63, i32 96)
br label %32
32: ; preds = %1, %21, %10, %3
ret void
}