#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 /*<<< orphan*/ downArm(int);
int /*<<< orphan*/ maxMotorSin(int);
int /*<<< orphan*/ minMotorSin(int);
int /*<<< orphan*/ riseArm(int);
int /*<<< orphan*/ setAllTorques(int);
int /*<<< orphan*/ setMotorPosition(int, int /*<<< orphan*/);
int /*<<< orphan*/ wait();
void turnRightSpider(int torque) {
  int i = 4;
  setAllTorques(torque);
  while (i--) {
    downArm(1);
    downArm(2);
    downArm(5);
    wait();
    riseArm(0);
    riseArm(3);
    riseArm(4);
    setMotorPosition(1, minMotorSin(1));
    setMotorPosition(8, maxMotorSin(8));
    setMotorPosition(13, maxMotorSin(13));
    setMotorPosition(2, minMotorSin(2));
    setMotorPosition(7, minMotorSin(7));
    setMotorPosition(14, minMotorSin(14));
    wait();
    downArm(0);
    downArm(3);
    downArm(4);
    wait();
    riseArm(1);
    riseArm(2);
    riseArm(5);
    setMotorPosition(1, maxMotorSin(1));
    setMotorPosition(8, minMotorSin(8));
    setMotorPosition(13, minMotorSin(13));
    setMotorPosition(2, maxMotorSin(2));
    setMotorPosition(7, maxMotorSin(7));
    setMotorPosition(14, maxMotorSin(14));
    wait();
  }
}


