#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 /*<<< orphan*/ mirror16bS(unsigned char *, unsigned char *, int, int, int,
                              int, int, int);
void Mirror16bS(unsigned char *tex, uint32_t mask, uint32_t max_width,
                uint32_t real_width, uint32_t height) {
  if (mask == 0)
    return;
  uint32_t mask_width = (1 << mask);
  uint32_t mask_mask = (mask_width - 1) << 1;
  if (mask_width >= max_width)
    return;
  int count = max_width - mask_width;
  if (count <= 0)
    return;
  int line_full = real_width << 1;
  int line = line_full - (count << 1);
  if (line < 0)
    return;
  unsigned char *start = tex + (mask_width << 1);
  mirror16bS(tex, start, mask_width, height, mask_mask, line, line_full, count);
}


x86 assembly (clang, -O0):
<Mirror16bS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1138 <Mirror16bS+0x28>
jmp    11de <Mirror16bS+0xce>
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1162 <Mirror16bS+0x52>
jmp    11de <Mirror16bS+0xce>
mov    -0x10(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     117a <Mirror16bS+0x6a>
jmp    11de <Mirror16bS+0xce>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11a0 <Mirror16bS+0x90>
jmp    11de <Mirror16bS+0xce>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x28(%rbp),%r10d
mov    -0x24(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <mirror16bS@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mirror16bS>:
test   %esi,%esi
je     115d <Mirror16bS+0x4d>
mov    %ecx,%r10d
mov    %edx,%eax
mov    $0x1,%edx
mov    %esi,%ecx
shl    %cl,%edx
cmp    %eax,%edx
jge    115d <Mirror16bS+0x4d>
sub    %edx,%eax
jle    115d <Mirror16bS+0x4d>
mov    %r10d,%r9d
sub    %eax,%r9d
add    %r9d,%r9d
js     115d <Mirror16bS+0x4d>
push   %rax
lea    (%rdx,%rdx,1),%ecx
lea    (%rdx,%rdx,1),%r11d
add    $0xfffffffe,%r11d
add    %r10d,%r10d
movslq %ecx,%rsi
add    %rdi,%rsi
mov    %r8d,%ecx
mov    %r11d,%r8d
push   %rax
push   %r10
call   1030 <mirror16bS@plt>
add    $0x10,%rsp
pop    %rax
ret

LLVM IR (-O0):
define void @Mirror16bS(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %5
br label %62
20: ; preds = %5
%21 = load i32, i32* %7
%22 = shl i32 1, %21
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = sub nsw i32 %23, 1
%25 = shl i32 %24, 1
store i32 %25, i32* %12
%26 = load i32, i32* %11
%27 = load i32, i32* %8
%28 = icmp sge i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %20
br label %62
30: ; preds = %20
%31 = load i32, i32* %8
%32 = load i32, i32* %11
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %13
%34 = load i32, i32* %13
%35 = icmp sle i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
br label %62
37: ; preds = %30
%38 = load i32, i32* %9
%39 = shl i32 %38, 1
store i32 %39, i32* %14
%40 = load i32, i32* %14
%41 = load i32, i32* %13
%42 = shl i32 %41, 1
%43 = sub nsw i32 %40, %42
store i32 %43, i32* %15
%44 = load i32, i32* %15
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %37
br label %62
47: ; preds = %37
%48 = load i8*, i8** %6
%49 = load i32, i32* %11
%50 = shl i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8* %52, i8** %16
%53 = load i8*, i8** %6
%54 = load i8*, i8** %16
%55 = load i32, i32* %11
%56 = load i32, i32* %10
%57 = load i32, i32* %12
%58 = load i32, i32* %15
%59 = load i32, i32* %14
%60 = load i32, i32* %13
%61 = call i32 @mirror16bS(i8* %53, i8* %54, i32 %55, i32 %56, i32 %57, i32 %58, i32 %59, i32 %60)
br label %62
62: ; preds = %47, %46, %36, %29, %19
ret void
}

LLVM IR (-O2):
define void @Mirror16bS(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %1, 0
br i1 %6, label %24, label %7
7: ; preds = %5
%8 = shl nuw i32 1, %1
%9 = shl i32 %8, 1
%10 = add i32 %9, -2
%11 = icmp slt i32 %8, %2
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = sub nsw i32 %2, %8
%14 = icmp slt i32 %13, 1
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = sub i32 %3, %13
%17 = shl i32 %16, 1
%18 = icmp slt i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = shl i32 %3, 1
%21 = sext i32 %9 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = tail call i32 @mirror16bS(i8* %0, i8* %22, i32 %8, i32 %4, i32 %10, i32 %17, i32 %20, i32 %13)
br label %24
24: ; preds = %7, %19, %15, %12, %5
ret void
}