#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 sxbp_change_direction(int, int);
bool test_sxbp_change_direction(void) {
  if (sxbp_change_direction(0, 1) != 1) {
    return false;
  } else if (sxbp_change_direction(0, -1) != 3) {
    return false;
  } else if (sxbp_change_direction(3, 1) != 0) {
    return false;
  } else if (sxbp_change_direction(3, -1) != 2) {
    return false;
  } else if (sxbp_change_direction(2, 1) != 3) {
    return false;
  } else if (sxbp_change_direction(1, -1) != 0) {
    return false;
  } else {
    return true;
  }
}


x86 assembly (clang, -O0):
<test_sxbp_change_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x1,%eax
je     1139 <test_sxbp_change_direction+0x29>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
xor    %edi,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x3,%eax
je     115a <test_sxbp_change_direction+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x0,%eax
je     117e <test_sxbp_change_direction+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x2,%eax
je     11a2 <test_sxbp_change_direction+0x92>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x3,%eax
je     11c6 <test_sxbp_change_direction+0xb6>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x0,%eax
je     11ea <test_sxbp_change_direction+0xda>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <test_sxbp_change_direction+0xe1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sxbp_change_direction>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x1,%eax
jne    1188 <test_sxbp_change_direction+0x78>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x3,%eax
jne    1188 <test_sxbp_change_direction+0x78>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
test   %eax,%eax
jne    1188 <test_sxbp_change_direction+0x78>
mov    $0x3,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x2,%eax
jne    1188 <test_sxbp_change_direction+0x78>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <sxbp_change_direction@plt>
cmp    $0x3,%eax
jne    1188 <test_sxbp_change_direction+0x78>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <sxbp_change_direction@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @test_sxbp_change_direction() {
%1 = alloca i32
%2 = call i32 @sxbp_change_direction(i32 0, i32 1)
%3 = icmp ne i32 %2, 1
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 0, i32* %1
br label %26
5: ; preds = %0
%6 = call i32 @sxbp_change_direction(i32 0, i32 -1)
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 0, i32* %1
br label %26
9: ; preds = %5
%10 = call i32 @sxbp_change_direction(i32 3, i32 1)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 0, i32* %1
br label %26
13: ; preds = %9
%14 = call i32 @sxbp_change_direction(i32 3, i32 -1)
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 0, i32* %1
br label %26
17: ; preds = %13
%18 = call i32 @sxbp_change_direction(i32 2, i32 1)
%19 = icmp ne i32 %18, 3
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 0, i32* %1
br label %26
21: ; preds = %17
%22 = call i32 @sxbp_change_direction(i32 1, i32 -1)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %1
br label %26
25: ; preds = %21
store i32 1, i32* %1
br label %26
26: ; preds = %25, %24, %20, %16, %12, %8, %4
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
define i32 @test_sxbp_change_direction() {
%1 = tail call i32 @sxbp_change_direction(i32 0, i32 1)
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %19
3: ; preds = %0
%4 = tail call i32 @sxbp_change_direction(i32 0, i32 -1)
%5 = icmp eq i32 %4, 3
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = tail call i32 @sxbp_change_direction(i32 3, i32 1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = tail call i32 @sxbp_change_direction(i32 3, i32 -1)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = tail call i32 @sxbp_change_direction(i32 2, i32 1)
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @sxbp_change_direction(i32 1, i32 -1)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %9, %6, %3, %0
%20 = phi i32 [ 0, %0 ], [ 0, %3 ], [ 0, %6 ], [ 0, %9 ], [ 0, %12 ], [ %18, %15 ]
ret i32 %20
}