#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 checkPos(int pos1, int pos2) {
  int flag = 0;
  if (pos1 > 3 || pos1 < 0) {
    printf("\n***ERROR Pos1 out of bounds\n");
    flag = 1;
  }
  if (pos2 > 3 || pos2 < 0) {
    printf("\n***ERROR Pos2 out of bounds\n");
    flag = 1;
  }
  if (pos1 == pos2) {
    printf(
        "\n***ERROR If Pos1 and Pos2 are the same no encryption takes place\n");
    flag = 1;
  }
  return flag;
}


x86 assembly (clang, -O0):
<checkPos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0x4(%rbp)
jg     1139 <checkPos+0x29>
cmpl   $0x0,-0x4(%rbp)
jge    114c <checkPos+0x3c>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     1160 <checkPos+0x50>
cmpl   $0x0,-0x8(%rbp)
jge    1173 <checkPos+0x63>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1192 <checkPos+0x82>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPos>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
cmp    $0x4,%edi
jae    113f <checkPos+0x2f>
cmp    $0x4,%ebx
jae    1155 <checkPos+0x45>
cmp    %ebx,%ebp
jne    1138 <checkPos+0x28>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xf19(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
cmp    $0x4,%ebx
jb     1123 <checkPos+0x13>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
cmp    %ebx,%ebp
je     1127 <checkPos+0x17>
jmp    1138 <checkPos+0x28>

LLVM IR (-O0):
@.str = [30 x i8] c"\0A***ERROR Pos1 out of bounds\0A\00"
@.str.1 = [30 x i8] c"\0A***ERROR Pos2 out of bounds\0A\00"
@.str.2 = [67 x i8] c"\0A***ERROR If Pos1 and Pos2 are the same no encryption takes place\0A\00"
define i32 @checkPos(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %2
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 3
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16, %13
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %21
21: ; preds = %19, %16
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
@str = [66 x i8] c"\0A***ERROR If Pos1 and Pos2 are the same no encryption takes place\00"
@str.3 = [29 x i8] c"\0A***ERROR Pos2 out of bounds\00"
@str.4 = [29 x i8] c"\0A***ERROR Pos1 out of bounds\00"
define i32 @checkPos(i32 %0, i32 %1) {
%3 = icmp ugt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
br label %6
6: ; preds = %2, %4
%7 = phi i32 [ 1, %4 ], [ 0, %2 ]
%8 = icmp ugt i32 %1, 3
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
br label %11
11: ; preds = %6, %9
%12 = phi i32 [ 1, %9 ], [ %7, %6 ]
%13 = icmp eq i32 %0, %1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ 1, %14 ], [ %12, %11 ]
ret i32 %17
}