#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 */
struct queue {
  int dummy;
};
struct arrayStack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ DeQueue(struct queue *);
int /*<<< orphan*/ EnQueue(struct queue *, int);
struct queue *createQueue(int);
int /*<<< orphan*/ isEmpty(struct queue *);
int /*<<< orphan*/ isStackEmpty(struct arrayStack *);
int pop(struct arrayStack *);
int /*<<< orphan*/ push(struct arrayStack *, int /*<<< orphan*/);
int checkStackPairOrder(struct arrayStack *S) {
  int flag = 1;
  struct queue *Q = createQueue(15);
  while (!isStackEmpty(S)) {
    EnQueue(Q, pop(S));
  }
  while (!isEmpty(Q)) {
    push(S, DeQueue(Q));
  }
  while (!isStackEmpty(S)) {
    int a = pop(S);
    EnQueue(Q, a);
    if (!isStackEmpty(S)) {
      int b = pop(S);
      EnQueue(Q, b);
      if (a - b != 1 || a - b != -1) {
        flag = 0;
        break;
      }
    }
  }
  while (!isEmpty(Q)) {
    push(S, DeQueue(Q));
  }
  return flag;
}


x86 assembly (clang, -O0):
<checkStackPairOrder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0xf,%edi
call   1030 <createQueue@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <isStackEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11af <checkStackPairOrder+0x3f>
jmp    11d0 <checkStackPairOrder+0x60>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <pop@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
jmp    1191 <checkStackPairOrder+0x21>
jmp    11d5 <checkStackPairOrder+0x65>
mov    -0x18(%rbp),%rdi
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f3 <checkStackPairOrder+0x83>
jmp    1214 <checkStackPairOrder+0xa4>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <DeQueue@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1080 <push@plt>
jmp    11d5 <checkStackPairOrder+0x65>
jmp    1219 <checkStackPairOrder+0xa9>
mov    -0x8(%rbp),%rdi
call   1090 <isStackEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1237 <checkStackPairOrder+0xc7>
jmp    12ad <checkStackPairOrder+0x13d>
mov    -0x8(%rbp),%rdi
call   1060 <pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <EnQueue@plt>
mov    -0x8(%rbp),%rdi
call   1090 <isStackEmpty@plt>
cmp    $0x0,%eax
jne    12a8 <checkStackPairOrder+0x138>
mov    -0x8(%rbp),%rdi
call   1060 <pop@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <EnQueue@plt>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
cmp    $0x1,%eax
jne    1297 <checkStackPairOrder+0x127>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
cmp    $0xffffffff,%eax
je     12a3 <checkStackPairOrder+0x133>
movl   $0x0,-0xc(%rbp)
jmp    12ad <checkStackPairOrder+0x13d>
jmp    12a8 <checkStackPairOrder+0x138>
jmp    1219 <checkStackPairOrder+0xa9>
jmp    12b2 <checkStackPairOrder+0x142>
mov    -0x18(%rbp),%rdi
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d0 <checkStackPairOrder+0x160>
jmp    12f1 <checkStackPairOrder+0x181>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <DeQueue@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1080 <push@plt>
jmp    12b2 <checkStackPairOrder+0x142>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkStackPairOrder>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0xf,%edi
call   1030 <createQueue@plt>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1090 <isStackEmpty@plt>
test   %eax,%eax
jne    11c2 <checkStackPairOrder+0x52>
mov    %rbx,%rdi
call   1060 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
jmp    1190 <checkStackPairOrder+0x20>
mov    %r14,%rdi
call   1050 <DeQueue@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <push@plt>
mov    %r14,%rdi
call   1070 <isEmpty@plt>
test   %eax,%eax
je     11b0 <checkStackPairOrder+0x40>
jmp    11ee <checkStackPairOrder+0x7e>
mov    %rbx,%rdi
call   1060 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
mov    %rbx,%rdi
call   1090 <isStackEmpty@plt>
test   %eax,%eax
je     1201 <checkStackPairOrder+0x91>
mov    %rbx,%rdi
call   1090 <isStackEmpty@plt>
test   %eax,%eax
je     11d0 <checkStackPairOrder+0x60>
mov    $0x1,%ebp
jmp    1232 <checkStackPairOrder+0xc2>
mov    %rbx,%rdi
call   1060 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
xor    %ebp,%ebp
jmp    1232 <checkStackPairOrder+0xc2>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <DeQueue@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <push@plt>
mov    %r14,%rdi
call   1070 <isEmpty@plt>
test   %eax,%eax
je     1220 <checkStackPairOrder+0xb0>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.arrayStack = type { i32 }
%struct.queue = type { i32 }
define i32 @checkStackPairOrder(%struct.arrayStack* %0) {
%2 = alloca %struct.arrayStack*
%3 = alloca i32
%4 = alloca %struct.queue*
%5 = alloca i32
%6 = alloca i32
store %struct.arrayStack* %0, %struct.arrayStack** %2
store i32 1, i32* %3
%7 = call %struct.queue* @createQueue(i32 15)
store %struct.queue* %7, %struct.queue** %4
br label %8
8: ; preds = %13, %1
%9 = load %struct.arrayStack*, %struct.arrayStack** %2
%10 = call i32 @isStackEmpty(%struct.arrayStack* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load %struct.queue*, %struct.queue** %4
%15 = load %struct.arrayStack*, %struct.arrayStack** %2
%16 = call i32 @pop(%struct.arrayStack* %15)
%17 = call i32 @EnQueue(%struct.queue* %14, i32 %16)
br label %8
18: ; preds = %8
br label %19
19: ; preds = %24, %18
%20 = load %struct.queue*, %struct.queue** %4
%21 = call i32 @isEmpty(%struct.queue* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load %struct.arrayStack*, %struct.arrayStack** %2
%26 = load %struct.queue*, %struct.queue** %4
%27 = call i32 @DeQueue(%struct.queue* %26)
%28 = call i32 @push(%struct.arrayStack* %25, i32 %27)
br label %19
29: ; preds = %19
br label %30
30: ; preds = %61, %29
%31 = load %struct.arrayStack*, %struct.arrayStack** %2
%32 = call i32 @isStackEmpty(%struct.arrayStack* %31)
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
br i1 %34, label %35, label %62
35: ; preds = %30
%36 = load %struct.arrayStack*, %struct.arrayStack** %2
%37 = call i32 @pop(%struct.arrayStack* %36)
store i32 %37, i32* %5
%38 = load %struct.queue*, %struct.queue** %4
%39 = load i32, i32* %5
%40 = call i32 @EnQueue(%struct.queue* %38, i32 %39)
%41 = load %struct.arrayStack*, %struct.arrayStack** %2
%42 = call i32 @isStackEmpty(%struct.arrayStack* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %61, label %44
44: ; preds = %35
%45 = load %struct.arrayStack*, %struct.arrayStack** %2
%46 = call i32 @pop(%struct.arrayStack* %45)
store i32 %46, i32* %6
%47 = load %struct.queue*, %struct.queue** %4
%48 = load i32, i32* %6
%49 = call i32 @EnQueue(%struct.queue* %47, i32 %48)
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = sub nsw i32 %50, %51
%53 = icmp ne i32 %52, 1
br i1 %53, label %59, label %54
54: ; preds = %44
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = sub nsw i32 %55, %56
%58 = icmp ne i32 %57, -1
br i1 %58, label %59, label %60
59: ; preds = %54, %44
store i32 0, i32* %3
br label %62
60: ; preds = %54
br label %61
61: ; preds = %60, %35
br label %30
62: ; preds = %59, %30
br label %63
63: ; preds = %68, %62
%64 = load %struct.queue*, %struct.queue** %4
%65 = call i32 @isEmpty(%struct.queue* %64)
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = load %struct.arrayStack*, %struct.arrayStack** %2
%70 = load %struct.queue*, %struct.queue** %4
%71 = call i32 @DeQueue(%struct.queue* %70)
%72 = call i32 @push(%struct.arrayStack* %69, i32 %71)
br label %63
73: ; preds = %63
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
%struct.arrayStack = type { i32 }
%struct.queue = type { i32 }
define i32 @checkStackPairOrder(%struct.arrayStack* %0) {
%2 = tail call %struct.queue* @createQueue(i32 15)
%3 = tail call i32 @isStackEmpty(%struct.arrayStack* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %8, %1
%6 = tail call i32 @isEmpty(%struct.queue* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %18
8: ; preds = %1, %8
%9 = tail call i32 @pop(%struct.arrayStack* %0)
%10 = tail call i32 @EnQueue(%struct.queue* %2, i32 %9)
%11 = tail call i32 @isStackEmpty(%struct.arrayStack* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %8, label %5
13: ; preds = %5, %13
%14 = tail call i32 @DeQueue(%struct.queue* %2)
%15 = tail call i32 @push(%struct.arrayStack* %0, i32 %14)
%16 = tail call i32 @isEmpty(%struct.queue* %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %13, label %18
18: ; preds = %13, %5
br label %19
19: ; preds = %18, %22
%20 = tail call i32 @isStackEmpty(%struct.arrayStack* %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = tail call i32 @pop(%struct.arrayStack* %0)
%24 = tail call i32 @EnQueue(%struct.queue* %2, i32 %23)
%25 = tail call i32 @isStackEmpty(%struct.arrayStack* %0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %19
27: ; preds = %22
%28 = tail call i32 @pop(%struct.arrayStack* %0)
%29 = tail call i32 @EnQueue(%struct.queue* %2, i32 %28)
br label %30
30: ; preds = %19, %27
%31 = phi i32 [ 0, %27 ], [ 1, %19 ]
%32 = tail call i32 @isEmpty(%struct.queue* %2)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30, %34
%35 = tail call i32 @DeQueue(%struct.queue* %2)
%36 = tail call i32 @push(%struct.arrayStack* %0, i32 %35)
%37 = tail call i32 @isEmpty(%struct.queue* %2)
%38 = icmp eq i32 %37, 0
br i1 %38, label %34, label %39
39: ; preds = %34, %30
ret i32 %31
}