#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 /*<<< orphan*/ bcm2835_write(int, int);
int /*<<< orphan*/ printk(char *, int);
int gpio_clear_interrupt(int which_one) {
  uint32_t address_offset, bit;
  if (which_one > 54) {
    printk("GPIO%d too big\n", which_one);
    return -1;
  }
  bit = 1 << (which_one & 0x1f);
  address_offset = (which_one / 32) * 4;
  bcm2835_write(((0 + 0x200000) + 0x40) + address_offset, bit);
  return 0;
}


x86 assembly (clang, -O0):
<gpio_clear_interrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x36,-0x8(%rbp)
jle    1150 <gpio_clear_interrupt+0x30>
mov    -0x8(%rbp),%esi
lea    0xec1(%rip),%rdi
call   1030 <printk@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1189 <gpio_clear_interrupt+0x69>
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    $0x200040,%edi
mov    -0x10(%rbp),%esi
call   1040 <bcm2835_write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_clear_interrupt>:
push   %rax
mov    %edi,%ecx
cmp    $0x37,%edi
jl     113d <gpio_clear_interrupt+0x1d>
lea    0xed1(%rip),%rdi
mov    %ecx,%esi
call   1030 <printk@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    $0x1,%esi
shl    %cl,%esi
lea    0x1f(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x5,%eax
lea    0x200040(,%rax,4),%edi
call   1040 <bcm2835_write@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"GPIO%d too big\0A\00"
define i32 @gpio_clear_interrupt(i32 %0) {
%2 = icmp sgt i32 %0, 54
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printk(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %12
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, 2097216
%11 = tail call i32 @bcm2835_write(i32 %10, i32 %7)
br label %12
12: ; preds = %5, %3
%13 = phi i32 [ -1, %3 ], [ 0, %5 ]
ret i32 %13
}