#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*/ printf(char *, ...);
int _glipCheckImageParam(int w, int h, int b, int format, int type) {
  int r = 1;
  if ((w <= 0) || (h <= 0)) {
    printf("Image Size Not Valid  w=%d h=%d\n", w, h);
    r -= 1;
  }
  if ((format < 6400) || (format > 32993) ||
      ((format > 6409) && (format < 32992))) {
    printf("Image Not a valid format\n");
    r -= 2;
  }
  if ((type < 5120) || (type > 5126)) {
    printf("Image Not a valid type\n");
    r -= 4;
  }
  if (!((b == 1) || (b == 2) || (b == 4) || (b == 8))) {
    r = -8;
    printf("Image  Not a valid byte Aligment \n");
  }
  return r;
}


x86 assembly (clang, -O0):
<_glipCheckImageParam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1143 <_glipCheckImageParam+0x33>
cmpl   $0x0,-0x8(%rbp)
jg     1160 <_glipCheckImageParam+0x50>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1900,-0x10(%rbp)
jl     1194 <_glipCheckImageParam+0x84>
cmpl   $0x80e1,-0x10(%rbp)
jg     1194 <_glipCheckImageParam+0x84>
cmpl   $0x1909,-0x10(%rbp)
jle    11ab <_glipCheckImageParam+0x9b>
cmpl   $0x80e0,-0x10(%rbp)
jge    11ab <_glipCheckImageParam+0x9b>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1400,-0x14(%rbp)
jl     11c5 <_glipCheckImageParam+0xb5>
cmpl   $0x1406,-0x14(%rbp)
jle    11dc <_glipCheckImageParam+0xcc>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1219 <_glipCheckImageParam+0x109>
cmpl   $0x2,-0xc(%rbp)
je     1219 <_glipCheckImageParam+0x109>
cmpl   $0x4,-0xc(%rbp)
je     1219 <_glipCheckImageParam+0x109>
cmpl   $0x8,-0xc(%rbp)
je     1219 <_glipCheckImageParam+0x109>
movl   $0xfffffff8,-0x18(%rbp)
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_glipCheckImageParam>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%edx
mov    %edi,%esi
test   %edi,%edi
jle    1141 <_glipCheckImageParam+0x21>
mov    $0x1,%r15d
test   %edx,%edx
jg     1152 <_glipCheckImageParam+0x32>
lea    0xeb8(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x80e2(%rbp),%eax
cmp    $0xffff981e,%eax
jb     116d <_glipCheckImageParam+0x4d>
add    $0xffffe6f6,%ebp
cmp    $0x67d5,%ebp
ja     117d <_glipCheckImageParam+0x5d>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
or     $0xfffffffe,%r15d
add    $0xffffebf9,%ebx
cmp    $0xfffffff8,%ebx
ja     1198 <_glipCheckImageParam+0x78>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
add    $0xfffffffc,%r15d
cmp    $0x8,%r14d
ja     11a9 <_glipCheckImageParam+0x89>
mov    $0x116,%eax
bt     %r14d,%eax
jb     11bb <_glipCheckImageParam+0x9b>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffff8,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Image Size Not Valid w=%d h=%d\0A\00"
@.str.1 = [26 x i8] c"Image Not a valid format\0A\00"
@.str.2 = [24 x i8] c"Image Not a valid type\0A\00"
@.str.3 = [35 x i8] c"Image Not a valid byte Aligment \0A\00"
define i32 @_glipCheckImageParam(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 1, i32* %11
%12 = load i32, i32* %6
%13 = icmp sle i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %5
%15 = load i32, i32* %7
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14, %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32, i32* %11
%22 = sub nsw i32 %21, 1
store i32 %22, i32* %11
br label %23
23: ; preds = %17, %14
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 6400
br i1 %25, label %35, label %26
26: ; preds = %23
%27 = load i32, i32* %9
%28 = icmp sgt i32 %27, 32993
br i1 %28, label %35, label %29
29: ; preds = %26
%30 = load i32, i32* %9
%31 = icmp sgt i32 %30, 6409
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %9
%34 = icmp slt i32 %33, 32992
br i1 %34, label %35, label %39
35: ; preds = %32, %26, %23
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %11
%38 = sub nsw i32 %37, 2
store i32 %38, i32* %11
br label %39
39: ; preds = %35, %32, %29
%40 = load i32, i32* %10
%41 = icmp slt i32 %40, 5120
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* %10
%44 = icmp sgt i32 %43, 5126
br i1 %44, label %45, label %49
45: ; preds = %42, %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %11
%48 = sub nsw i32 %47, 4
store i32 %48, i32* %11
br label %49
49: ; preds = %45, %42
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 1
br i1 %51, label %63, label %52
52: ; preds = %49
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, 2
br i1 %54, label %63, label %55
55: ; preds = %52
%56 = load i32, i32* %8
%57 = icmp eq i32 %56, 4
br i1 %57, label %63, label %58
58: ; preds = %55
%59 = load i32, i32* %8
%60 = icmp eq i32 %59, 8
br i1 %60, label %63, label %61
61: ; preds = %58
store i32 -8, i32* %11
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61, %58, %55, %52, %49
%64 = load i32, i32* %11
ret i32 %64
}

LLVM IR (-O2):
@.str = [33 x i8] c"Image Size Not Valid w=%d h=%d\0A\00"
@str = [34 x i8] c"Image Not a valid byte Aligment \00"
@str.4 = [23 x i8] c"Image Not a valid type\00"
@str.5 = [25 x i8] c"Image Not a valid format\00"
define i32 @_glipCheckImageParam(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %0, 1
%7 = icmp slt i32 %1, 1
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %11
11: ; preds = %5, %9
%12 = phi i32 [ 0, %9 ], [ 1, %5 ]
%13 = add i32 %3, -32994
%14 = icmp ult i32 %13, -26594
%15 = add i32 %3, -6410
%16 = icmp ult i32 %15, 26582
%17 = or i1 %14, %16
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%20 = or i32 %12, -2
br label %21
21: ; preds = %11, %18
%22 = phi i32 [ %20, %18 ], [ %12, %11 ]
%23 = add i32 %4, -5127
%24 = icmp ult i32 %23, -7
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
%27 = add nsw i32 %22, -4
br label %28
28: ; preds = %21, %25
%29 = phi i32 [ %27, %25 ], [ %22, %21 ]
switch i32 %2, label %30 [
i32 8, label %32
i32 4, label %32
i32 2, label %32
i32 1, label %32
]
30: ; preds = %28
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %28, %28, %28, %28, %30
%33 = phi i32 [ %29, %28 ], [ -8, %30 ], [ %29, %28 ], [ %29, %28 ], [ %29, %28 ]
ret i32 %33
}