x86 assembly (clang, -O0):
<turnRightSpider>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <setAllTorques@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1339 <turnRightSpider+0x1c9>
mov    $0x1,%edi
call   1040 <downArm@plt>
mov    $0x2,%edi
call   1040 <downArm@plt>
mov    $0x5,%edi
call   1040 <downArm@plt>
mov    $0x0,%al
call   1090 <wait@plt>
xor    %edi,%edi
call   1030 <riseArm@plt>
mov    $0x3,%edi
call   1030 <riseArm@plt>
mov    $0x4,%edi
call   1030 <riseArm@plt>
mov    $0x1,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0x1,%edi
call   1050 <setMotorPosition@plt>
mov    $0x8,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0x8,%edi
call   1050 <setMotorPosition@plt>
mov    $0xd,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0xd,%edi
call   1050 <setMotorPosition@plt>
mov    $0x2,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0x2,%edi
call   1050 <setMotorPosition@plt>
mov    $0x7,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0x7,%edi
call   1050 <setMotorPosition@plt>
mov    $0xe,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0xe,%edi
call   1050 <setMotorPosition@plt>
mov    $0x0,%al
call   1090 <wait@plt>
xor    %edi,%edi
call   1040 <downArm@plt>
mov    $0x3,%edi
call   1040 <downArm@plt>
mov    $0x4,%edi
call   1040 <downArm@plt>
mov    $0x0,%al
call   1090 <wait@plt>
mov    $0x1,%edi
call   1030 <riseArm@plt>
mov    $0x2,%edi
call   1030 <riseArm@plt>
mov    $0x5,%edi
call   1030 <riseArm@plt>
mov    $0x1,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0x1,%edi
call   1050 <setMotorPosition@plt>
mov    $0x8,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0x8,%edi
call   1050 <setMotorPosition@plt>
mov    $0xd,%edi
call   1070 <minMotorSin@plt>
mov    %eax,%esi
mov    $0xd,%edi
call   1050 <setMotorPosition@plt>
mov    $0x2,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0x2,%edi
call   1050 <setMotorPosition@plt>
mov    $0x7,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0x7,%edi
call   1050 <setMotorPosition@plt>
mov    $0xe,%edi
call   1060 <maxMotorSin@plt>
mov    %eax,%esi
mov    $0xe,%edi
call   1050 <setMotorPosition@plt>
mov    $0x0,%al
call   1090 <wait@plt>
jmp    118a <turnRightSpider+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turnRightSpider>:
push   %rbx
call   1080 <setAllTorques@plt>
mov    $0xfffffffc,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <downArm@plt>
mov    $0x2,%edi
call   1040 <downArm@plt>
mov    $0x5,%edi
call   1040 <downArm@plt>
xor    %eax,%eax
call   1090 <wait@plt>
xor    %edi,%edi
call   1030 <riseArm@plt>
mov    $0x3,%edi
call   1030 <riseArm@plt>
mov    $0x4,%edi
call   1030 <riseArm@plt>
mov    $0x1,%edi
call   1070 <minMotorSin@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x8,%edi
call   1060 <maxMotorSin@plt>
mov    $0x8,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0xd,%edi
call   1060 <maxMotorSin@plt>
mov    $0xd,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x2,%edi
call   1070 <minMotorSin@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x7,%edi
call   1070 <minMotorSin@plt>
mov    $0x7,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0xe,%edi
call   1070 <minMotorSin@plt>
mov    $0xe,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
xor    %eax,%eax
call   1090 <wait@plt>
xor    %edi,%edi
call   1040 <downArm@plt>
mov    $0x3,%edi
call   1040 <downArm@plt>
mov    $0x4,%edi
call   1040 <downArm@plt>
xor    %eax,%eax
call   1090 <wait@plt>
mov    $0x1,%edi
call   1030 <riseArm@plt>
mov    $0x2,%edi
call   1030 <riseArm@plt>
mov    $0x5,%edi
call   1030 <riseArm@plt>
mov    $0x1,%edi
call   1060 <maxMotorSin@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x8,%edi
call   1070 <minMotorSin@plt>
mov    $0x8,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0xd,%edi
call   1070 <minMotorSin@plt>
mov    $0xd,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x2,%edi
call   1060 <maxMotorSin@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0x7,%edi
call   1060 <maxMotorSin@plt>
mov    $0x7,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
mov    $0xe,%edi
call   1060 <maxMotorSin@plt>
mov    $0xe,%edi
mov    %eax,%esi
call   1050 <setMotorPosition@plt>
xor    %eax,%eax
call   1090 <wait@plt>
inc    %ebx
jne    1180 <turnRightSpider+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @turnRightSpider(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
%4 = load i32, i32* %2
%5 = call i32 @setAllTorques(i32 %4)
br label %6
6: ; preds = %10, %1
%7 = load i32, i32* %3
%8 = add nsw i32 %7, -1
store i32 %8, i32* %3
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %51
10: ; preds = %6
%11 = call i32 @downArm(i32 1)
%12 = call i32 @downArm(i32 2)
%13 = call i32 @downArm(i32 5)
%14 = call i32 (...) @wait()
%15 = call i32 @riseArm(i32 0)
%16 = call i32 @riseArm(i32 3)
%17 = call i32 @riseArm(i32 4)
%18 = call i32 @minMotorSin(i32 1)
%19 = call i32 @setMotorPosition(i32 1, i32 %18)
%20 = call i32 @maxMotorSin(i32 8)
%21 = call i32 @setMotorPosition(i32 8, i32 %20)
%22 = call i32 @maxMotorSin(i32 13)
%23 = call i32 @setMotorPosition(i32 13, i32 %22)
%24 = call i32 @minMotorSin(i32 2)
%25 = call i32 @setMotorPosition(i32 2, i32 %24)
%26 = call i32 @minMotorSin(i32 7)
%27 = call i32 @setMotorPosition(i32 7, i32 %26)
%28 = call i32 @minMotorSin(i32 14)
%29 = call i32 @setMotorPosition(i32 14, i32 %28)
%30 = call i32 (...) @wait()
%31 = call i32 @downArm(i32 0)
%32 = call i32 @downArm(i32 3)
%33 = call i32 @downArm(i32 4)
%34 = call i32 (...) @wait()
%35 = call i32 @riseArm(i32 1)
%36 = call i32 @riseArm(i32 2)
%37 = call i32 @riseArm(i32 5)
%38 = call i32 @maxMotorSin(i32 1)
%39 = call i32 @setMotorPosition(i32 1, i32 %38)
%40 = call i32 @minMotorSin(i32 8)
%41 = call i32 @setMotorPosition(i32 8, i32 %40)
%42 = call i32 @minMotorSin(i32 13)
%43 = call i32 @setMotorPosition(i32 13, i32 %42)
%44 = call i32 @maxMotorSin(i32 2)
%45 = call i32 @setMotorPosition(i32 2, i32 %44)
%46 = call i32 @maxMotorSin(i32 7)
%47 = call i32 @setMotorPosition(i32 7, i32 %46)
%48 = call i32 @maxMotorSin(i32 14)
%49 = call i32 @setMotorPosition(i32 14, i32 %48)
%50 = call i32 (...) @wait()
br label %6
51: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @turnRightSpider(i32 %0) {
%2 = tail call i32 @setAllTorques(i32 %0)
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 4, %1 ], [ %5, %3 ]
%5 = add nsw i32 %4, -1
%6 = tail call i32 @downArm(i32 1)
%7 = tail call i32 @downArm(i32 2)
%8 = tail call i32 @downArm(i32 5)
%9 = tail call i32 (...) @wait()
%10 = tail call i32 @riseArm(i32 0)
%11 = tail call i32 @riseArm(i32 3)
%12 = tail call i32 @riseArm(i32 4)
%13 = tail call i32 @minMotorSin(i32 1)
%14 = tail call i32 @setMotorPosition(i32 1, i32 %13)
%15 = tail call i32 @maxMotorSin(i32 8)
%16 = tail call i32 @setMotorPosition(i32 8, i32 %15)
%17 = tail call i32 @maxMotorSin(i32 13)
%18 = tail call i32 @setMotorPosition(i32 13, i32 %17)
%19 = tail call i32 @minMotorSin(i32 2)
%20 = tail call i32 @setMotorPosition(i32 2, i32 %19)
%21 = tail call i32 @minMotorSin(i32 7)
%22 = tail call i32 @setMotorPosition(i32 7, i32 %21)
%23 = tail call i32 @minMotorSin(i32 14)
%24 = tail call i32 @setMotorPosition(i32 14, i32 %23)
%25 = tail call i32 (...) @wait()
%26 = tail call i32 @downArm(i32 0)
%27 = tail call i32 @downArm(i32 3)
%28 = tail call i32 @downArm(i32 4)
%29 = tail call i32 (...) @wait()
%30 = tail call i32 @riseArm(i32 1)
%31 = tail call i32 @riseArm(i32 2)
%32 = tail call i32 @riseArm(i32 5)
%33 = tail call i32 @maxMotorSin(i32 1)
%34 = tail call i32 @setMotorPosition(i32 1, i32 %33)
%35 = tail call i32 @minMotorSin(i32 8)
%36 = tail call i32 @setMotorPosition(i32 8, i32 %35)
%37 = tail call i32 @minMotorSin(i32 13)
%38 = tail call i32 @setMotorPosition(i32 13, i32 %37)
%39 = tail call i32 @maxMotorSin(i32 2)
%40 = tail call i32 @setMotorPosition(i32 2, i32 %39)
%41 = tail call i32 @maxMotorSin(i32 7)
%42 = tail call i32 @setMotorPosition(i32 7, i32 %41)
%43 = tail call i32 @maxMotorSin(i32 14)
%44 = tail call i32 @setMotorPosition(i32 14, i32 %43)
%45 = tail call i32 (...) @wait()
%46 = icmp eq i32 %5, 0
br i1 %46, label %47, label %3
47: ; preds = %3
ret void
}