#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 uint64_t;
typedef int int32_t;
typedef scalar_t__ int16_t;

/* Variables and functions */
int draw_block4x4_signed_rgtc1_shared(const unsigned char *bitstring,
                                      unsigned int *image_buffer, int offset,
                                      int flags) {
  uint64_t bits = (*(uint64_t *)&bitstring[0]) >> 16;
  int lum0 = (char)bitstring[0];
  int lum1 = (char)bitstring[1];
  if (lum0 == -127 && lum1 == -128)
    return 0;
  if (lum0 == -128)
    lum0 = -127;
  if (lum1 == -128)
    lum1 = -127;
  for (int i = 0; i < 16; i++) {
    int control_code = bits & 0x7;
    int32_t result;
    if (lum0 > lum1)
      switch (control_code) {
      case 0:
        result = lum0;
        break;
      case 1:
        result = lum1;
        break;
      case 2:
        result = (6 * lum0 + lum1) / 7;
        break;
      case 3:
        result = (5 * lum0 + 2 * lum1) / 7;
        break;
      case 4:
        result = (4 * lum0 + 3 * lum1) / 7;
        break;
      case 5:
        result = (3 * lum0 + 4 * lum1) / 7;
        break;
      case 6:
        result = (2 * lum0 + 5 * lum1) / 7;
        break;
      case 7:
        result = (lum0 + 6 * lum1) / 7;
        break;
      }
    else
      switch (control_code) {
      case 0:
        result = lum0;
        break;
      case 1:
        result = lum1;
        break;
      case 2:
        result = (4 * lum0 + lum1) / 5;
        break;
      case 3:
        result = (3 * lum0 + 2 * lum1) / 5;
        break;
      case 4:
        result = (2 * lum0 + 3 * lum1) / 5;
        break;
      case 5:
        result = (lum0 + 4 * lum1) / 5;
        break;
      case 6:
        result = -127;
        break;
      case 7:
        result = 127;
        break;
      }
    *((int16_t *)&image_buffer[i] + offset) =
        (int16_t)((result + 127) * 65535 / 254 - 32768);
    bits >>= 3;
  }
  return 1;
}


