#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 */
unsigned long BSP_ReadIer();
int /*<<< orphan*/ BSP_WriteIer(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned int);
void BSP_DisableDspInterrupt(unsigned int dspInt) {
  unsigned long tmp;
  if (dspInt > 15 || dspInt < 4) {
    printf("bad dsp_int%d\n", dspInt);
    return;
  }
  tmp = BSP_ReadIer();
  tmp &= ~(1 << dspInt);
  BSP_WriteIer(tmp);
}


x86 assembly (clang, -O0):
<BSP_DisableDspInterrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xf,-0x4(%rbp)
ja     114f <BSP_DisableDspInterrupt+0x1f>
cmpl   $0x4,-0x4(%rbp)
jae    1163 <BSP_DisableDspInterrupt+0x33>
mov    -0x4(%rbp),%esi
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
jmp    118e <BSP_DisableDspInterrupt+0x5e>
mov    $0x0,%al
call   1030 <BSP_ReadIer@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
cltq
and    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <BSP_WriteIer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_DisableDspInterrupt>:
push   %rbx
mov    %edi,%ebx
lea    -0x10(%rbx),%eax
cmp    $0xfffffff3,%eax
ja     114a <BSP_DisableDspInterrupt+0x1a>
lea    0xebe(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <printf@plt>
xor    %eax,%eax
call   1030 <BSP_ReadIer@plt>
mov    $0xfffffffe,%edx
mov    %ebx,%ecx
rol    %cl,%edx
movslq %edx,%rdi
and    %rax,%rdi
pop    %rbx
jmp    1050 <BSP_WriteIer@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"bad dsp_int%d\0A\00"
define void @BSP_DisableDspInterrupt(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp ugt i32 %4, 15
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp ult i32 %7, 4
br i1 %8, label %9, label %12
9: ; preds = %6, %1
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %22
12: ; preds = %6
%13 = call i64 (...) @BSP_ReadIer()
store i64 %13, i64* %3
%14 = load i32, i32* %2
%15 = shl i32 1, %14
%16 = xor i32 %15, -1
%17 = sext i32 %16 to i64
%18 = load i64, i64* %3
%19 = and i64 %18, %17
store i64 %19, i64* %3
%20 = load i64, i64* %3
%21 = call i32 @BSP_WriteIer(i64 %20)
br label %22
22: ; preds = %12, %9
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"bad dsp_int%d\0A\00"
define void @BSP_DisableDspInterrupt(i32 %0) {
%2 = add i32 %0, -16
%3 = icmp ult i32 %2, -12
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %13
6: ; preds = %1
%7 = tail call i64 (...) @BSP_ReadIer()
%8 = shl nuw nsw i32 1, %0
%9 = xor i32 %8, -1
%10 = sext i32 %9 to i64
%11 = and i64 %7, %10
%12 = tail call i32 @BSP_WriteIer(i64 %11)
br label %13
13: ; preds = %6, %4
ret void
}