#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 */

/* Variables and functions */
int /*<<< orphan*/ gpu_send_control_gp0(int);
void gpu_draw_texmask(int w, int h, int ox, int oy) {
  if ((w & ~7) != 0)
    w = ~((w - 1) >> 3);
  if ((h & ~7) != 0)
    h = ~((h - 1) >> 3);
  ox >>= 3;
  oy >>= 3;
  gpu_send_control_gp0(0xE2000000 | ((w & 0x1F) << 0) | ((h & 0x1F) << 5) |
                       ((ox & 0x1F) << 10) | ((oy & 0x1F) << 15));
}


x86 assembly (clang, -O0):
<gpu_draw_texmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffff8,%eax
cmp    $0x0,%eax
je     1142 <gpu_draw_texmask+0x32>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
sar    $0x3,%eax
xor    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfffffff8,%eax
cmp    $0x0,%eax
je     1160 <gpu_draw_texmask+0x50>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
sar    $0x3,%eax
xor    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
and    $0x1f,%edi
shl    $0x0,%edi
or     $0xe2000000,%edi
mov    -0x8(%rbp),%eax
and    $0x1f,%eax
shl    $0x5,%eax
or     %eax,%edi
mov    -0xc(%rbp),%eax
and    $0x1f,%eax
shl    $0xa,%eax
or     %eax,%edi
mov    -0x10(%rbp),%eax
and    $0x1f,%eax
shl    $0xf,%eax
or     %eax,%edi
call   1030 <gpu_send_control_gp0@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpu_draw_texmask>:
lea    -0x1(%rdi),%eax
shr    $0x3,%eax
cmp    $0x8,%edi
not    %eax
cmovb  %edi,%eax
lea    -0x1(%rsi),%edi
shr    $0x3,%edi
cmp    $0x8,%esi
not    %edi
cmovb  %esi,%edi
and    $0x1f,%eax
and    $0x1f,%edi
shl    $0x5,%edi
shl    $0x7,%edx
and    $0x7c00,%edx
or     %eax,%edx
shl    $0xc,%ecx
and    $0xf8000,%ecx
or     %edx,%ecx
add    %ecx,%edi
add    $0xe2000000,%edi
jmp    1030 <gpu_send_control_gp0@plt>

LLVM IR (-O0):
define void @gpu_draw_texmask(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = and i32 %9, -8
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1
%15 = ashr i32 %14, 3
%16 = xor i32 %15, -1
store i32 %16, i32* %5
br label %17
17: ; preds = %12, %4
%18 = load i32, i32* %6
%19 = and i32 %18, -8
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = ashr i32 %23, 3
%25 = xor i32 %24, -1
store i32 %25, i32* %6
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %7
%28 = ashr i32 %27, 3
store i32 %28, i32* %7
%29 = load i32, i32* %8
%30 = ashr i32 %29, 3
store i32 %30, i32* %8
%31 = load i32, i32* %5
%32 = and i32 %31, 31
%33 = shl i32 %32, 0
%34 = or i32 -503316480, %33
%35 = load i32, i32* %6
%36 = and i32 %35, 31
%37 = shl i32 %36, 5
%38 = or i32 %34, %37
%39 = load i32, i32* %7
%40 = and i32 %39, 31
%41 = shl i32 %40, 10
%42 = or i32 %38, %41
%43 = load i32, i32* %8
%44 = and i32 %43, 31
%45 = shl i32 %44, 15
%46 = or i32 %42, %45
%47 = call i32 @gpu_send_control_gp0(i32 %46)
ret void
}

LLVM IR (-O2):
define void @gpu_draw_texmask(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp ult i32 %0, 8
%6 = add i32 %0, 255
%7 = lshr i32 %6, 3
%8 = xor i32 %7, -1
%9 = select i1 %5, i32 %0, i32 %8
%10 = icmp ult i32 %1, 8
%11 = add i32 %1, 255
%12 = lshr i32 %11, 3
%13 = xor i32 %12, -1
%14 = select i1 %10, i32 %1, i32 %13
%15 = and i32 %9, 31
%16 = shl i32 %14, 5
%17 = and i32 %16, 992
%18 = shl i32 %2, 7
%19 = and i32 %18, 31744
%20 = shl i32 %3, 12
%21 = and i32 %20, 1015808
%22 = or i32 %15, %19
%23 = or i32 %22, %21
%24 = or i32 %23, %17
%25 = or i32 %24, -503316480
%26 = tail call i32 @gpu_send_control_gp0(i32 %25)
ret void
}