#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*/ irq_enable(int);
int /*<<< orphan*/ printk(char *, int);
void pl011_uart_enable_interrupts(void) {
  uint32_t old;
  bcm2835_write((0 + 0x201000 + 0x44), 0x7FF);
  old = bcm2835_read((0 + 0x201000 + 0x34));
  old &= ~(0x7 << 3);
  bcm2835_write((0 + 0x201000 + 0x34), old);
  old = bcm2835_read((0 + 0x201000 + 0x38));
  printk("uart: previous IMSC: %x\n", old);
  old |= (1 << 6);
  printk("uart: new IMSC: %x\n", old);
  bcm2835_write((0 + 0x201000 + 0x38), old);
  irq_enable(57);
}


x86 assembly (clang, -O0):
<pl011_uart_enable_interrupts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x201044,%edi
mov    $0x7ff,%esi
call   1060 <bcm2835_write@plt>
mov    $0x201034,%edi
call   1050 <bcm2835_read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffffc7,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x201034,%edi
call   1060 <bcm2835_write@plt>
mov    $0x201038,%edi
call   1050 <bcm2835_read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1030 <printk@plt>
mov    -0x4(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1030 <printk@plt>
mov    -0x4(%rbp),%esi
mov    $0x201038,%edi
call   1060 <bcm2835_write@plt>
mov    $0x39,%edi
call   1040 <irq_enable@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pl011_uart_enable_interrupts>:
push   %rbx
mov    $0x201044,%edi
mov    $0x7ff,%esi
call   1060 <bcm2835_write@plt>
mov    $0x201034,%edi
call   1050 <bcm2835_read@plt>
and    $0xffffffc7,%eax
mov    $0x201034,%edi
mov    %eax,%esi
call   1060 <bcm2835_write@plt>
mov    $0x201038,%edi
call   1050 <bcm2835_read@plt>
mov    %eax,%ebx
lea    0xe84(%rip),%rdi
mov    %eax,%esi
call   1030 <printk@plt>
or     $0x40,%ebx
lea    0xe8c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printk@plt>
mov    $0x201038,%edi
mov    %ebx,%esi
call   1060 <bcm2835_write@plt>
mov    $0x39,%edi
pop    %rbx
jmp    1040 <irq_enable@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"uart: previous IMSC: %x\0A\00"
@.str.1 = [20 x i8] c"uart: new IMSC: %x\0A\00"
define void @pl011_uart_enable_interrupts() {
%1 = alloca i32
%2 = call i32 @bcm2835_write(i32 2101316, i32 2047)
%3 = call i32 @bcm2835_read(i32 2101300)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = and i32 %4, -57
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @bcm2835_write(i32 2101300, i32 %6)
%8 = call i32 @bcm2835_read(i32 2101304)
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = call i32 @printk(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = or i32 %11, 64
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = call i32 @printk(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @bcm2835_write(i32 2101304, i32 %15)
%17 = call i32 @irq_enable(i32 57)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"uart: previous IMSC: %x\0A\00"
@.str.1 = [20 x i8] c"uart: new IMSC: %x\0A\00"
define void @pl011_uart_enable_interrupts() {
%1 = tail call i32 @bcm2835_write(i32 2101316, i32 2047)
%2 = tail call i32 @bcm2835_read(i32 2101300)
%3 = and i32 %2, -57
%4 = tail call i32 @bcm2835_write(i32 2101300, i32 %3)
%5 = tail call i32 @bcm2835_read(i32 2101304)
%6 = tail call i32 @printk(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = or i32 %5, 64
%8 = tail call i32 @printk(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @bcm2835_write(i32 2101304, i32 %7)
%10 = tail call i32 @irq_enable(i32 57)
ret void
}