#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 uint32_t;

/* Variables and functions */
int bcm2835_read(int);
int /*<<< orphan*/ bcm2835_write(int, int);
int /*<<< orphan*/ printk(char *, int);
int irq_disable(int which_one) {
  uint32_t address_offset, bit, old;
  if (which_one > 64) {
    printk("IRQ%d too big\n", which_one);
    return -1;
  }
  bit = 1 << (which_one & 0x1f);
  address_offset = (which_one / 32) * 4;
  old = bcm2835_read((0 + 0x00b000 + 0x21c) + address_offset);
  bcm2835_write((0 + 0x00b000 + 0x21c) + address_offset, old | bit);
  return 0;
}


x86 assembly (clang, -O0):
<irq_disable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x40,-0x8(%rbp)
jle    1160 <irq_disable+0x30>
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
call   1030 <printk@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <irq_disable+0x7d>
mov    -0x8(%rbp),%ecx
and    $0x1f,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0xb21c,%edi
call   1040 <bcm2835_read@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
add    $0xb21c,%edi
mov    -0x14(%rbp),%esi
or     -0x10(%rbp),%esi
call   1050 <bcm2835_write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irq_disable>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x41,%edi
jl     114f <irq_disable+0x1f>
lea    0xebf(%rip),%rdi
mov    %ebx,%esi
call   1030 <printk@plt>
mov    $0xffffffff,%eax
jmp    1176 <irq_disable+0x46>
lea    0x1f(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
sar    $0x5,%eax
lea    0xb21c(,%rax,4),%ebp
mov    %ebp,%edi
call   1040 <bcm2835_read@plt>
bts    %ebx,%eax
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <bcm2835_write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"IRQ%d too big\0A\00"
define i32 @irq_disable(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 64
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @printk(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 -1, i32* %2
br label %28
12: ; preds = %1
%13 = load i32, i32* %3
%14 = and i32 %13, 31
%15 = shl i32 1, %14
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 32
%18 = mul nsw i32 %17, 4
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = add nsw i32 45596, %19
%21 = call i32 @bcm2835_read(i32 %20)
store i32 %21, i32* %6
%22 = load i32, i32* %4
%23 = add nsw i32 45596, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %5
%26 = or i32 %24, %25
%27 = call i32 @bcm2835_write(i32 %23, i32 %26)
store i32 0, i32* %2
br label %28
28: ; preds = %12, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [15 x i8] c"IRQ%d too big\0A\00"
define i32 @irq_disable(i32 %0) {
%2 = icmp sgt i32 %0, 64
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printk(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %14
5: ; preds = %1
%6 = and i32 %0, 31
%7 = shl nuw i32 1, %6
%8 = sdiv i32 %0, 32
%9 = shl nsw i32 %8, 2
%10 = add nsw i32 %9, 45596
%11 = tail call i32 @bcm2835_read(i32 %10)
%12 = or i32 %11, %7
%13 = tail call i32 @bcm2835_write(i32 %10, i32 %12)
br label %14
14: ; preds = %5, %3
%15 = phi i32 [ -1, %3 ], [ 0, %5 ]
ret i32 %15
}