int GPU_SendMail(unsigned int GPU_MSG, unsigned int channel) {
  volatile unsigned int *Status = (unsigned int *)0x2000B898;
  volatile unsigned int *Write = (unsigned int *)0x2000B8A0;
  if ((GPU_MSG & 0xF) != 0) {
    return -1;
  }
  if ((channel > 15) || (channel < 0)) {
    return -1;
  }
  while ((*Status & 0x80000000) != 0)
    ;
  GPU_MSG = GPU_MSG + channel;
  *Write = GPU_MSG;
  return 0;
}


x86 assembly (clang, -O0):
<GPU_SendMail>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x2000b898,%eax
mov    %rax,-0x18(%rbp)
mov    $0x2000b8a0,%eax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
je     1137 <GPU_SendMail+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <GPU_SendMail+0x8e>
cmpl   $0xf,-0xc(%rbp)
ja     114b <GPU_SendMail+0x4b>
cmpl   $0x0,-0xc(%rbp)
jae    1157 <GPU_SendMail+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <GPU_SendMail+0x8e>
jmp    115c <GPU_SendMail+0x5c>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1175 <GPU_SendMail+0x75>
jmp    115c <GPU_SendMail+0x5c>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPU_SendMail>:
mov    $0xffffffff,%eax
test   $0xf,%dil
jne    1125 <GPU_SendMail+0x25>
cmp    $0xf,%esi
ja     1125 <GPU_SendMail+0x25>
cmpl   $0x0,0x2000b898
js     1110 <GPU_SendMail+0x10>
add    %edi,%esi
mov    %esi,0x2000b8a0
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @GPU_SendMail(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* inttoptr (i64 536918168 to i32*), i32** %6
store i32* inttoptr (i64 536918176 to i32*), i32** %7
%8 = load i32, i32* %4
%9 = and i32 %8, 15
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %32
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp ugt i32 %13, 15
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp ult i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15, %12
store i32 -1, i32* %3
br label %32
19: ; preds = %15
br label %20
20: ; preds = %25, %19
%21 = load i32*, i32** %6
%22 = load volatile i32, i32* %21
%23 = and i32 %22, -2147483648
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %20
26: ; preds = %20
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = add i32 %27, %28
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = load i32*, i32** %7
store volatile i32 %30, i32* %31
store i32 0, i32* %3
br label %32
32: ; preds = %26, %18, %11
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @GPU_SendMail(i32 %0, i32 %1) {
%3 = and i32 %0, 15
%4 = icmp ne i32 %3, 0
%5 = icmp ugt i32 %1, 15
%6 = or i1 %4, %5
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = load volatile i32, i32* inttoptr (i64 536918168 to i32*)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %7
10: ; preds = %7
%11 = add i32 %1, %0
store volatile i32 %11, i32* inttoptr (i64 536918176 to i32*)
br label %12
12: ; preds = %2, %10
%13 = phi i32 [ 0, %10 ], [ -1, %2 ]
ret i32 %13
}