#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 /*<<< orphan*/ mask;

/* Variables and functions */
int FS460_decode_bitmap_from_alpha_mask(unsigned char *, long *,
                                        unsigned short *, int);
int FS460_encode_alpha_mask_from_bitmap(unsigned short *, int *,
                                        unsigned char *, int);
int FS460_set_alpha_mask(unsigned short *, int);
scalar_t__ OS_alloc(int);
int /*<<< orphan*/ OS_free(unsigned char *);
scalar_t__ sqrt(int);
void test_alpha_encode_decode(void) {
  unsigned char *p_alpha, *p_got;
  unsigned short mask[6144];
  int mask_size;
  long alpha_value_size;
  int x, y;
  int off;
  int err;
  p_alpha = (unsigned char *)OS_alloc(720 * 288);
  if (p_alpha) {
    for (x = 0; x < (720 * 288); x++)
      p_alpha[x] = 0;
    for (y = 40; y < 80; y++)
      for (x = 40; x < 160; x++)
        p_alpha[720 * y + x] = 0x20;
    for (y = 20; y < 100; y++)
      for (x = 200 - (y * 2 - 40); x < 200 + (y * 2 - 40); x++)
        p_alpha[720 * y + x] = 0x40;
    for (y = 100; y < 180; y++)
      for (x = 200 - (360 - y * 2); x < 200 + (360 - y * 2); x++)
        p_alpha[720 * y + x] = 0x40;
    for (y = 120; y < 220; y++) {
      off = (int)sqrt(10000 - (340 - 2 * y) * (340 - 2 * y));
      for (x = 400 - off; x < 400 + off; x++)
        p_alpha[720 * y + x] = 0x60;
    }
    for (y = 150; y < 170; y++)
      for (x = 40; x < 680; x++)
        p_alpha[720 * y + x] = 0x7F;
    mask_size = sizeof(mask);
    err = FS460_encode_alpha_mask_from_bitmap(mask, &mask_size, p_alpha,
                                              720 * 288);
    if (err) {
      {}
    } else {
      err = FS460_set_alpha_mask(mask, mask_size);
      p_got = (unsigned char *)OS_alloc(720 * 288);
      if (p_got) {
        alpha_value_size = 720 * 288;
        err = FS460_decode_bitmap_from_alpha_mask(p_got, &alpha_value_size,
                                                  mask, sizeof(mask));
        if (err) {
          {}
        } else {
          if (alpha_value_size != 720 * 288) {
          }
          for (x = 0; x < (720 * 288); x++) {
            if (p_got[x] != p_alpha[x])
              break;
          }
          if (x < (720 * 288)) {
            {} {} {}
          } else {
          }
        }
        OS_free(p_got);
      }
    }
    OS_free(p_alpha);
  }
}


