#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 /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ cpu_irq_restore(uintptr_t);
int /*<<< orphan*/ cpu_irq_save(uintptr_t *);
int /*<<< orphan*/ pause();
void send_ipi(uint8_t *baseapic, uint32_t high, uint32_t low) {
  uintptr_t flags;
  cpu_irq_save(&flags);
  while (*((uint32_t *)&baseapic[0x300]) & (1 << 12)) {
    pause();
  }
  *((uint32_t *)&baseapic[0x310]) = high;
  *((uint32_t *)&baseapic[0x300]) = low;
  cpu_irq_restore(flags);
}


x86 assembly (clang, -O0):
<send_ipi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <cpu_irq_save@plt>
mov    -0x8(%rbp),%rax
mov    0xc00(%rax),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     116f <send_ipi+0x3f>
mov    $0x0,%al
call   1050 <pause@plt>
jmp    114b <send_ipi+0x1b>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc40(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc00(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <cpu_irq_restore@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_ipi>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1040 <cpu_irq_save@plt>
testb  $0x10,0xc01(%rbx)
je     1170 <send_ipi+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <pause@plt>
testb  $0x10,0xc01(%rbx)
jne    1160 <send_ipi+0x30>
mov    %ebp,0xc40(%rbx)
mov    %r14d,0xc00(%rbx)
mov    0x8(%rsp),%rdi
call   1030 <cpu_irq_restore@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @send_ipi(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i32 @cpu_irq_save(i64* %7)
br label %9
9: ; preds = %15, %3
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 768
%12 = load i32, i32* %11
%13 = and i32 %12, 4096
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (...) @pause()
br label %9
17: ; preds = %9
%18 = load i32, i32* %5
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 784
store i32 %18, i32* %20
%21 = load i32, i32* %6
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 768
store i32 %21, i32* %23
%24 = load i64, i64* %7
%25 = call i32 @cpu_irq_restore(i64 %24)
ret void
}

LLVM IR (-O2):
define void @send_ipi(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @cpu_irq_save(i64* %4)
%7 = getelementptr inbounds i32, i32* %0, i64 768
%8 = load i32, i32* %7
%9 = and i32 %8, 4096
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %3, %11
%12 = call i32 (...) @pause()
%13 = load i32, i32* %7
%14 = and i32 %13, 4096
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %11
16: ; preds = %11, %3
%17 = getelementptr inbounds i32, i32* %0, i64 784
store i32 %1, i32* %17
store i32 %2, i32* %7
%18 = load i64, i64* %4
%19 = call i32 @cpu_irq_restore(i64 %18)
ret void
}