#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*/ msg_Dbg(char *);
int checkbuffer(unsigned char *buffer) {
  int error = 0;
  if (buffer[0] == 255) {
    msg_Dbg("buffer[0] == 255");
  } else {
    error = 1;
    msg_Dbg("buffer[0] != 255");
  }
  if (buffer[1] < 255) {
    msg_Dbg("buffer[1] <255");
  } else {
    error = 1;
    msg_Dbg("buffer[1] >= 255");
  }
  if (buffer[2] < 2) {
    msg_Dbg("buffer[2] <2");
  } else {
    error = 1;
    msg_Dbg("buffer[2] >= 2");
  }
  if (buffer[3] < 255) {
    msg_Dbg("buffer[3] <255");
  } else {
    error = 1;
    msg_Dbg("buffer[3] >= 255");
  }
  if (buffer[4] < 255) {
    msg_Dbg("buffer[4] <255");
  } else {
    error = 1;
    msg_Dbg("buffer[4] >= 255");
  }
  if (buffer[5] < 5) {
    msg_Dbg("buffer[5] <5");
  } else {
    error = 1;
    msg_Dbg("buffer[5] >= 255");
  }
  return error;
}


x86 assembly (clang, -O0):
<checkbuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    1146 <checkbuffer+0x36>
lea    0xec4(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    1159 <checkbuffer+0x49>
movl   $0x1,-0xc(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xff,%eax
jge    117d <checkbuffer+0x6d>
lea    0xeaf(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    1190 <checkbuffer+0x80>
movl   $0x1,-0xc(%rbp)
lea    0xea6(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x2,%eax
jge    11b2 <checkbuffer+0xa2>
lea    0xe9a(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    11c5 <checkbuffer+0xb5>
movl   $0x1,-0xc(%rbp)
lea    0xe8f(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0xff,%eax
jge    11e9 <checkbuffer+0xd9>
lea    0xe7f(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    11fc <checkbuffer+0xec>
movl   $0x1,-0xc(%rbp)
lea    0xe76(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
cmp    $0xff,%eax
jge    1220 <checkbuffer+0x110>
lea    0xe68(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    1233 <checkbuffer+0x123>
movl   $0x1,-0xc(%rbp)
lea    0xe5f(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
cmp    $0x5,%eax
jge    1255 <checkbuffer+0x145>
lea    0xe53(%rip),%rdi
call   1030 <msg_Dbg@plt>
jmp    1268 <checkbuffer+0x158>
movl   $0x1,-0xc(%rbp)
lea    0xe48(%rip),%rdi
call   1030 <msg_Dbg@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkbuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbp
cmpb   $0xff,(%rdi)
setne  %r12b
lea    0xed4(%rip),%rax
lea    0xede(%rip),%rdi
cmove  %rax,%rdi
call   1030 <msg_Dbg@plt>
cmpb   $0xff,0x1(%rbp)
sete   %r14b
lea    0xee6(%rip),%rax
lea    0xed0(%rip),%rdi
cmove  %rax,%rdi
call   1030 <msg_Dbg@plt>
cmpb   $0x2,0x2(%rbp)
setae  %r15b
lea    0xed8(%rip),%rax
lea    0xede(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <msg_Dbg@plt>
cmpb   $0xff,0x3(%rbp)
sete   %bl
lea    0xee5(%rip),%rax
lea    0xecf(%rip),%rdi
cmove  %rax,%rdi
call   1030 <msg_Dbg@plt>
cmpb   $0xff,0x4(%rbp)
sete   %r13b
lea    0xee6(%rip),%rax
lea    0xed0(%rip),%rdi
cmove  %rax,%rdi
call   1030 <msg_Dbg@plt>
cmpb   $0x5,0x5(%rbp)
setae  %al
lea    0xed9(%rip),%rcx
lea    0xedf(%rip),%rdi
cmovb  %rcx,%rdi
or     %r13b,%al
or     %r15b,%bl
or     %al,%bl
or     %r12b,%r14b
or     %bl,%r14b
movzbl %r14b,%ebx
call   1030 <msg_Dbg@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"buffer[0] == 255\00"
@.str.1 = [17 x i8] c"buffer[0] != 255\00"
@.str.2 = [15 x i8] c"buffer[1] <255\00"
@.str.3 = [17 x i8] c"buffer[1] >= 255\00"
@.str.4 = [13 x i8] c"buffer[2] <2\00"
@.str.5 = [15 x i8] c"buffer[2] >= 2\00"
@.str.6 = [15 x i8] c"buffer[3] <255\00"
@.str.7 = [17 x i8] c"buffer[3] >= 255\00"
@.str.8 = [15 x i8] c"buffer[4] <255\00"
@.str.9 = [17 x i8] c"buffer[4] >= 255\00"
@.str.10 = [13 x i8] c"buffer[5] <5\00"
@.str.11 = [17 x i8] c"buffer[5] >= 255\00"
define i32 @checkbuffer(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 255
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %1
store i32 1, i32* %3
%12 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp slt i32 %17, 255
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @msg_Dbg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %13
store i32 1, i32* %3
%22 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @msg_Dbg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %33
31: ; preds = %23
store i32 1, i32* %3
%32 = call i32 @msg_Dbg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 3
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp slt i32 %37, 255
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = call i32 @msg_Dbg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %43
41: ; preds = %33
store i32 1, i32* %3
%42 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %43
43: ; preds = %41, %39
%44 = load i8*, i8** %2
%45 = getelementptr inbounds i8, i8* %44, i64 4
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = icmp slt i32 %47, 255
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 @msg_Dbg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %53
51: ; preds = %43
store i32 1, i32* %3
%52 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i64 5
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = icmp slt i32 %57, 5
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @msg_Dbg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %63
61: ; preds = %53
store i32 1, i32* %3
%62 = call i32 @msg_Dbg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str = [17 x i8] c"buffer[0] == 255\00"
@.str.1 = [17 x i8] c"buffer[0] != 255\00"
@.str.2 = [15 x i8] c"buffer[1] <255\00"
@.str.3 = [17 x i8] c"buffer[1] >= 255\00"
@.str.4 = [13 x i8] c"buffer[2] <2\00"
@.str.5 = [15 x i8] c"buffer[2] >= 2\00"
@.str.6 = [15 x i8] c"buffer[3] <255\00"
@.str.7 = [17 x i8] c"buffer[3] >= 255\00"
@.str.8 = [15 x i8] c"buffer[4] <255\00"
@.str.9 = [17 x i8] c"buffer[4] >= 255\00"
@.str.10 = [13 x i8] c"buffer[5] <5\00"
@.str.11 = [17 x i8] c"buffer[5] >= 255\00"
define i32 @checkbuffer(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, -1
%4 = select i1 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0)
%5 = xor i1 %3, true
%6 = tail call i32 @msg_Dbg(i8* %4)
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, -1
%10 = select i1 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 @msg_Dbg(i8* %10)
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = icmp ult i8 %13, 2
%15 = select i1 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0)
%16 = xor i1 %14, true
%17 = tail call i32 @msg_Dbg(i8* %15)
%18 = getelementptr inbounds i8, i8* %0, i64 3
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, -1
%21 = select i1 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0)
%22 = tail call i32 @msg_Dbg(i8* %21)
%23 = getelementptr inbounds i8, i8* %0, i64 4
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, -1
%26 = select i1 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0)
%27 = tail call i32 @msg_Dbg(i8* %26)
%28 = getelementptr inbounds i8, i8* %0, i64 5
%29 = load i8, i8* %28
%30 = icmp ult i8 %29, 5
%31 = select i1 %30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0)
%32 = xor i1 %30, true
%33 = select i1 %32, i1 true, i1 %25
%34 = select i1 %33, i1 true, i1 %20
%35 = select i1 %34, i1 true, i1 %16
%36 = select i1 %35, i1 true, i1 %9
%37 = select i1 %36, i1 true, i1 %5
%38 = zext i1 %37 to i32
%39 = tail call i32 @msg_Dbg(i8* %31)
ret i32 %38
}