#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*/ getcolors(int *, unsigned char *, int const, int const);
int /*<<< orphan*/ printf(char *, int, int);
int testcolorproc() {
  int result = 0;
  const int xres = 100;
  const int yres = 10;
  unsigned char bitmap[xres * yres * 3];
  int i;
  for (i = 0; i < xres * yres * 3;) {
    bitmap[i++] = 255;
    bitmap[i++] = 127;
    bitmap[i++] = 0;
  }
  int colors[5];
  getcolors(colors, bitmap, xres, yres);
  for (i = 0; i < 5; ++i) {
    if (colors[i] != 0x00ff7f00) {
      printf("Wrong color at %d: %06x\n", i, colors[i]);
      result = 1;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<testcolorproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xbb8,-0x1c(%rbp)
jge    119f <testcolorproc+0x7f>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0xff,-0xbf0(%rbp,%rax,1)
ff
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x7f,-0xbf0(%rbp,%rax,1)
7f
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x0,-0xbf0(%rbp,%rax,1)
jmp    114e <testcolorproc+0x2e>
lea    -0x30(%rbp),%rdi
lea    -0xbf0(%rbp),%rsi
mov    $0x64,%edx
mov    $0xa,%ecx
call   1040 <getcolors@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    120d <testcolorproc+0xed>
movslq -0x1c(%rbp),%rax
cmpl   $0xff7f00,-0x30(%rbp,%rax,4)
je     11fa <testcolorproc+0xda>
mov    -0x1c(%rbp),%esi
movslq -0x1c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ff <testcolorproc+0xdf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <testcolorproc+0xa0>
mov    -0x4(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
add    $0xbf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcolorproc>:
push   %rbx
sub    $0xbe0,%rsp
mov    $0xfffffffffffffffa,%rax
nop
movl   $0xff007fff,0x26(%rsp,%rax,1)
ff
movw   $0x7f,0x2a(%rsp,%rax,1)
add    $0x6,%rax
cmp    $0xbb2,%rax
jb     1130 <testcolorproc+0x10>
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    $0x64,%edx
mov    $0xa,%ecx
call   1040 <getcolors@plt>
mov    (%rsp),%edx
xor    %ebx,%ebx
cmp    $0xff7f00,%edx
je     1182 <testcolorproc+0x62>
lea    0xe8a(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    0x4(%rsp),%edx
cmp    $0xff7f00,%edx
je     11a4 <testcolorproc+0x84>
lea    0xe6b(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
cmp    $0xff7f00,%edx
je     11c6 <testcolorproc+0xa6>
lea    0xe49(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    0xc(%rsp),%edx
cmp    $0xff7f00,%edx
je     11e8 <testcolorproc+0xc8>
lea    0xe27(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    0x10(%rsp),%edx
cmp    $0xff7f00,%edx
je     120a <testcolorproc+0xea>
lea    0xe05(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0xbe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Wrong color at %d: %06x\0A\00"
define i32 @testcolorproc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [5 x i32]
store i32 0, i32* %1
store i32 100, i32* %2
store i32 10, i32* %3
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %4
%8 = alloca i8, i64 3000
store i32 0, i32* %5
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 3000
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %5
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %8, i64 %15
store i8 -1, i8* %16
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %8, i64 %19
store i8 127, i8* %20
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %8, i64 %23
store i8 0, i8* %24
br label %9
25: ; preds = %9
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%27 = call i32 @getcolors(i32* %26, i8* %8, i32 100, i32 10)
store i32 0, i32* %5
br label %28
28: ; preds = %45, %25
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %48
31: ; preds = %28
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 16744192
br i1 %36, label %37, label %44
37: ; preds = %31
%38 = load i32, i32* %5
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %42)
store i32 1, i32* %1
br label %44
44: ; preds = %37, %31
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %28
48: ; preds = %28
%49 = load i32, i32* %1
%50 = load i8*, i8** %4
ret i32 %49
}

LLVM IR (-O2):
@.str = [25 x i8] c"Wrong color at %d: %06x\0A\00"
define i32 @testcolorproc() {
%1 = alloca [5 x i32]
%2 = alloca [3000 x i8]
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %15, %3 ]
%5 = or i64 %4, 1
%6 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %4
store i8 -1, i8* %6
%7 = add nuw nsw i64 %4, 2
%8 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %5
store i8 127, i8* %8
%9 = add nuw nsw i64 %4, 3
%10 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %7
store i8 0, i8* %10
%11 = add nuw nsw i64 %4, 4
%12 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %9
store i8 -1, i8* %12
%13 = add nuw nsw i64 %4, 5
%14 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %11
store i8 127, i8* %14
%15 = add nuw nsw i64 %4, 6
%16 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %16
%17 = icmp ult i64 %4, 2994
br i1 %17, label %3, label %18
18: ; preds = %3
%19 = getelementptr inbounds [3000 x i8], [3000 x i8]* %2, i64 0, i64 0
%20 = bitcast [5 x i32]* %1 to i8*
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%22 = call i32 @getcolors(i32* %21, i8* %19, i32 100, i32 10)
%23 = load i32, i32* %21
%24 = icmp eq i32 %23, 16744192
br i1 %24, label %27, label %25
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0, i32 %23)
br label %27
27: ; preds = %18, %25
%28 = phi i32 [ 1, %25 ], [ 0, %18 ]
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 16744192
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 1, i32 %30)
br label %34
34: ; preds = %32, %27
%35 = phi i32 [ 1, %32 ], [ %28, %27 ]
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 16744192
br i1 %38, label %41, label %39
39: ; preds = %34
%40 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 2, i32 %37)
br label %41
41: ; preds = %39, %34
%42 = phi i32 [ 1, %39 ], [ %35, %34 ]
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 16744192
br i1 %45, label %48, label %46
46: ; preds = %41
%47 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 3, i32 %44)
br label %48
48: ; preds = %46, %41
%49 = phi i32 [ 1, %46 ], [ %42, %41 ]
%50 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 16744192
br i1 %52, label %55, label %53
53: ; preds = %48
%54 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 4, i32 %51)
br label %55
55: ; preds = %53, %48
%56 = phi i32 [ 1, %53 ], [ %49, %48 ]
ret i32 %56
}