x86 assembly (clang, -O0):
<draw_block4x4_signed_rgtc1_shared>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x10,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffff81,-0x28(%rbp)
jne    1153 <draw_block4x4_signed_rgtc1_shared+0x53>
cmpl   $0xffffff80,-0x2c(%rbp)
jne    1153 <draw_block4x4_signed_rgtc1_shared+0x53>
movl   $0x0,-0x4(%rbp)
jmp    1386 <draw_block4x4_signed_rgtc1_shared+0x286>
cmpl   $0xffffff80,-0x28(%rbp)
jne    1164 <draw_block4x4_signed_rgtc1_shared+0x64>
movl   $0xffffff81,-0x28(%rbp)
cmpl   $0xffffff80,-0x2c(%rbp)
jne    1175 <draw_block4x4_signed_rgtc1_shared+0x75>
movl   $0xffffff81,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x10,-0x30(%rbp)
jge    137f <draw_block4x4_signed_rgtc1_shared+0x27f>
mov    -0x24(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    1276 <draw_block4x4_signed_rgtc1_shared+0x176>
mov    -0x34(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x7,%rax
ja     1271 <draw_block4x4_signed_rgtc1_shared+0x171>
mov    -0x40(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
imul   $0x6,-0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
imul   $0x5,-0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
mov    -0x28(%rbp),%eax
shl    $0x2,%eax
imul   $0x3,-0x2c(%rbp),%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
imul   $0x3,-0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
imul   $0x5,-0x2c(%rbp),%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1271 <draw_block4x4_signed_rgtc1_shared+0x171>
mov    -0x28(%rbp),%eax
imul   $0x6,-0x2c(%rbp),%ecx
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1335 <draw_block4x4_signed_rgtc1_shared+0x235>
mov    -0x34(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x7,%rax
ja     1330 <draw_block4x4_signed_rgtc1_shared+0x230>
mov    -0x48(%rbp),%rax
lea    0xd6e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
mov    -0x28(%rbp),%eax
shl    $0x2,%eax
add    -0x2c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
imul   $0x3,-0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
imul   $0x3,-0x2c(%rbp),%ecx
add    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
mov    -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
movl   $0xffffff81,-0x38(%rbp)
jmp    1330 <draw_block4x4_signed_rgtc1_shared+0x230>
movl   $0x7f,-0x38(%rbp)
jmp    1335 <draw_block4x4_signed_rgtc1_shared+0x235>
mov    -0x38(%rbp),%eax
add    $0x7f,%eax
imul   $0xffff,%eax,%eax
mov    $0xfe,%ecx
cltd
idiv   %ecx
sub    $0x8000,%eax
movslq %eax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117c <draw_block4x4_signed_rgtc1_shared+0x7c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_block4x4_signed_rgtc1_shared>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%r11d
mov    %rsi,%r9
mov    %rdi,%r14
mov    (%rdi),%cl
mov    0x1(%rdi),%dl
cmp    $0x81,%cl
jne    1128 <draw_block4x4_signed_rgtc1_shared+0x28>
xor    %eax,%eax
cmp    $0x80,%dl
je     1396 <draw_block4x4_signed_rgtc1_shared+0x296>
cmp    $0x80,%cl
movzbl %cl,%r8d
mov    $0x81,%esi
cmove  %esi,%r8d
cmp    $0x80,%dl
movsbl %r8b,%ecx
movzbl %dl,%eax
cmove  %esi,%eax
movsbl %al,%ebx
lea    (%rcx,%rbx,4),%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%rsi
mov    %rsi,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rsi
sar    %esi
add    %edx,%esi
mov    %rsi,-0x20(%rsp)
lea    (%rbx,%rbx,2),%esi
lea    (%rsi,%rcx,2),%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rdi
sar    %edi
add    %edx,%edi
mov    %rdi,-0x8(%rsp)
lea    (%rcx,%rcx,2),%edx
lea    (%rdx,%rbx,2),%edi
movslq %edi,%rdi
imul   $0x66666667,%rdi,%rdi
mov    %rdi,%rbp
shr    $0x3f,%rbp
shr    $0x20,%rdi
sar    %edi
add    %ebp,%edi
mov    %rdi,-0x10(%rsp)
lea    (%rbx,%rcx,4),%edi
movslq %edi,%rdi
imul   $0x66666667,%rdi,%rdi
mov    %rdi,%rbp
shr    $0x3f,%rbp
shr    $0x20,%rdi
sar    %edi
add    %ebp,%edi
mov    %rdi,-0x18(%rsp)
lea    (%rcx,%rsi,2),%edi
imul   $0x4925,%edi,%edi
mov    %edi,%ebp
shr    $0x1f,%ebp
sar    $0x11,%edi
add    %ebp,%edi
mov    %edi,-0x34(%rsp)
lea    (%rbx,%rbx,4),%edi
lea    (%rdi,%rcx,2),%edi
movslq %edi,%rbp
imul   $0xffffffff92492493,%rbp,%rdi
shr    $0x20,%rdi
add    %edi,%ebp
mov    %ebp,%edi
shr    $0x1f,%edi
sar    $0x2,%ebp
add    %edi,%ebp
mov    %rbp,-0x28(%rsp)
lea    (%rdx,%rbx,4),%edi
movslq %edi,%r13
imul   $0xffffffff92492493,%r13,%rdi
shr    $0x20,%rdi
add    %edi,%r13d
mov    %r13d,%edi
shr    $0x1f,%edi
sar    $0x2,%r13d
add    %edi,%r13d
lea    (%rsi,%rcx,4),%esi
movslq %esi,%rbp
imul   $0xffffffff92492493,%rbp,%rsi
shr    $0x20,%rsi
add    %esi,%ebp
mov    %ebp,%esi
shr    $0x1f,%esi
sar    $0x2,%ebp
add    %esi,%ebp
lea    (%rcx,%rcx,4),%esi
lea    (%rsi,%rbx,2),%esi
movslq %esi,%r10
imul   $0xffffffff92492493,%r10,%rsi
shr    $0x20,%rsi
add    %esi,%r10d
mov    %r10d,%esi
shr    $0x1f,%esi
sar    $0x2,%r10d
add    %esi,%r10d
mov    %rbx,-0x30(%rsp)
lea    (%rbx,%rdx,2),%edx
imul   $0x4925,%edx,%r12d
mov    %r12d,%edx
shr    $0x1f,%edx
sar    $0x11,%r12d
add    %edx,%r12d
movslq %r11d,%rdx
lea    (%r9,%rdx,8),%rsi
movswl 0x2(%r14),%edi
xor    %r15d,%r15d
lea    0xd7e(%rip),%r11
lea    0xd57(%rip),%r14
jmp    12fd <draw_block4x4_signed_rgtc1_shared+0x1fd>
mov    -0x30(%rsp),%rdx
mov    %edx,%ebx
shl    $0x10,%ebx
sub    %edx,%ebx
mov    %ebx,%edx
add    $0x7eff81,%edx
movslq %edx,%rdx
imul   $0xffffffff81020409,%rdx,%rdx
shr    $0x20,%rdx
add    %ebx,%edx
add    $0x7eff81,%edx
mov    %edx,%ebx
sar    $0x7,%ebx
shr    $0x1f,%edx
add    %ebx,%edx
add    $0xffff8000,%edx
movslq %edx,%rdx
mov    %rdx,(%rsi,%r15,4)
sar    $0x3,%edi
add    $0x1,%r15
cmp    $0x10,%r15
je     1391 <draw_block4x4_signed_rgtc1_shared+0x291>
mov    %edi,%edx
and    $0x7,%edx
mov    %edx,%edx
cmp    %al,%r8b
jle    1320 <draw_block4x4_signed_rgtc1_shared+0x220>
movslq (%r11,%rdx,4),%r9
add    %r11,%r9
mov    %ecx,%edx
jmp    *%r9
mov    %r12d,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
nopw   0x0(%rax,%rax,1)
movslq (%r14,%rdx,4),%rbx
add    %r14,%rbx
mov    %ecx,%edx
jmp    *%rbx
mov    -0x18(%rsp),%rdx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    %r10d,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    %ebp,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    -0x10(%rsp),%rdx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    -0x8(%rsp),%rdx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    %r13d,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    -0x28(%rsp),%rdx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    -0x34(%rsp),%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    -0x20(%rsp),%rdx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    $0xffffff81,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    $0x7f,%edx
jmp    12b0 <draw_block4x4_signed_rgtc1_shared+0x1b0>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @draw_block4x4_signed_rgtc1_shared(i8* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32
%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
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = bitcast i8* %17 to i32*
%19 = load i32, i32* %18
%20 = ashr i32 %19, 16
store i32 %20, i32* %10
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %11
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
store i32 %28, i32* %12
%29 = load i32, i32* %11
%30 = icmp eq i32 %29, -127
br i1 %30, label %31, label %35
31: ; preds = %4
%32 = load i32, i32* %12
%33 = icmp eq i32 %32, -128
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 0, i32* %5
br label %156
35: ; preds = %31, %4
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, -128
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 -127, i32* %11
br label %39
39: ; preds = %38, %35
%40 = load i32, i32* %12
%41 = icmp eq i32 %40, -128
br i1 %41, label %42, label %43
42: ; preds = %39
store i32 -127, i32* %12
br label %43
43: ; preds = %42, %39
store i32 0, i32* %13
br label %44
44: ; preds = %152, %43
%45 = load i32, i32* %13
%46 = icmp slt i32 %45, 16
br i1 %46, label %47, label %155
47: ; preds = %44
%48 = load i32, i32* %10
%49 = and i32 %48, 7
store i32 %49, i32* %14
%50 = load i32, i32* %11
%51 = load i32, i32* %12
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %100
53: ; preds = %47
%54 = load i32, i32* %14
switch i32 %54, label %99 [
i32 0, label %55
i32 1, label %57
i32 2, label %59
i32 3, label %65
i32 4, label %72
i32 5, label %79
i32 6, label %86
i32 7, label %93
]
55: ; preds = %53
%56 = load i32, i32* %11
store i32 %56, i32* %15
br label %99
57: ; preds = %53
%58 = load i32, i32* %12
store i32 %58, i32* %15
br label %99
59: ; preds = %53
%60 = load i32, i32* %11
%61 = mul nsw i32 6, %60
%62 = load i32, i32* %12
%63 = add nsw i32 %61, %62
%64 = sdiv i32 %63, 7
store i32 %64, i32* %15
br label %99
65: ; preds = %53
%66 = load i32, i32* %11
%67 = mul nsw i32 5, %66
%68 = load i32, i32* %12
%69 = mul nsw i32 2, %68
%70 = add nsw i32 %67, %69
%71 = sdiv i32 %70, 7
store i32 %71, i32* %15
br label %99
72: ; preds = %53
%73 = load i32, i32* %11
%74 = mul nsw i32 4, %73
%75 = load i32, i32* %12
%76 = mul nsw i32 3, %75
%77 = add nsw i32 %74, %76
%78 = sdiv i32 %77, 7
store i32 %78, i32* %15
br label %99
79: ; preds = %53
%80 = load i32, i32* %11
%81 = mul nsw i32 3, %80
%82 = load i32, i32* %12
%83 = mul nsw i32 4, %82
%84 = add nsw i32 %81, %83
%85 = sdiv i32 %84, 7
store i32 %85, i32* %15
br label %99
86: ; preds = %53
%87 = load i32, i32* %11
%88 = mul nsw i32 2, %87
%89 = load i32, i32* %12
%90 = mul nsw i32 5, %89
%91 = add nsw i32 %88, %90
%92 = sdiv i32 %91, 7
store i32 %92, i32* %15
br label %99
93: ; preds = %53
%94 = load i32, i32* %11
%95 = load i32, i32* %12
%96 = mul nsw i32 6, %95
%97 = add nsw i32 %94, %96
%98 = sdiv i32 %97, 7
store i32 %98, i32* %15
br label %99
99: ; preds = %53, %93, %86, %79, %72, %65, %59, %57, %55
br label %135
100: ; preds = %47
%101 = load i32, i32* %14
switch i32 %101, label %134 [
i32 0, label %102
i32 1, label %104
i32 2, label %106
i32 3, label %112
i32 4, label %119
i32 5, label %126
i32 6, label %132
i32 7, label %133
]
102: ; preds = %100
%103 = load i32, i32* %11
store i32 %103, i32* %15
br label %134
104: ; preds = %100
%105 = load i32, i32* %12
store i32 %105, i32* %15
br label %134
106: ; preds = %100
%107 = load i32, i32* %11
%108 = mul nsw i32 4, %107
%109 = load i32, i32* %12
%110 = add nsw i32 %108, %109
%111 = sdiv i32 %110, 5
store i32 %111, i32* %15
br label %134
112: ; preds = %100
%113 = load i32, i32* %11
%114 = mul nsw i32 3, %113
%115 = load i32, i32* %12
%116 = mul nsw i32 2, %115
%117 = add nsw i32 %114, %116
%118 = sdiv i32 %117, 5
store i32 %118, i32* %15
br label %134
119: ; preds = %100
%120 = load i32, i32* %11
%121 = mul nsw i32 2, %120
%122 = load i32, i32* %12
%123 = mul nsw i32 3, %122
%124 = add nsw i32 %121, %123
%125 = sdiv i32 %124, 5
store i32 %125, i32* %15
br label %134
126: ; preds = %100
%127 = load i32, i32* %11
%128 = load i32, i32* %12
%129 = mul nsw i32 4, %128
%130 = add nsw i32 %127, %129
%131 = sdiv i32 %130, 5
store i32 %131, i32* %15
br label %134
132: ; preds = %100
store i32 -127, i32* %15
br label %134
133: ; preds = %100
store i32 127, i32* %15
br label %134
134: ; preds = %100, %133, %132, %126, %119, %112, %106, %104, %102
br label %135
135: ; preds = %134, %99
%136 = load i32, i32* %15
%137 = add nsw i32 %136, 127
%138 = mul nsw i32 %137, 65535
%139 = sdiv i32 %138, 254
%140 = sub nsw i32 %139, 32768
%141 = sext i32 %140 to i64
%142 = load i32*, i32** %7
%143 = load i32, i32* %13
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i32, i32* %142, i64 %144
%146 = bitcast i32* %145 to i64*
%147 = load i32, i32* %8
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i64, i64* %146, i64 %148
store i64 %141, i64* %149
%150 = load i32, i32* %10
%151 = ashr i32 %150, 3
store i32 %151, i32* %10
br label %152
152: ; preds = %135
%153 = load i32, i32* %13
%154 = add nsw i32 %153, 1
store i32 %154, i32* %13
br label %44
155: ; preds = %44
store i32 1, i32* %5
br label %156
156: ; preds = %155, %34
%157 = load i32, i32* %5
ret i32 %157
}

LLVM IR (-O2):
define i32 @draw_block4x4_signed_rgtc1_shared(i8* nocapture %0, i32* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = load i8, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %5, -127
%9 = icmp eq i8 %7, -128
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %91, label %11
11: ; preds = %4
%12 = bitcast i8* %0 to i32*
%13 = load i32, i32* %12
%14 = ashr i32 %13, 16
%15 = icmp eq i8 %5, -128
%16 = select i1 %15, i8 -127, i8 %5
%17 = sext i8 %16 to i32
%18 = select i1 %9, i8 -127, i8 %7
%19 = sext i8 %18 to i32
%20 = icmp sgt i8 %16, %18
%21 = shl nsw i32 %19, 2
%22 = add nsw i32 %21, %17
%23 = sdiv i32 %22, 5
%24 = shl nsw i32 %17, 1
%25 = mul nsw i32 %19, 3
%26 = add nsw i32 %25, %24
%27 = sdiv i32 %26, 5
%28 = mul nsw i32 %17, 3
%29 = shl nsw i32 %19, 1
%30 = add nsw i32 %29, %28
%31 = sdiv i32 %30, 5
%32 = shl nsw i32 %17, 2
%33 = add nsw i32 %32, %19
%34 = sdiv i32 %33, 5
%35 = mul nsw i32 %19, 6
%36 = add nsw i32 %35, %17
%37 = trunc i32 %36 to i16
%38 = sdiv i16 %37, 7
%39 = sext i16 %38 to i32
%40 = mul nsw i32 %19, 5
%41 = add nsw i32 %40, %24
%42 = sdiv i32 %41, 7
%43 = add nsw i32 %21, %28
%44 = sdiv i32 %43, 7
%45 = add nsw i32 %25, %32
%46 = sdiv i32 %45, 7
%47 = mul nsw i32 %17, 5
%48 = add nsw i32 %29, %47
%49 = sdiv i32 %48, 7
%50 = mul nsw i32 %17, 6
%51 = add nsw i32 %50, %19
%52 = trunc i32 %51 to i16
%53 = sdiv i16 %52, 7
%54 = sext i16 %53 to i32
%55 = sext i32 %2 to i64
br label %56
56: ; preds = %11, %78
%57 = phi i64 [ 0, %11 ], [ %89, %78 ]
%58 = phi i32 [ %14, %11 ], [ %88, %78 ]
%59 = and i32 %58, 7
br i1 %20, label %60, label %68
60: ; preds = %56
switch i32 %59, label %76 [
i32 0, label %78
i32 1, label %61
i32 2, label %62
i32 3, label %63
i32 4, label %64
i32 5, label %65
i32 6, label %66
i32 7, label %67
]
61: ; preds = %60
br label %78
62: ; preds = %60
br label %78
63: ; preds = %60
br label %78
64: ; preds = %60
br label %78
65: ; preds = %60
br label %78
66: ; preds = %60
br label %78
67: ; preds = %60
br label %78
68: ; preds = %56
switch i32 %59, label %77 [
i32 0, label %78
i32 1, label %69
i32 2, label %70
i32 3, label %71
i32 4, label %72
i32 5, label %73
i32 6, label %74
i32 7, label %75
]
69: ; preds = %68
br label %78
70: ; preds = %68
br label %78
71: ; preds = %68
br label %78
72: ; preds = %68
br label %78
73: ; preds = %68
br label %78
74: ; preds = %68
br label %78
75: ; preds = %68
br label %78
76: ; preds = %60
unreachable
77: ; preds = %68
unreachable
78: ; preds = %68, %60, %69, %70, %71, %72, %73, %74, %75, %61, %62, %63, %64, %65, %66, %67
%79 = phi i32 [ %39, %67 ], [ %42, %66 ], [ %44, %65 ], [ %46, %64 ], [ %49, %63 ], [ %54, %62 ], [ %19, %61 ], [ 127, %75 ], [ -127, %74 ], [ %23, %73 ], [ %27, %72 ], [ %31, %71 ], [ %34, %70 ], [ %19, %69 ], [ %17, %60 ], [ %17, %68 ]
%80 = mul i32 %79, 65535
%81 = add i32 %80, 8322945
%82 = sdiv i32 %81, 254
%83 = add nsw i32 %82, -32768
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %1, i64 %57
%86 = bitcast i32* %85 to i64*
%87 = getelementptr inbounds i64, i64* %86, i64 %55
store i64 %84, i64* %87
%88 = ashr i32 %58, 3
%89 = add nuw nsw i64 %57, 1
%90 = icmp eq i64 %89, 16
br i1 %90, label %91, label %56
91: ; preds = %78, %4
%92 = phi i32 [ 0, %4 ], [ 1, %78 ]
ret i32 %92
}