#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 get_opposite_direction_bit(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int test_get_opposite_direction_bit() {
  int ret = 0;
  char *res;
  printf("\ntest_get_opposite_direction_bit\n");
  printf("-------------------------------\n");
  printf("%s: Test North\n",
         res = (get_opposite_direction_bit(0x04) == 0x10 ? "Ok" : "Ko"));
  ret |= strcmp(res, "Ko") == 0;
  printf("%s: Test South\n",
         res = (get_opposite_direction_bit(0x10) == 0x04 ? "Ok" : "Ko"));
  ret |= strcmp(res, "Ko") == 0;
  printf("%s: Test East\n",
         res = (get_opposite_direction_bit(0x08) == 0x20 ? "Ok" : "Ko"));
  ret |= strcmp(res, "Ko") == 0;
  printf("%s: Test West\n",
         res = (get_opposite_direction_bit(0x20) == 0x08 ? "Ok" : "Ko"));
  ret |= strcmp(res, "Ko") == 0;
  printf("%s: Test Unknown\n",
         res = (get_opposite_direction_bit(12) == -1 ? "Ok" : "Ko"));
  ret |= strcmp(res, "Ko") == 0;
  return ret;
}


x86 assembly (clang, -O0):
<test_get_opposite_direction_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <get_opposite_direction_bit@plt>
mov    %eax,%ecx
lea    0xee8(%rip),%rsi
lea    0xede(%rip),%rax
cmp    $0x10,%ecx
cmove  %rax,%rsi
mov    %rsi,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x10,%edi
call   1050 <get_opposite_direction_bit@plt>
mov    %eax,%ecx
lea    0xe93(%rip),%rsi
lea    0xe89(%rip),%rax
cmp    $0x4,%ecx
cmove  %rax,%rsi
mov    %rsi,-0x10(%rbp)
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x8,%edi
call   1050 <get_opposite_direction_bit@plt>
mov    %eax,%ecx
lea    0xe3e(%rip),%rsi
lea    0xe34(%rip),%rax
cmp    $0x20,%ecx
cmove  %rax,%rsi
mov    %rsi,-0x10(%rbp)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x20,%edi
call   1050 <get_opposite_direction_bit@plt>
mov    %eax,%ecx
lea    0xde9(%rip),%rsi
lea    0xddf(%rip),%rax
cmp    $0x8,%ecx
cmove  %rax,%rsi
mov    %rsi,-0x10(%rbp)
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0xc,%edi
call   1050 <get_opposite_direction_bit@plt>
mov    %eax,%ecx
lea    0xd94(%rip),%rsi
lea    0xd8a(%rip),%rax
cmp    $0xffffffff,%ecx
cmove  %rax,%rsi
mov    %rsi,-0x10(%rbp)
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_opposite_direction_bit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1060 <get_opposite_direction_bit@plt>
cmp    $0x10,%eax
lea    0xe9c(%rip),%r15
lea    0xe98(%rip),%r14
mov    %r14,%rbx
cmove  %r15,%rbx
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %r12b
mov    $0x10,%edi
call   1060 <get_opposite_direction_bit@plt>
cmp    $0x4,%eax
mov    %r14,%rbx
cmove  %r15,%rbx
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %bpl
or     %r12b,%bpl
mov    $0x8,%edi
call   1060 <get_opposite_direction_bit@plt>
cmp    $0x20,%eax
mov    %r14,%rbx
cmove  %r15,%rbx
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %r12b
mov    $0x20,%edi
call   1060 <get_opposite_direction_bit@plt>
cmp    $0x8,%eax
mov    %r14,%rbx
cmove  %r15,%rbx
lea    0xe04(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %bl
or     %r12b,%bl
or     %bpl,%bl
mov    $0xc,%edi
call   1060 <get_opposite_direction_bit@plt>
cmp    $0xffffffff,%eax
cmovne %r14,%r15
lea    0xdda(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
sete   %al
or     %bl,%al
movzbl %al,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0Atest_get_opposite_direction_bit\0A\00"
@.str.1 = [33 x i8] c"-------------------------------\0A\00"
@.str.2 = [16 x i8] c"%s: Test North\0A\00"
@.str.3 = [3 x i8] c"Ok\00"
@.str.4 = [3 x i8] c"Ko\00"
@.str.5 = [16 x i8] c"%s: Test South\0A\00"
@.str.6 = [15 x i8] c"%s: Test East\0A\00"
@.str.7 = [15 x i8] c"%s: Test West\0A\00"
@.str.8 = [18 x i8] c"%s: Test Unknown\0A\00"
define i32 @test_get_opposite_direction_bit() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @get_opposite_direction_bit(i32 4)
%6 = icmp eq i32 %5, 16
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
store i8* %8, i8** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = load i32, i32* %1
%15 = or i32 %14, %13
store i32 %15, i32* %1
%16 = call i32 @get_opposite_direction_bit(i32 16)
%17 = icmp eq i32 %16, 4
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
store i8* %19, i8** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %2
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = load i32, i32* %1
%26 = or i32 %25, %24
store i32 %26, i32* %1
%27 = call i32 @get_opposite_direction_bit(i32 8)
%28 = icmp eq i32 %27, 32
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
store i8* %30, i8** %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %2
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = load i32, i32* %1
%37 = or i32 %36, %35
store i32 %37, i32* %1
%38 = call i32 @get_opposite_direction_bit(i32 32)
%39 = icmp eq i32 %38, 8
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
store i8* %41, i8** %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %2
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = load i32, i32* %1
%48 = or i32 %47, %46
store i32 %48, i32* %1
%49 = call i32 @get_opposite_direction_bit(i32 12)
%50 = icmp eq i32 %49, -1
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
store i8* %52, i8** %2
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %52)
%54 = load i8*, i8** %2
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
%57 = zext i1 %56 to i32
%58 = load i32, i32* %1
%59 = or i32 %58, %57
store i32 %59, i32* %1
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"%s: Test North\0A\00"
@.str.3 = [3 x i8] c"Ok\00"
@.str.4 = [3 x i8] c"Ko\00"
@.str.5 = [16 x i8] c"%s: Test South\0A\00"
@.str.6 = [15 x i8] c"%s: Test East\0A\00"
@.str.7 = [15 x i8] c"%s: Test West\0A\00"
@.str.8 = [18 x i8] c"%s: Test Unknown\0A\00"
@str = [33 x i8] c"\0Atest_get_opposite_direction_bit\00"
@str.9 = [32 x i8] c"-------------------------------\00"
define i32 @test_get_opposite_direction_bit() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%3 = tail call i32 @get_opposite_direction_bit(i32 4)
%4 = icmp eq i32 %3, 16
%5 = select i1 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = tail call i32 @get_opposite_direction_bit(i32 16)
%10 = icmp eq i32 %9, 4
%11 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%13 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = or i1 %8, %14
%16 = tail call i32 @get_opposite_direction_bit(i32 8)
%17 = icmp eq i32 %16, 32
%18 = select i1 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %18)
%20 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = or i1 %15, %21
%23 = tail call i32 @get_opposite_direction_bit(i32 32)
%24 = icmp eq i32 %23, 8
%25 = select i1 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %25)
%27 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = or i1 %22, %28
%30 = tail call i32 @get_opposite_direction_bit(i32 12)
%31 = icmp eq i32 %30, -1
%32 = select i1 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %32)
%34 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
%36 = or i1 %29, %35
%37 = zext i1 %36 to i32
ret i32 %37
}