#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;

/* Variables and functions */
int decode_block4x4_11bits_signed(int, unsigned int *, int, int);
int draw_block4x4_signed_rg11_eac(const unsigned char *bitstring,
                                  unsigned int *image_buffer, int flags) {
  uint64_t red_qword =
      ((uint64_t)bitstring[0] << 56) | ((uint64_t)bitstring[1] << 48) |
      ((uint64_t)bitstring[2] << 40) | ((uint64_t)bitstring[3] << 32) |
      ((uint64_t)bitstring[4] << 24) | ((uint64_t)bitstring[5] << 16) |
      ((uint64_t)bitstring[6] << 8) | bitstring[7];
  int r = decode_block4x4_11bits_signed(red_qword, image_buffer, 0, flags);
  if (r == 0)
    return 0;
  uint64_t green_qword =
      ((uint64_t)bitstring[8] << 56) | ((uint64_t)bitstring[9] << 48) |
      ((uint64_t)bitstring[10] << 40) | ((uint64_t)bitstring[11] << 32) |
      ((uint64_t)bitstring[12] << 24) | ((uint64_t)bitstring[13] << 16) |
      ((uint64_t)bitstring[14] << 8) | bitstring[15];
  decode_block4x4_11bits_signed(green_qword, image_buffer, 1, flags);
  return 1;
}


x86 assembly (clang, -O0):
<draw_block4x4_signed_rg11_eac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    $0x38,%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x5(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x6(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
xor    %edx,%edx
call   1030 <decode_block4x4_11bits_signed@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11c8 <draw_block4x4_signed_rg11_eac+0xb8>
movl   $0x0,-0x4(%rbp)
jmp    125f <draw_block4x4_signed_rg11_eac+0x14f>
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
mov    $0x38,%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x9(%rcx),%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xa(%rcx),%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xb(%rcx),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xc(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xd(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xe(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0xf(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
call   1030 <decode_block4x4_11bits_signed@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_block4x4_signed_rg11_eac>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
xor    %r14d,%r14d
xor    %edx,%edx
mov    %ebp,%ecx
call   1030 <decode_block4x4_11bits_signed@plt>
test   %eax,%eax
je     113e <draw_block4x4_signed_rg11_eac+0x2e>
mov    $0x1,%r14d
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %ebp,%ecx
call   1030 <decode_block4x4_11bits_signed@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @draw_block4x4_signed_rg11_eac(i8* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl i32 %14, 56
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl i32 %19, 48
%21 = or i32 %15, %20
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = shl i32 %25, 40
%27 = or i32 %21, %26
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 32
%33 = or i32 %27, %32
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 4
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = shl i32 %37, 24
%39 = or i32 %33, %38
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 5
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl i32 %43, 16
%45 = or i32 %39, %44
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i64 6
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = shl i32 %49, 8
%51 = or i32 %45, %50
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 7
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = or i32 %51, %55
store i32 %56, i32* %8
%57 = load i32, i32* %8
%58 = load i32*, i32** %6
%59 = load i32, i32* %7
%60 = call i32 @decode_block4x4_11bits_signed(i32 %57, i32* %58, i32 0, i32 %59)
store i32 %60, i32* %9
%61 = load i32, i32* %9
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %3
store i32 0, i32* %4
br label %115
64: ; preds = %3
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i64 8
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = shl i32 %68, 56
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i64 9
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = shl i32 %73, 48
%75 = or i32 %69, %74
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i64 10
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = shl i32 %79, 40
%81 = or i32 %75, %80
%82 = load i8*, i8** %5
%83 = getelementptr inbounds i8, i8* %82, i64 11
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = shl i32 %85, 32
%87 = or i32 %81, %86
%88 = load i8*, i8** %5
%89 = getelementptr inbounds i8, i8* %88, i64 12
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = shl i32 %91, 24
%93 = or i32 %87, %92
%94 = load i8*, i8** %5
%95 = getelementptr inbounds i8, i8* %94, i64 13
%96 = load i8, i8* %95
%97 = zext i8 %96 to i32
%98 = shl i32 %97, 16
%99 = or i32 %93, %98
%100 = load i8*, i8** %5
%101 = getelementptr inbounds i8, i8* %100, i64 14
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = shl i32 %103, 8
%105 = or i32 %99, %104
%106 = load i8*, i8** %5
%107 = getelementptr inbounds i8, i8* %106, i64 15
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = or i32 %105, %109
store i32 %110, i32* %10
%111 = load i32, i32* %10
%112 = load i32*, i32** %6
%113 = load i32, i32* %7
%114 = call i32 @decode_block4x4_11bits_signed(i32 %111, i32* %112, i32 1, i32 %113)
store i32 1, i32* %4
br label %115
115: ; preds = %64, %63
%116 = load i32, i32* %4
ret i32 %116
}

LLVM IR (-O2):
define i32 @draw_block4x4_signed_rg11_eac(i8* nocapture readnone %0, i32* %1, i32 %2) {
%4 = tail call i32 @decode_block4x4_11bits_signed(i32 poison, i32* %1, i32 0, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @decode_block4x4_11bits_signed(i32 poison, i32* %1, i32 1, i32 %2)
br label %8
8: ; preds = %3, %6
%9 = phi i32 [ 1, %6 ], [ 0, %3 ]
ret i32 %9
}