x86 assembly (clang, -O0):
<test_alpha_encode_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3030,%rsp
mov    $0x32a00,%edi
call   1060 <OS_alloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     160b <test_alpha_encode_decode+0x4ab>
movl   $0x0,-0x3024(%rbp)
cmpl   $0x32a00,-0x3024(%rbp)
jge    11c1 <test_alpha_encode_decode+0x61>
mov    -0x8(%rbp),%rax
movslq -0x3024(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    118e <test_alpha_encode_decode+0x2e>
movl   $0x28,-0x3028(%rbp)
cmpl   $0x50,-0x3028(%rbp)
jge    123a <test_alpha_encode_decode+0xda>
movl   $0x28,-0x3024(%rbp)
cmpl   $0xa0,-0x3024(%rbp)
jge    1221 <test_alpha_encode_decode+0xc1>
mov    -0x8(%rbp),%rax
imul   $0x2d0,-0x3028(%rbp),%ecx
add    -0x3024(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    11e2 <test_alpha_encode_decode+0x82>
jmp    1226 <test_alpha_encode_decode+0xc6>
mov    -0x3028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3028(%rbp)
jmp    11cb <test_alpha_encode_decode+0x6b>
movl   $0x14,-0x3028(%rbp)
cmpl   $0x64,-0x3028(%rbp)
jge    12d2 <test_alpha_encode_decode+0x172>
mov    -0x3028(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x28,%ecx
mov    $0xc8,%eax
sub    %ecx,%eax
mov    %eax,-0x3024(%rbp)
mov    -0x3024(%rbp),%eax
mov    -0x3028(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x28,%ecx
add    $0xc8,%ecx
cmp    %ecx,%eax
jge    12b9 <test_alpha_encode_decode+0x159>
mov    -0x8(%rbp),%rax
imul   $0x2d0,-0x3028(%rbp),%ecx
add    -0x3024(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x40,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    126a <test_alpha_encode_decode+0x10a>
jmp    12be <test_alpha_encode_decode+0x15e>
mov    -0x3028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3028(%rbp)
jmp    1244 <test_alpha_encode_decode+0xe4>
movl   $0x64,-0x3028(%rbp)
cmpl   $0xb4,-0x3028(%rbp)
jge    1375 <test_alpha_encode_decode+0x215>
mov    -0x3028(%rbp),%eax
shl    $0x1,%eax
mov    $0x168,%ecx
sub    %eax,%ecx
mov    $0xc8,%eax
sub    %ecx,%eax
mov    %eax,-0x3024(%rbp)
mov    -0x3024(%rbp),%eax
mov    -0x3028(%rbp),%edx
shl    $0x1,%edx
mov    $0x168,%ecx
sub    %edx,%ecx
add    $0xc8,%ecx
cmp    %ecx,%eax
jge    135c <test_alpha_encode_decode+0x1fc>
mov    -0x8(%rbp),%rax
imul   $0x2d0,-0x3028(%rbp),%ecx
add    -0x3024(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x40,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    1309 <test_alpha_encode_decode+0x1a9>
jmp    1361 <test_alpha_encode_decode+0x201>
mov    -0x3028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3028(%rbp)
jmp    12dc <test_alpha_encode_decode+0x17c>
movl   $0x78,-0x3028(%rbp)
cmpl   $0xdc,-0x3028(%rbp)
jge    1437 <test_alpha_encode_decode+0x2d7>
mov    -0x3028(%rbp),%ecx
shl    $0x1,%ecx
mov    $0x154,%eax
sub    %ecx,%eax
mov    -0x3028(%rbp),%edx
shl    $0x1,%edx
mov    $0x154,%ecx
sub    %edx,%ecx
imul   %ecx,%eax
mov    $0x2710,%edi
sub    %eax,%edi
call   1070 <sqrt@plt>
mov    %eax,-0x302c(%rbp)
mov    $0x190,%eax
sub    -0x302c(%rbp),%eax
mov    %eax,-0x3024(%rbp)
mov    -0x3024(%rbp),%eax
mov    -0x302c(%rbp),%ecx
add    $0x190,%ecx
cmp    %ecx,%eax
jge    141e <test_alpha_encode_decode+0x2be>
mov    -0x8(%rbp),%rax
imul   $0x2d0,-0x3028(%rbp),%ecx
add    -0x3024(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x60,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    13d5 <test_alpha_encode_decode+0x275>
jmp    1423 <test_alpha_encode_decode+0x2c3>
mov    -0x3028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3028(%rbp)
jmp    137f <test_alpha_encode_decode+0x21f>
movl   $0x96,-0x3028(%rbp)
cmpl   $0xaa,-0x3028(%rbp)
jge    14b3 <test_alpha_encode_decode+0x353>
movl   $0x28,-0x3024(%rbp)
cmpl   $0x2a8,-0x3024(%rbp)
jge    149a <test_alpha_encode_decode+0x33a>
mov    -0x8(%rbp),%rax
imul   $0x2d0,-0x3028(%rbp),%ecx
add    -0x3024(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x7f,(%rax,%rcx,1)
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    145b <test_alpha_encode_decode+0x2fb>
jmp    149f <test_alpha_encode_decode+0x33f>
mov    -0x3028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3028(%rbp)
jmp    1441 <test_alpha_encode_decode+0x2e1>
movl   $0x3000,-0x3014(%rbp)
lea    -0x3010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    -0x3014(%rbp),%rsi
mov    $0x32a00,%ecx
call   1030 <FS460_encode_alpha_mask_from_bitmap@plt>
mov    %eax,-0x3030(%rbp)
cmpl   $0x0,-0x3030(%rbp)
je     14f1 <test_alpha_encode_decode+0x391>
jmp    1602 <test_alpha_encode_decode+0x4a2>
lea    -0x3010(%rbp),%rdi
mov    -0x3014(%rbp),%esi
call   1080 <FS460_set_alpha_mask@plt>
mov    %eax,-0x3030(%rbp)
mov    $0x32a00,%edi
call   1060 <OS_alloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     15fd <test_alpha_encode_decode+0x49d>
movq   $0x32a00,-0x3020(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x3010(%rbp),%rdx
lea    -0x3020(%rbp),%rsi
mov    $0x3000,%ecx
call   1040 <FS460_decode_bitmap_from_alpha_mask@plt>
mov    %eax,-0x3030(%rbp)
cmpl   $0x0,-0x3030(%rbp)
je     1561 <test_alpha_encode_decode+0x401>
jmp    15f4 <test_alpha_encode_decode+0x494>
cmpq   $0x32a00,-0x3020(%rbp)
je     1577 <test_alpha_encode_decode+0x417>
jmp    1577 <test_alpha_encode_decode+0x417>
movl   $0x0,-0x3024(%rbp)
cmpl   $0x32a00,-0x3024(%rbp)
jge    15d5 <test_alpha_encode_decode+0x475>
mov    -0x10(%rbp),%rax
movslq -0x3024(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0x3024(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     15bc <test_alpha_encode_decode+0x45c>
jmp    15d5 <test_alpha_encode_decode+0x475>
jmp    15c1 <test_alpha_encode_decode+0x461>
mov    -0x3024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3024(%rbp)
jmp    1581 <test_alpha_encode_decode+0x421>
cmpl   $0x32a00,-0x3024(%rbp)
jge    15ea <test_alpha_encode_decode+0x48a>
jmp    15ef <test_alpha_encode_decode+0x48f>
jmp    15ef <test_alpha_encode_decode+0x48f>
jmp    15f4 <test_alpha_encode_decode+0x494>
mov    -0x10(%rbp),%rdi
call   1050 <OS_free@plt>
jmp    1602 <test_alpha_encode_decode+0x4a2>
mov    -0x8(%rbp),%rdi
call   1050 <OS_free@plt>
add    $0x3030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_alpha_encode_decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3018,%rsp
mov    $0x32a00,%edi
call   1070 <OS_alloc@plt>
test   %rax,%rax
je     1689 <test_alpha_encode_decode+0x519>
mov    %rax,%r14
mov    $0x32a00,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x70a8,%eax
movabs $0x2020202020202020,%rcx
20 20 20
movaps 0xe44(%rip),%xmm0
nopl   0x0(%rax)
mov    %rcx,0x70(%r14,%rax,1)
movups %xmm0,0x60(%r14,%rax,1)
movups %xmm0,0x50(%r14,%rax,1)
movups %xmm0,0x40(%r14,%rax,1)
movups %xmm0,0x30(%r14,%rax,1)
movups %xmm0,0x20(%r14,%rax,1)
movups %xmm0,0x10(%r14,%rax,1)
movups %xmm0,(%r14,%rax,1)
movups %xmm0,0x2d0(%r14,%rax,1)
movups %xmm0,0x2e0(%r14,%rax,1)
movups %xmm0,0x2f0(%r14,%rax,1)
movups %xmm0,0x300(%r14,%rax,1)
movups %xmm0,0x310(%r14,%rax,1)
movups %xmm0,0x320(%r14,%rax,1)
movups %xmm0,0x330(%r14,%rax,1)
mov    %rcx,0x340(%r14,%rax,1)
movups %xmm0,0x5a0(%r14,%rax,1)
movups %xmm0,0x5b0(%r14,%rax,1)
movups %xmm0,0x5c0(%r14,%rax,1)
movups %xmm0,0x5d0(%r14,%rax,1)
movups %xmm0,0x5e0(%r14,%rax,1)
movups %xmm0,0x5f0(%r14,%rax,1)
movups %xmm0,0x600(%r14,%rax,1)
mov    %rcx,0x610(%r14,%rax,1)
mov    %rcx,0x8e0(%r14,%rax,1)
movups %xmm0,0x8d0(%r14,%rax,1)
movups %xmm0,0x8c0(%r14,%rax,1)
movups %xmm0,0x8b0(%r14,%rax,1)
movups %xmm0,0x8a0(%r14,%rax,1)
movups %xmm0,0x890(%r14,%rax,1)
movups %xmm0,0x880(%r14,%rax,1)
movups %xmm0,0x870(%r14,%rax,1)
movups %xmm0,0xb40(%r14,%rax,1)
movups %xmm0,0xb50(%r14,%rax,1)
movups %xmm0,0xb60(%r14,%rax,1)
movups %xmm0,0xb70(%r14,%rax,1)
movups %xmm0,0xb80(%r14,%rax,1)
movups %xmm0,0xb90(%r14,%rax,1)
movups %xmm0,0xba0(%r14,%rax,1)
mov    %rcx,0xbb0(%r14,%rax,1)
add    $0xe10,%rax
cmp    $0xe128,%rax
jne    11c0 <test_alpha_encode_decode+0x50>
mov    $0x1c84,%ebx
mov    $0xc8,%r15d
mov    $0xfffffffc,%r12d
mov    $0xc8,%ebp
mov    $0xfffffffc,%r13d
jmp    135b <test_alpha_encode_decode+0x1eb>
nopw   0x0(%rax,%rax,1)
add    $0x4,%r13
add    $0x167,%rbx
add    $0x2,%ebp
add    $0xfffffffe,%r15d
cmp    $0x8cb4,%rbx
je     137a <test_alpha_encode_decode+0x20a>
cmp    %ebp,%r15d
jae    1340 <test_alpha_encode_decode+0x1d0>
mov    %r13d,%edx
and    $0xfffffffc,%edx
add    $0x4,%rdx
lea    (%r14,%rbx,2),%rdi
mov    $0x40,%esi
call   1050 <memset@plt>
jmp    1340 <test_alpha_encode_decode+0x1d0>
lea    0x11968(%r14),%r15
mov    $0x140,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
lea    -0x4(%rbx),%rdx
lea    0x2d2(%r15),%rdi
mov    $0x40,%esi
call   1050 <memset@plt>
lea    -0x8(%rbx),%rdx
lea    0x5a4(%r15),%rdi
mov    $0x40,%esi
call   1050 <memset@plt>
lea    -0xc(%rbx),%rdx
lea    0x876(%r15),%rdi
mov    $0x40,%esi
call   1050 <memset@plt>
add    $0xb48,%r15
add    $0xfffffffffffffff0,%rbx
jne    1390 <test_alpha_encode_decode+0x220>
mov    $0x15310,%ebx
mov    $0x64,%ebp
jmp    1411 <test_alpha_encode_decode+0x2a1>
nopl   0x0(%rax,%rax,1)
add    $0x2d0,%ebx
add    $0xfffffffe,%ebp
cmp    $0x26c50,%ebx
je     145b <test_alpha_encode_decode+0x2eb>
mov    %ebp,%eax
imul   %ebp,%eax
mov    $0x2710,%edi
sub    %eax,%edi
call   1080 <sqrt@plt>
mov    $0x190,%ecx
sub    %eax,%ecx
lea    0x190(%rax),%edx
cmp    %edx,%ecx
jge    1400 <test_alpha_encode_decode+0x290>
add    %ebx,%ecx
add    $0xfffffe70,%ecx
movslq %ecx,%rdi
add    %r14,%rdi
lea    (%r12,%rax,2),%edx
add    $0x2,%edx
and    $0xfffffffe,%edx
add    $0x2,%rdx
mov    $0x60,%esi
call   1050 <memset@plt>
jmp    1400 <test_alpha_encode_decode+0x290>
lea    0x1a608(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1a8d8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1aba8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1ae78(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1b148(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1b418(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1b6e8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1b9b8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1bc88(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1bf58(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1c228(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1c4f8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1c7c8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1ca98(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1cd68(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1d038(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1d308(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1d5d8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
lea    0x1d8a8(%r14),%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
add    $0x1db78,%rdi
mov    $0x280,%edx
mov    $0x7f,%esi
call   1050 <memset@plt>
movl   $0x3000,0x4(%rsp)
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    %r14,%rdx
mov    $0x32a00,%ecx
call   1030 <FS460_encode_alpha_mask_from_bitmap@plt>
test   %eax,%eax
jne    1681 <test_alpha_encode_decode+0x511>
mov    0x4(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1090 <FS460_set_alpha_mask@plt>
mov    $0x32a00,%edi
call   1070 <OS_alloc@plt>
test   %rax,%rax
je     1681 <test_alpha_encode_decode+0x511>
mov    %rax,%rbx
movq   $0x32a00,0x8(%rsp)
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
mov    $0x3000,%ecx
call   1040 <FS460_decode_bitmap_from_alpha_mask@plt>
mov    %rbx,%rdi
call   1060 <OS_free@plt>
mov    %r14,%rdi
call   1060 <OS_free@plt>
add    $0x3018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @test_alpha_encode_decode() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [6144 x i16]
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i64 @OS_alloc(i32 207360)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %1
%12 = load i8*, i8** %1
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %233
14: ; preds = %0
store i32 0, i32* %6
br label %15
15: ; preds = %23, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 207360
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i8*, i8** %1
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %15
26: ; preds = %15
store i32 40, i32* %7
br label %27
27: ; preds = %46, %26
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 80
br i1 %29, label %30, label %49
30: ; preds = %27
store i32 40, i32* %6
br label %31
31: ; preds = %42, %30
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 160
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i8*, i8** %1
%36 = load i32, i32* %7
%37 = mul nsw i32 720, %36
%38 = load i32, i32* %6
%39 = add nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %35, i64 %40
store i8 32, i8* %41
br label %42
42: ; preds = %34
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %31
45: ; preds = %31
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %27
49: ; preds = %27
store i32 20, i32* %7
br label %50
50: ; preds = %77, %49
%51 = load i32, i32* %7
%52 = icmp slt i32 %51, 100
br i1 %52, label %53, label %80
53: ; preds = %50
%54 = load i32, i32* %7
%55 = mul nsw i32 %54, 2
%56 = sub nsw i32 %55, 40
%57 = sub nsw i32 200, %56
store i32 %57, i32* %6
br label %58
58: ; preds = %73, %53
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = mul nsw i32 %60, 2
%62 = sub nsw i32 %61, 40
%63 = add nsw i32 200, %62
%64 = icmp slt i32 %59, %63
br i1 %64, label %65, label %76
65: ; preds = %58
%66 = load i8*, i8** %1
%67 = load i32, i32* %7
%68 = mul nsw i32 720, %67
%69 = load i32, i32* %6
%70 = add nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %66, i64 %71
store i8 64, i8* %72
br label %73
73: ; preds = %65
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %58
76: ; preds = %58
br label %77
77: ; preds = %76
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %50
80: ; preds = %50
store i32 100, i32* %7
br label %81
81: ; preds = %108, %80
%82 = load i32, i32* %7
%83 = icmp slt i32 %82, 180
br i1 %83, label %84, label %111
84: ; preds = %81
%85 = load i32, i32* %7
%86 = mul nsw i32 %85, 2
%87 = sub nsw i32 360, %86
%88 = sub nsw i32 200, %87
store i32 %88, i32* %6
br label %89
89: ; preds = %104, %84
%90 = load i32, i32* %6
%91 = load i32, i32* %7
%92 = mul nsw i32 %91, 2
%93 = sub nsw i32 360, %92
%94 = add nsw i32 200, %93
%95 = icmp slt i32 %90, %94
br i1 %95, label %96, label %107
96: ; preds = %89
%97 = load i8*, i8** %1
%98 = load i32, i32* %7
%99 = mul nsw i32 720, %98
%100 = load i32, i32* %6
%101 = add nsw i32 %99, %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %97, i64 %102
store i8 64, i8* %103
br label %104
104: ; preds = %96
%105 = load i32, i32* %6
%106 = add nsw i32 %105, 1
store i32 %106, i32* %6
br label %89
107: ; preds = %89
br label %108
108: ; preds = %107
%109 = load i32, i32* %7
%110 = add nsw i32 %109, 1
store i32 %110, i32* %7
br label %81
111: ; preds = %81
store i32 120, i32* %7
br label %112
112: ; preds = %145, %111
%113 = load i32, i32* %7
%114 = icmp slt i32 %113, 220
br i1 %114, label %115, label %148
115: ; preds = %112
%116 = load i32, i32* %7
%117 = mul nsw i32 2, %116
%118 = sub nsw i32 340, %117
%119 = load i32, i32* %7
%120 = mul nsw i32 2, %119
%121 = sub nsw i32 340, %120
%122 = mul nsw i32 %118, %121
%123 = sub nsw i32 10000, %122
%124 = call i64 @sqrt(i32 %123)
%125 = trunc i64 %124 to i32
store i32 %125, i32* %8
%126 = load i32, i32* %8
%127 = sub nsw i32 400, %126
store i32 %127, i32* %6
br label %128
128: ; preds = %141, %115
%129 = load i32, i32* %6
%130 = load i32, i32* %8
%131 = add nsw i32 400, %130
%132 = icmp slt i32 %129, %131
br i1 %132, label %133, label %144
133: ; preds = %128
%134 = load i8*, i8** %1
%135 = load i32, i32* %7
%136 = mul nsw i32 720, %135
%137 = load i32, i32* %6
%138 = add nsw i32 %136, %137
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i8, i8* %134, i64 %139
store i8 96, i8* %140
br label %141
141: ; preds = %133
%142 = load i32, i32* %6
%143 = add nsw i32 %142, 1
store i32 %143, i32* %6
br label %128
144: ; preds = %128
br label %145
145: ; preds = %144
%146 = load i32, i32* %7
%147 = add nsw i32 %146, 1
store i32 %147, i32* %7
br label %112
148: ; preds = %112
store i32 150, i32* %7
br label %149
149: ; preds = %168, %148
%150 = load i32, i32* %7
%151 = icmp slt i32 %150, 170
br i1 %151, label %152, label %171
152: ; preds = %149
store i32 40, i32* %6
br label %153
153: ; preds = %164, %152
%154 = load i32, i32* %6
%155 = icmp slt i32 %154, 680
br i1 %155, label %156, label %167
156: ; preds = %153
%157 = load i8*, i8** %1
%158 = load i32, i32* %7
%159 = mul nsw i32 720, %158
%160 = load i32, i32* %6
%161 = add nsw i32 %159, %160
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %157, i64 %162
store i8 127, i8* %163
br label %164
164: ; preds = %156
%165 = load i32, i32* %6
%166 = add nsw i32 %165, 1
store i32 %166, i32* %6
br label %153
167: ; preds = %153
br label %168
168: ; preds = %167
%169 = load i32, i32* %7
%170 = add nsw i32 %169, 1
store i32 %170, i32* %7
br label %149
171: ; preds = %149
store i32 12288, i32* %4
%172 = getelementptr inbounds [6144 x i16], [6144 x i16]* %3, i64 0, i64 0
%173 = load i8*, i8** %1
%174 = call i32 @FS460_encode_alpha_mask_from_bitmap(i16* %172, i32* %4, i8* %173, i32 207360)
store i32 %174, i32* %9
%175 = load i32, i32* %9
%176 = icmp ne i32 %175, 0
br i1 %176, label %177, label %178
177: ; preds = %171
br label %230
178: ; preds = %171
%179 = getelementptr inbounds [6144 x i16], [6144 x i16]* %3, i64 0, i64 0
%180 = load i32, i32* %4
%181 = call i32 @FS460_set_alpha_mask(i16* %179, i32 %180)
store i32 %181, i32* %9
%182 = call i64 @OS_alloc(i32 207360)
%183 = inttoptr i64 %182 to i8*
store i8* %183, i8** %2
%184 = load i8*, i8** %2
%185 = icmp ne i8* %184, null
br i1 %185, label %186, label %229
186: ; preds = %178
store i64 207360, i64* %5
%187 = load i8*, i8** %2
%188 = getelementptr inbounds [6144 x i16], [6144 x i16]* %3, i64 0, i64 0
%189 = call i32 @FS460_decode_bitmap_from_alpha_mask(i8* %187, i64* %5, i16* %188, i32 12288)
store i32 %189, i32* %9
%190 = load i32, i32* %9
%191 = icmp ne i32 %190, 0
br i1 %191, label %192, label %193
192: ; preds = %186
br label %226
193: ; preds = %186
%194 = load i64, i64* %5
%195 = icmp ne i64 %194, 207360
br i1 %195, label %196, label %197
196: ; preds = %193
br label %197
197: ; preds = %196, %193
store i32 0, i32* %6
br label %198
198: ; preds = %217, %197
%199 = load i32, i32* %6
%200 = icmp slt i32 %199, 207360
br i1 %200, label %201, label %220
201: ; preds = %198
%202 = load i8*, i8** %2
%203 = load i32, i32* %6
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds i8, i8* %202, i64 %204
%206 = load i8, i8* %205
%207 = zext i8 %206 to i32
%208 = load i8*, i8** %1
%209 = load i32, i32* %6
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i8, i8* %208, i64 %210
%212 = load i8, i8* %211
%213 = zext i8 %212 to i32
%214 = icmp ne i32 %207, %213
br i1 %214, label %215, label %216
215: ; preds = %201
br label %220
216: ; preds = %201
br label %217
217: ; preds = %216
%218 = load i32, i32* %6
%219 = add nsw i32 %218, 1
store i32 %219, i32* %6
br label %198
220: ; preds = %215, %198
%221 = load i32, i32* %6
%222 = icmp slt i32 %221, 207360
br i1 %222, label %223, label %224
223: ; preds = %220
br label %225
224: ; preds = %220
br label %225
225: ; preds = %224, %223
br label %226
226: ; preds = %225, %192
%227 = load i8*, i8** %2
%228 = call i32 @OS_free(i8* %227)
br label %229
229: ; preds = %226, %178
br label %230
230: ; preds = %229, %177
%231 = load i8*, i8** %1
%232 = call i32 @OS_free(i8* %231)
br label %233
233: ; preds = %230, %0
ret void
}

LLVM IR (-O2):
define void @test_alpha_encode_decode() {
%1 = alloca [6144 x i16]
%2 = alloca i32
%3 = alloca i64
%4 = bitcast [6144 x i16]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = tail call i64 @OS_alloc(i32 207360)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %137, label %10
10: ; preds = %0
br label %11
11: ; preds = %11, %10
%12 = phi i64 [ 0, %10 ], [ %28, %11 ]
%13 = mul nuw nsw i64 %12, 720
%14 = add nuw nsw i64 %13, 28840
%15 = getelementptr i8, i8* %8, i64 %14
%16 = mul i64 %12, 720
%17 = add i64 %16, 29560
%18 = getelementptr i8, i8* %8, i64 %17
%19 = mul i64 %12, 720
%20 = add i64 %19, 30280
%21 = getelementptr i8, i8* %8, i64 %20
%22 = mul i64 %12, 720
%23 = add i64 %22, 31000
%24 = getelementptr i8, i8* %8, i64 %23
%25 = mul i64 %12, 720
%26 = add i64 %25, 31720
%27 = getelementptr i8, i8* %8, i64 %26
%28 = add nuw nsw i64 %12, 5
%29 = icmp eq i64 %28, 40
br i1 %29, label %30, label %11
30: ; preds = %11, %45
%31 = phi i64 [ %47, %45 ], [ 0, %11 ]
%32 = phi i32 [ %46, %45 ], [ 20, %11 ]
%33 = shl nuw nsw i32 %32, 1
%34 = sub nuw nsw i32 240, %33
%35 = add nuw nsw i32 %33, 160
%36 = icmp ult i32 %34, %35
br i1 %36, label %37, label %45
37: ; preds = %30
%38 = shl i64 %31, 2
%39 = add i64 %38, 4294967292
%40 = and i64 %39, 4294967292
%41 = add nuw nsw i64 %40, 4
%42 = mul nuw nsw i64 %31, 718
%43 = add nuw nsw i64 %42, 14600
%44 = getelementptr i8, i8* %8, i64 %43
br label %45
45: ; preds = %37, %30
%46 = add nuw nsw i32 %32, 1
%47 = add nuw nsw i64 %31, 1
%48 = icmp eq i64 %47, 80
br i1 %48, label %49, label %30
49: ; preds = %45, %49
%50 = phi i64 [ %74, %49 ], [ 0, %45 ]
%51 = mul nsw i64 %50, -4
%52 = add nsw i64 %51, 320
%53 = mul nuw nsw i64 %50, 722
%54 = add nuw nsw i64 %53, 72040
%55 = getelementptr i8, i8* %8, i64 %54
%56 = or i64 %50, 1
%57 = mul nsw i64 %56, -4
%58 = add nsw i64 %57, 320
%59 = mul nuw nsw i64 %56, 722
%60 = add nuw nsw i64 %59, 72040
%61 = getelementptr i8, i8* %8, i64 %60
%62 = or i64 %50, 2
%63 = mul nsw i64 %62, -4
%64 = add nsw i64 %63, 320
%65 = mul nuw nsw i64 %62, 722
%66 = add nuw nsw i64 %65, 72040
%67 = getelementptr i8, i8* %8, i64 %66
%68 = or i64 %50, 3
%69 = mul nsw i64 %68, -4
%70 = add nsw i64 %69, 320
%71 = mul nuw nsw i64 %68, 722
%72 = add nuw nsw i64 %71, 72040
%73 = getelementptr i8, i8* %8, i64 %72
%74 = add nuw nsw i64 %50, 4
%75 = icmp eq i64 %74, 80
br i1 %75, label %76, label %49
76: ; preds = %49, %98
%77 = phi i32 [ %100, %98 ], [ 0, %49 ]
%78 = phi i32 [ %99, %98 ], [ 120, %49 ]
%79 = mul nsw i32 %78, -2
%80 = add nsw i32 %79, 340
%81 = mul nsw i32 %80, %80
%82 = sub nsw i32 10000, %81
%83 = tail call i64 @sqrt(i32 %82)
%84 = trunc i64 %83 to i32
%85 = sub i32 400, %84
%86 = add nsw i32 %84, 400
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %98
88: ; preds = %76
%89 = mul nuw nsw i32 %77, 720
%90 = add nuw nsw i32 %89, 86800
%91 = sub i32 %90, %84
%92 = sext i32 %91 to i64
%93 = getelementptr i8, i8* %8, i64 %92
%94 = shl i64 %83, 1
%95 = add i64 %94, 4294967294
%96 = and i64 %95, 4294967294
%97 = add nuw nsw i64 %96, 2
br label %98
98: ; preds = %88, %76
%99 = add nuw nsw i32 %78, 1
%100 = add nuw nsw i32 %77, 1
%101 = icmp eq i32 %100, 100
br i1 %101, label %102, label %76
102: ; preds = %98
%103 = getelementptr i8, i8* %8, i64 108040
%104 = getelementptr i8, i8* %8, i64 108760
%105 = getelementptr i8, i8* %8, i64 109480
%106 = getelementptr i8, i8* %8, i64 110200
%107 = getelementptr i8, i8* %8, i64 110920
%108 = getelementptr i8, i8* %8, i64 111640
%109 = getelementptr i8, i8* %8, i64 112360
%110 = getelementptr i8, i8* %8, i64 113080
%111 = getelementptr i8, i8* %8, i64 113800
%112 = getelementptr i8, i8* %8, i64 114520
%113 = getelementptr i8, i8* %8, i64 115240
%114 = getelementptr i8, i8* %8, i64 115960
%115 = getelementptr i8, i8* %8, i64 116680
%116 = getelementptr i8, i8* %8, i64 117400
%117 = getelementptr i8, i8* %8, i64 118120
%118 = getelementptr i8, i8* %8, i64 118840
%119 = getelementptr i8, i8* %8, i64 119560
%120 = getelementptr i8, i8* %8, i64 120280
%121 = getelementptr i8, i8* %8, i64 121000
%122 = getelementptr i8, i8* %8, i64 121720
store i32 12288, i32* %2
%123 = getelementptr inbounds [6144 x i16], [6144 x i16]* %1, i64 0, i64 0
%124 = call i32 @FS460_encode_alpha_mask_from_bitmap(i16* %123, i32* %2, i8* %8, i32 207360)
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %135
126: ; preds = %102
%127 = load i32, i32* %2
%128 = call i32 @FS460_set_alpha_mask(i16* %123, i32 %127)
%129 = call i64 @OS_alloc(i32 207360)
%130 = inttoptr i64 %129 to i8*
%131 = icmp eq i64 %129, 0
br i1 %131, label %135, label %132
132: ; preds = %126
store i64 207360, i64* %3
%133 = call i32 @FS460_decode_bitmap_from_alpha_mask(i8* %130, i64* %3, i16* %123, i32 12288)
%134 = call i32 @OS_free(i8* %130)
br label %135
135: ; preds = %126, %132, %102
%136 = call i32 @OS_free(i8* %8)
br label %137
137: ; preds = %135, %0
ret void
}