#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 Tuple3_Int_Int_Int {
  int dummy;
};

/* Variables and functions */
struct Tuple3_Int_Int_Int *Tuple3_0(int, int, int);
scalar_t__ editable_0(int);
scalar_t__ positiveEdge_0(int, int);
int node_anonymous69880537178160(int curMode, int btnRotate_at_last,
                                 int btnRotate, int curPos,
                                 struct Tuple3_Int_Int_Int **output) {
  int _tmp006;
  struct Tuple3_Int_Int_Int *_tmp005;
  _tmp006 =
      (editable_0(curMode) && positiveEdge_0(btnRotate_at_last, btnRotate));
  if (_tmp006 == 1) {
    struct Tuple3_Int_Int_Int *_tmp007;
    if (curPos == 0) {
      _tmp007 = Tuple3_0(1, 0, 0);
    } else if (curPos == 1) {
      _tmp007 = Tuple3_0(0, 1, 0);
    } else if (curPos == 2) {
      _tmp007 = Tuple3_0(0, 0, 1);
    }
    _tmp005 = _tmp007;
  } else if (_tmp006 == 0) {
    _tmp005 = Tuple3_0(0, 0, 0);
  }
  *output = _tmp005;
  return 1;
}


x86 assembly (clang, -O0):
<node_anonymous69880537178160>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <editable_0@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x31(%rbp)
je     1177 <node_anonymous69880537178160+0x47>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <positiveEdge_0@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1201 <node_anonymous69880537178160+0xd1>
cmpl   $0x0,-0x10(%rbp)
jne    11ad <node_anonymous69880537178160+0x7d>
mov    $0x1,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Tuple3_0@plt>
mov    %rax,-0x30(%rbp)
jmp    11f4 <node_anonymous69880537178160+0xc4>
cmpl   $0x1,-0x10(%rbp)
jne    11ce <node_anonymous69880537178160+0x9e>
xor    %edx,%edx
mov    $0x1,%esi
mov    %edx,%edi
call   1050 <Tuple3_0@plt>
mov    %rax,-0x30(%rbp)
jmp    11ef <node_anonymous69880537178160+0xbf>
cmpl   $0x2,-0x10(%rbp)
jne    11ea <node_anonymous69880537178160+0xba>
xor    %esi,%esi
mov    $0x1,%edx
mov    %esi,%edi
call   1050 <Tuple3_0@plt>
mov    %rax,-0x30(%rbp)
jmp    11ef <node_anonymous69880537178160+0xbf>
jmp    11f4 <node_anonymous69880537178160+0xc4>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    121f <node_anonymous69880537178160+0xef>
cmpl   $0x0,-0x1c(%rbp)
jne    121a <node_anonymous69880537178160+0xea>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1050 <Tuple3_0@plt>
mov    %rax,-0x28(%rbp)
jmp    121f <node_anonymous69880537178160+0xef>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<node_anonymous69880537178160>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%ebp
call   1040 <editable_0@plt>
test   %rax,%rax
je     1171 <node_anonymous69880537178160+0x41>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <positiveEdge_0@plt>
test   %rax,%rax
je     1171 <node_anonymous69880537178160+0x41>
cmp    $0x2,%r15d
je     118f <node_anonymous69880537178160+0x5f>
cmp    $0x1,%r15d
je     119a <node_anonymous69880537178160+0x6a>
test   %r15d,%r15d
jne    117c <node_anonymous69880537178160+0x4c>
mov    $0x1,%edi
jmp    1173 <node_anonymous69880537178160+0x43>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Tuple3_0@plt>
mov    %rax,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
jmp    1177 <node_anonymous69880537178160+0x47>
xor    %edi,%edi
mov    $0x1,%esi
jmp    1175 <node_anonymous69880537178160+0x45>

LLVM IR (-O0):
%struct.Tuple3_Int_Int_Int = type { i32 }
define i32 @node_anonymous69880537178160(i32 %0, i32 %1, i32 %2, i32 %3, %struct.Tuple3_Int_Int_Int** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.Tuple3_Int_Int_Int**
%11 = alloca i32
%12 = alloca %struct.Tuple3_Int_Int_Int*
%13 = alloca %struct.Tuple3_Int_Int_Int*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store %struct.Tuple3_Int_Int_Int** %4, %struct.Tuple3_Int_Int_Int*** %10
%14 = load i32, i32* %6
%15 = call i64 @editable_0(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %5
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = call i64 @positiveEdge_0(i32 %18, i32 %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %17, %5
%23 = phi i1 [ false, %5 ], [ %21, %17 ]
%24 = zext i1 %23 to i32
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %46
27: ; preds = %22
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 1, i32 0, i32 0)
store %struct.Tuple3_Int_Int_Int* %31, %struct.Tuple3_Int_Int_Int** %13
br label %44
32: ; preds = %27
%33 = load i32, i32* %9
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 1, i32 0)
store %struct.Tuple3_Int_Int_Int* %36, %struct.Tuple3_Int_Int_Int** %13
br label %43
37: ; preds = %32
%38 = load i32, i32* %9
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 0, i32 1)
store %struct.Tuple3_Int_Int_Int* %41, %struct.Tuple3_Int_Int_Int** %13
br label %42
42: ; preds = %40, %37
br label %43
43: ; preds = %42, %35
br label %44
44: ; preds = %43, %30
%45 = load %struct.Tuple3_Int_Int_Int*, %struct.Tuple3_Int_Int_Int** %13
store %struct.Tuple3_Int_Int_Int* %45, %struct.Tuple3_Int_Int_Int** %12
br label %52
46: ; preds = %22
%47 = load i32, i32* %11
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 0, i32 0)
store %struct.Tuple3_Int_Int_Int* %50, %struct.Tuple3_Int_Int_Int** %12
br label %51
51: ; preds = %49, %46
br label %52
52: ; preds = %51, %44
%53 = load %struct.Tuple3_Int_Int_Int*, %struct.Tuple3_Int_Int_Int** %12
%54 = load %struct.Tuple3_Int_Int_Int**, %struct.Tuple3_Int_Int_Int*** %10
store %struct.Tuple3_Int_Int_Int* %53, %struct.Tuple3_Int_Int_Int** %54
ret i32 1
}

LLVM IR (-O2):
%struct.Tuple3_Int_Int_Int = type { i32 }
define i32 @node_anonymous69880537178160(i32 %0, i32 %1, i32 %2, i32 %3, %struct.Tuple3_Int_Int_Int** nocapture writeonly %4) {
%6 = tail call i64 @editable_0(i32 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = tail call i64 @positiveEdge_0(i32 %1, i32 %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
switch i32 %3, label %20 [
i32 0, label %12
i32 1, label %14
i32 2, label %16
]
12: ; preds = %11
%13 = tail call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 1, i32 0, i32 0)
br label %20
14: ; preds = %11
%15 = tail call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 1, i32 0)
br label %20
16: ; preds = %11
%17 = tail call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 0, i32 1)
br label %20
18: ; preds = %5, %8
%19 = tail call %struct.Tuple3_Int_Int_Int* @Tuple3_0(i32 0, i32 0, i32 0)
br label %20
20: ; preds = %12, %16, %14, %11, %18
%21 = phi %struct.Tuple3_Int_Int_Int* [ %19, %18 ], [ %13, %12 ], [ %15, %14 ], [ %17, %16 ], [ undef, %11 ]
store %struct.Tuple3_Int_Int_Int* %21, %struct.Tuple3_Int_Int_Int** %4
ret i32 1
}