#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*/ closeJetduino();
int dynamixelGetRegister(int, int, int);
int /*<<< orphan*/ dynamixelMove(int, int, int);
int /*<<< orphan*/ dynamixelSetRegister(int, int, int, int);
int /*<<< orphan*/ dynamixelStop(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ jet_sleep(int);
int openJetduino();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int dval;
  int i = 0, num = 0, pos = 0, servo = 1;
  int pin = 4;
  if (openJetduino() == -1)
    exit(1);
  printf("setting return status level to 1\n");
  dynamixelSetRegister(servo, 16, 1, 1);
  printf("Move to 0 at fastest speed\n");
  dynamixelMove(servo, 0, 0);
  jet_sleep(1000);
  printf("Move to 1023 slowly\n");
  dynamixelMove(servo, 1023, 200);
  jet_sleep(500);
  printf("stop the servo at its current position.\n");
  dynamixelStop(servo);
  jet_sleep(1000);
  for (i = 0; i < 10; i++) {
    printf("Moving to 1023 at 100.\n");
    dynamixelMove(servo, 1023, 100);
    for (num = 0; num < 20; num++) {
      jet_sleep(100);
      pos = dynamixelGetRegister(servo, 36, 2);
      printf("Pos: %d\n", pos);
    }
    printf("Moving to 10 at 1000.\n");
    dynamixelMove(servo, 10, 1000);
    for (num = 0; num < 20; num++) {
      jet_sleep(100);
      pos = dynamixelGetRegister(servo, 36, 2);
      printf("Pos: %d\n", pos);
    }
  }
  closeJetduino();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x4,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <openJetduino@plt>
cmp    $0xffffffff,%eax
jne    11dc <main+0x4c>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x10,%esi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <dynamixelSetRegister@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <dynamixelMove@plt>
mov    $0x3e8,%edi
call   10b0 <jet_sleep@plt>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x3ff,%esi
mov    $0xc8,%edx
call   1070 <dynamixelMove@plt>
mov    $0x1f4,%edi
call   10b0 <jet_sleep@plt>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1090 <dynamixelStop@plt>
mov    $0x3e8,%edi
call   10b0 <jet_sleep@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    136e <main+0x1de>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0x3ff,%esi
mov    $0x64,%edx
call   1070 <dynamixelMove@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    12ec <main+0x15c>
mov    $0x64,%edi
call   10b0 <jet_sleep@plt>
mov    -0x18(%rbp),%edi
mov    $0x24,%esi
mov    $0x2,%edx
call   1080 <dynamixelGetRegister@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12a4 <main+0x114>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    $0xa,%esi
mov    $0x3e8,%edx
call   1070 <dynamixelMove@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    135b <main+0x1cb>
mov    $0x64,%edi
call   10b0 <jet_sleep@plt>
mov    -0x18(%rbp),%edi
mov    $0x24,%esi
mov    $0x2,%edx
call   1080 <dynamixelGetRegister@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1313 <main+0x183>
jmp    1360 <main+0x1d0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1273 <main+0xe3>
mov    $0x0,%al
call   1060 <closeJetduino@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <openJetduino@plt>
cmp    $0xffffffff,%eax
je     1342 <main+0x1a2>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0x10,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1060 <dynamixelSetRegister@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <dynamixelMove@plt>
mov    $0x3e8,%edi
call   10c0 <jet_sleep@plt>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0x3ff,%esi
mov    $0xc8,%edx
call   1080 <dynamixelMove@plt>
mov    $0x1f4,%edi
call   10c0 <jet_sleep@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <dynamixelStop@plt>
mov    $0x3e8,%edi
call   10c0 <jet_sleep@plt>
lea    0xe2f(%rip),%r14
lea    0xda7(%rip),%rbx
lea    0xe38(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0x3ff,%esi
mov    $0x64,%edx
call   1080 <dynamixelMove@plt>
mov    $0x14,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
call   10c0 <jet_sleep@plt>
mov    $0x1,%edi
mov    $0x24,%esi
mov    $0x2,%edx
call   1090 <dynamixelGetRegister@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    12a0 <main+0x100>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0xa,%esi
mov    $0x3e8,%edx
call   1080 <dynamixelMove@plt>
mov    $0x14,%ebp
mov    $0x64,%edi
call   10c0 <jet_sleep@plt>
mov    $0x1,%edi
mov    $0x24,%esi
mov    $0x2,%edx
call   1090 <dynamixelGetRegister@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    12f0 <main+0x150>
add    $0x1,%r12d
cmp    $0xa,%r12d
jne    1270 <main+0xd0>
xor    %eax,%eax
call   1070 <closeJetduino@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"setting return status level to 1\0A\00"
@.str.1 = [28 x i8] c"Move to 0 at fastest speed\0A\00"
@.str.2 = [21 x i8] c"Move to 1023 slowly\0A\00"
@.str.3 = [41 x i8] c"stop the servo at its current position.\0A\00"
@.str.4 = [24 x i8] c"Moving to 1023 at 100.\0A\00"
@.str.5 = [9 x i8] c"Pos: %d\0A\00"
@.str.6 = [23 x i8] c"Moving to 10 at 1000.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
store i32 4, i32* %7
%8 = call i32 (...) @openJetduino()
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %6
%15 = call i32 @dynamixelSetRegister(i32 %14, i32 16, i32 1, i32 1)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %6
%18 = call i32 @dynamixelMove(i32 %17, i32 0, i32 0)
%19 = call i32 @jet_sleep(i32 1000)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %6
%22 = call i32 @dynamixelMove(i32 %21, i32 1023, i32 200)
%23 = call i32 @jet_sleep(i32 500)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* %6
%26 = call i32 @dynamixelStop(i32 %25)
%27 = call i32 @jet_sleep(i32 1000)
store i32 0, i32* %3
br label %28
28: ; preds = %64, %12
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 10
br i1 %30, label %31, label %67
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* %6
%34 = call i32 @dynamixelMove(i32 %33, i32 1023, i32 100)
store i32 0, i32* %4
br label %35
35: ; preds = %44, %31
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 20
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = call i32 @jet_sleep(i32 100)
%40 = load i32, i32* %6
%41 = call i32 @dynamixelGetRegister(i32 %40, i32 36, i32 2)
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %35
47: ; preds = %35
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%49 = load i32, i32* %6
%50 = call i32 @dynamixelMove(i32 %49, i32 10, i32 1000)
store i32 0, i32* %4
br label %51
51: ; preds = %60, %47
%52 = load i32, i32* %4
%53 = icmp slt i32 %52, 20
br i1 %53, label %54, label %63
54: ; preds = %51
%55 = call i32 @jet_sleep(i32 100)
%56 = load i32, i32* %6
%57 = call i32 @dynamixelGetRegister(i32 %56, i32 36, i32 2)
store i32 %57, i32* %5
%58 = load i32, i32* %5
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %54
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %51
63: ; preds = %51
br label %64
64: ; preds = %63
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 1
store i32 %66, i32* %3
br label %28
67: ; preds = %28
%68 = call i32 (...) @closeJetduino()
ret i32 1
}

LLVM IR (-O2):
@.str.5 = [9 x i8] c"Pos: %d\0A\00"
@str = [33 x i8] c"setting return status level to 1\00"
@str.7 = [27 x i8] c"Move to 0 at fastest speed\00"
@str.8 = [20 x i8] c"Move to 1023 slowly\00"
@str.9 = [40 x i8] c"stop the servo at its current position.\00"
@str.10 = [23 x i8] c"Moving to 1023 at 100.\00"
@str.11 = [22 x i8] c"Moving to 10 at 1000.\00"
define i32 @main() {
%1 = tail call i32 (...) @openJetduino()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @exit(i32 1)
unreachable
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @dynamixelSetRegister(i32 1, i32 16, i32 1, i32 1)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%9 = tail call i32 @dynamixelMove(i32 1, i32 0, i32 0)
%10 = tail call i32 @jet_sleep(i32 1000)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
%12 = tail call i32 @dynamixelMove(i32 1, i32 1023, i32 200)
%13 = tail call i32 @jet_sleep(i32 500)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%15 = tail call i32 @dynamixelStop(i32 1)
%16 = tail call i32 @jet_sleep(i32 1000)
br label %17
17: ; preds = %5, %38
%18 = phi i32 [ 0, %5 ], [ %39, %38 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
%20 = tail call i32 @dynamixelMove(i32 1, i32 1023, i32 100)
br label %21
21: ; preds = %17, %21
%22 = phi i32 [ 0, %17 ], [ %26, %21 ]
%23 = tail call i32 @jet_sleep(i32 100)
%24 = tail call i32 @dynamixelGetRegister(i32 1, i32 36, i32 2)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i32 %22, 1
%27 = icmp eq i32 %26, 20
br i1 %27, label %28, label %21
28: ; preds = %21
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%30 = tail call i32 @dynamixelMove(i32 1, i32 10, i32 1000)
br label %31
31: ; preds = %28, %31
%32 = phi i32 [ 0, %28 ], [ %36, %31 ]
%33 = tail call i32 @jet_sleep(i32 100)
%34 = tail call i32 @dynamixelGetRegister(i32 1, i32 36, i32 2)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = add nuw nsw i32 %32, 1
%37 = icmp eq i32 %36, 20
br i1 %37, label %38, label %31
38: ; preds = %31
%39 = add nuw nsw i32 %18, 1
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %17
41: ; preds = %38
%42 = tail call i32 (...) @closeJetduino()
ret i32 1
}