#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*/ Process_Mode7_Background(unsigned int, unsigned int);
int /*<<< orphan*/ Recalc_Mode7();
int /*<<< orphan*/ _Render_SM7(unsigned char **, unsigned char **, unsigned int,
                               unsigned int, unsigned int, unsigned int,
                               unsigned int);
int /*<<< orphan*/ clear_scanlines(unsigned int);
void _SCREEN_MODE_7(unsigned char (*main_buf)[2], unsigned char (*sub_buf)[2],
                    unsigned output_surface_offset, unsigned current_line,
                    unsigned lines, unsigned layers1, unsigned layers2) {
  clear_scanlines(lines);
  if ((layers1 | layers2) & 3) {
    Recalc_Mode7();
    Process_Mode7_Background(current_line, lines);
  }
  _Render_SM7(main_buf, sub_buf, current_line, lines, output_surface_offset,
              layers1, layers2);
}


x86 assembly (clang, -O0):
<_SCREEN_MODE_7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <clear_scanlines@plt>
mov    -0x20(%rbp),%eax
or     0x10(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
je     118d <_SCREEN_MODE_7+0x4d>
mov    $0x0,%al
call   1060 <Recalc_Mode7@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <Process_Mode7_Background@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <_Render_SM7@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_SCREEN_MODE_7>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8d,%ebp
mov    %ecx,%r15d
mov    %edx,0x4(%rsp)
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x40(%rsp),%r14d
mov    %r8d,%edi
call   1040 <clear_scanlines@plt>
or     %ebx,%r14d
test   $0x3,%r14b
je     1185 <_SCREEN_MODE_7+0x45>
xor    %eax,%eax
call   1060 <Recalc_Mode7@plt>
mov    %r15d,%edi
mov    %ebp,%esi
call   1050 <Process_Mode7_Background@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    0x4(%rsp),%r8d
mov    %ebx,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_Render_SM7@plt>

LLVM IR (-O0):
define void @_SCREEN_MODE_7([2 x i8]* %0, [2 x i8]* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca [2 x i8]*
%9 = alloca [2 x i8]*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store [2 x i8]* %0, [2 x i8]** %8
store [2 x i8]* %1, [2 x i8]** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%15 = load i32, i32* %12
%16 = call i32 @clear_scanlines(i32 %15)
%17 = load i32, i32* %13
%18 = load i32, i32* %14
%19 = or i32 %17, %18
%20 = and i32 %19, 3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %7
%23 = call i32 (...) @Recalc_Mode7()
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = call i32 @Process_Mode7_Background(i32 %24, i32 %25)
br label %27
27: ; preds = %22, %7
%28 = load [2 x i8]*, [2 x i8]** %8
%29 = bitcast [2 x i8]* %28 to i8**
%30 = load [2 x i8]*, [2 x i8]** %9
%31 = bitcast [2 x i8]* %30 to i8**
%32 = load i32, i32* %11
%33 = load i32, i32* %12
%34 = load i32, i32* %10
%35 = load i32, i32* %13
%36 = load i32, i32* %14
%37 = call i32 @_Render_SM7(i8** %29, i8** %31, i32 %32, i32 %33, i32 %34, i32 %35, i32 %36)
ret void
}

LLVM IR (-O2):
define void @_SCREEN_MODE_7([2 x i8]* %0, [2 x i8]* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = tail call i32 @clear_scanlines(i32 %4)
%9 = or i32 %6, %5
%10 = and i32 %9, 3
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 (...) @Recalc_Mode7()
%14 = tail call i32 @Process_Mode7_Background(i32 %3, i32 %4)
br label %15
15: ; preds = %12, %7
%16 = bitcast [2 x i8]* %0 to i8**
%17 = bitcast [2 x i8]* %1 to i8**
%18 = tail call i32 @_Render_SM7(i8** %16, i8** %17, i32 %3, i32 %4, i32 %2, i32 %5, i32 %6)
ret void
}