#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 */
scalar_t__ _set_output_state(int, int, int, int, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int NXT_PivotTurn(int power) {
  int ret = 0;
  ret += _set_output_state(0x01, ((-power & 0xF0) + (-power & 0x0F)), 0x07,
                           0x00, 0x00, 0x20, 0x00);
  ret += _set_output_state(0x02, ((power & 0xF0) + (power & 0x0F)), 0x07, 0x00,
                           0x00, 0x20, 0x00);
  if (ret < 0) {
    fprintf(stderr, "_set_output_state Failed\n");
    return -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<NXT_PivotTurn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %esi,%esi
sub    -0x8(%rbp),%esi
and    $0xf0,%esi
xor    %eax,%eax
sub    -0x8(%rbp),%eax
and    $0xf,%eax
add    %eax,%esi
mov    $0x1,%edi
mov    $0x7,%edx
xor    %r8d,%r8d
mov    $0x20,%r9d
mov    %r8d,%ecx
movl   $0x0,(%rsp)
call   1030 <_set_output_state@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
and    $0xf0,%esi
mov    -0x8(%rbp),%eax
and    $0xf,%eax
add    %eax,%esi
mov    $0x2,%edi
mov    $0x7,%edx
xor    %r8d,%r8d
mov    $0x20,%r9d
mov    %r8d,%ecx
movl   $0x0,(%rsp)
call   1030 <_set_output_state@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11e1 <NXT_PivotTurn+0xc1>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <NXT_PivotTurn+0xc7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NXT_PivotTurn>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
neg    %eax
movzbl %al,%esi
movl   $0x0,(%rsp)
mov    $0x1,%edi
mov    $0x7,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0x20,%r9d
call   1030 <_set_output_state@plt>
mov    %rax,%r14
movzbl %bl,%esi
movl   $0x0,(%rsp)
mov    $0x2,%edi
mov    $0x7,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0x20,%r9d
call   1030 <_set_output_state@plt>
add    %r14d,%eax
jns    1194 <NXT_PivotTurn+0x74>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"_set_output_state Failed\0A\00"
define i32 @NXT_PivotTurn(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %3
%6 = sub nsw i32 0, %5
%7 = and i32 %6, 240
%8 = load i32, i32* %3
%9 = sub nsw i32 0, %8
%10 = and i32 %9, 15
%11 = add nsw i32 %7, %10
%12 = call i64 @_set_output_state(i32 1, i32 %11, i32 7, i32 0, i32 0, i32 32, i32 0)
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = and i32 %17, 240
%19 = load i32, i32* %3
%20 = and i32 %19, 15
%21 = add nsw i32 %18, %20
%22 = call i64 @_set_output_state(i32 2, i32 %21, i32 7, i32 0, i32 0, i32 32, i32 0)
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = add nsw i64 %24, %22
%26 = trunc i64 %25 to i32
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %1
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %34
32: ; preds = %1
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"_set_output_state Failed\0A\00"
define i32 @NXT_PivotTurn(i32 %0) {
%2 = sub nsw i32 0, %0
%3 = and i32 %2, 255
%4 = tail call i64 @_set_output_state(i32 1, i32 %3, i32 7, i32 0, i32 0, i32 32, i32 0)
%5 = and i32 %0, 255
%6 = tail call i64 @_set_output_state(i32 2, i32 %5, i32 7, i32 0, i32 0, i32 32, i32 0)
%7 = add i64 %6, %4
%8 = trunc i64 %7 to i32
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %1, %10
%14 = phi i32 [ -1, %10 ], [ %8, %1 ]
ret i32 %14
}