#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*/ histogram2(unsigned char *, int /*<<< orphan*/, int, int,
                              int, unsigned int *);
int /*<<< orphan*/ printf(char *);
int testcolorproc2() {
  unsigned int result[256] = {0};
  unsigned char bitmap[5 * 4] = {1, 2, 3, 4, 42, 1, 2, 3, 4, 42,
                                 5, 5, 5, 5, 42, 0, 0, 9, 9, 42};
  histogram2(bitmap, 0, 4, 5, 4, result);
  int i;
  if (result[0] != 1) {
    printf("Fail:"
           "result[0]"
           " != "
           "1"
           ".\n");
    return 1;
  };
  if (result[1] != 2) {
    printf("Fail:"
           "result[1]"
           " != "
           "2"
           ".\n");
    return 1;
  };
  if (result[2] != 0) {
    printf("Fail:"
           "result[2]"
           " != "
           "0"
           ".\n");
    return 1;
  };
  if (result[5] != 2) {
    printf("Fail:"
           "result[5]"
           " != "
           "2"
           ".\n");
    return 1;
  };
  if (result[42] != 0) {
    printf("Fail:"
           "result[42]"
           " != "
           "0"
           ".\n");
    return 1;
  };
  return 0;
}


x86 assembly (clang, -O0):
<testcolorproc2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    0xeab(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    0xea0(%rip),%eax
mov    %eax,-0x420(%rbp)
lea    -0x430(%rbp),%rdi
lea    -0x410(%rbp),%r9
xor    %esi,%esi
mov    $0x4,%r8d
mov    $0x5,%ecx
mov    %r8d,%edx
call   1030 <histogram2@plt>
cmpl   $0x1,-0x410(%rbp)
je     11be <testcolorproc2+0x8e>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <testcolorproc2+0x129>
cmpl   $0x2,-0x40c(%rbp)
je     11e3 <testcolorproc2+0xb3>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <testcolorproc2+0x129>
cmpl   $0x0,-0x408(%rbp)
je     1208 <testcolorproc2+0xd8>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <testcolorproc2+0x129>
cmpl   $0x2,-0x3fc(%rbp)
je     122d <testcolorproc2+0xfd>
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <testcolorproc2+0x129>
cmpl   $0x0,-0x368(%rbp)
je     1252 <testcolorproc2+0x122>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <testcolorproc2+0x129>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcolorproc2>:
push   %rbx
sub    $0x420,%rsp
lea    0x20(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x2a090900,0x10(%rsp)
2a
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
mov    $0x4,%r8d
mov    %rbx,%r9
call   1040 <histogram2@plt>
cmpl   $0x1,0x20(%rsp)
jne    119a <testcolorproc2+0x6a>
cmpl   $0x2,0x24(%rsp)
jne    11a3 <testcolorproc2+0x73>
cmpl   $0x0,0x28(%rsp)
je     11bd <testcolorproc2+0x8d>
lea    0xea7(%rip),%rdi
jmp    11aa <testcolorproc2+0x7a>
lea    0xec8(%rip),%rdi
jmp    11aa <testcolorproc2+0x7a>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x420,%rsp
pop    %rbx
ret
cmpl   $0x2,0x34(%rsp)
jne    11d7 <testcolorproc2+0xa7>
cmpl   $0x0,0xc8(%rsp)
je     11e0 <testcolorproc2+0xb0>
lea    0xe3f(%rip),%rdi
jmp    11aa <testcolorproc2+0x7a>
lea    0xe4c(%rip),%rdi
jmp    11aa <testcolorproc2+0x7a>
xor    %eax,%eax
jmp    11b4 <testcolorproc2+0x84>

LLVM IR (-O0):
@__const.testcolorproc2.bitmap = [20 x i8] c"\01\02\03\04*\01\02\03\04*\05\05\05\05*\00\00\09\09*"
@.str = [22 x i8] c"Fail:result[0] != 1.\0A\00"
@.str.1 = [22 x i8] c"Fail:result[1] != 2.\0A\00"
@.str.2 = [22 x i8] c"Fail:result[2] != 0.\0A\00"
@.str.3 = [22 x i8] c"Fail:result[5] != 2.\0A\00"
@.str.4 = [23 x i8] c"Fail:result[42] != 0.\0A\00"
define i32 @testcolorproc2() {
%1 = alloca i32
%2 = alloca [256 x i32]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = bitcast [256 x i32]* %2 to i8*
%6 = bitcast [20 x i8]* %3 to i8*
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
%9 = call i32 @histogram2(i8* %7, i32 0, i32 4, i32 5, i32 4, i32* %8)
%10 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %40
15: ; preds = %0
%16 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %40
21: ; preds = %15
%22 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 2
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %40
27: ; preds = %21
%28 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 5
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %40
33: ; preds = %27
%34 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 42
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %40
39: ; preds = %33
store i32 0, i32* %1
br label %40
40: ; preds = %39, %37, %31, %25, %19, %13
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@__const.testcolorproc2.bitmap = [20 x i8] c"\01\02\03\04*\01\02\03\04*\05\05\05\05*\00\00\09\09*"
@str = [22 x i8] c"Fail:result[42] != 0.\00"
@str.5 = [21 x i8] c"Fail:result[5] != 2.\00"
@str.6 = [21 x i8] c"Fail:result[2] != 0.\00"
@str.7 = [21 x i8] c"Fail:result[1] != 2.\00"
@str.8 = [21 x i8] c"Fail:result[0] != 1.\00"
define i32 @testcolorproc2() {
%1 = alloca [256 x i32]
%2 = alloca [20 x i8]
%3 = bitcast [256 x i32]* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
%6 = call i32 @histogram2(i8* %4, i32 0, i32 4, i32 5, i32 4, i32* %5)
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %25
9: ; preds = %0
%10 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 5
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 42
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %21, %17, %13, %9, %0
%26 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0), %0 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0), %13 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0), %17 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %21 ]
%27 = call i32 @puts(i8* dereferenceable(1) %26)
br label %28
28: ; preds = %25, %21
%29 = phi i32 [ 0, %21 ], [ 1, %25 ]
ret i32 %29
}