#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__ abs(int);
int /*<<< orphan*/ create_spin(int);
int /*<<< orphan*/ create_stop();
int get_create_total_angle();
int /*<<< orphan*/ msleep(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ set_create_total_angle(int /*<<< orphan*/);
int systime();
void create_spin_angle(int speed, int angle) {
  set_create_total_angle(0);
  if (angle > 0) {
    create_spin(speed);
  }
  if (angle < 0) {
    create_spin(-1 * speed);
  }
  int beginTime = systime();
  while (abs(get_create_total_angle()) < abs(angle))
    msleep(1);
  int totTime = systime() - beginTime;
  printf("\nms per current angle: %d", totTime);
  printf("\ncurrent angle: %d", get_create_total_angle());
  create_stop();
}


x86 assembly (clang, -O0):
<create_spin_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %edi,%edi
call   1060 <set_create_total_angle@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11a7 <create_spin_angle+0x27>
mov    -0x4(%rbp),%edi
call   1090 <create_spin@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11bd <create_spin_angle+0x3d>
imul   $0xffffffff,-0x4(%rbp),%edi
call   1090 <create_spin@plt>
mov    $0x0,%al
call   1030 <systime@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   10a0 <get_create_total_angle@plt>
mov    %eax,%edi
call   1040 <abs@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <abs@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jge    1200 <create_spin_angle+0x80>
mov    $0x1,%edi
call   1070 <msleep@plt>
jmp    11c7 <create_spin_angle+0x47>
mov    $0x0,%al
call   1030 <systime@plt>
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xde9(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   10a0 <get_create_total_angle@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   1050 <create_stop@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_spin_angle>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
call   1060 <set_create_total_angle@plt>
test   %ebx,%ebx
jle    119c <create_spin_angle+0x1c>
mov    %ebp,%edi
call   1090 <create_spin@plt>
jmp    119e <create_spin_angle+0x1e>
js     1211 <create_spin_angle+0x91>
xor    %eax,%eax
call   1030 <systime@plt>
mov    %eax,%r14d
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <get_create_total_angle@plt>
mov    %eax,%edi
call   1040 <abs@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1040 <abs@plt>
cmp    %rax,%rbp
jge    11d9 <create_spin_angle+0x59>
mov    $0x1,%edi
call   1070 <msleep@plt>
jmp    11b0 <create_spin_angle+0x30>
xor    %eax,%eax
call   1030 <systime@plt>
sub    %r14d,%eax
lea    0xe16(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
xor    %eax,%eax
call   10a0 <get_create_total_angle@plt>
lea    0xe1b(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <create_stop@plt>
neg    %ebp
jmp    1193 <create_spin_angle+0x13>

LLVM IR (-O0):
@.str = [26 x i8] c"\0Ams per current angle: %d\00"
@.str.1 = [19 x i8] c"\0Acurrent angle: %d\00"
define void @create_spin_angle(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 @set_create_total_angle(i32 0)
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %3
%12 = call i32 @create_spin(i32 %11)
br label %13
13: ; preds = %10, %2
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %3
%18 = mul nsw i32 -1, %17
%19 = call i32 @create_spin(i32 %18)
br label %20
20: ; preds = %16, %13
%21 = call i32 (...) @systime()
store i32 %21, i32* %5
br label %22
22: ; preds = %28, %20
%23 = call i32 (...) @get_create_total_angle()
%24 = call i64 @abs(i32 %23)
%25 = load i32, i32* %4
%26 = call i64 @abs(i32 %25)
%27 = icmp slt i64 %24, %26
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @msleep(i32 1)
br label %22
30: ; preds = %22
%31 = call i32 (...) @systime()
%32 = load i32, i32* %5
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = call i32 (...) @get_create_total_angle()
%37 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = call i32 (...) @create_stop()
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0Ams per current angle: %d\00"
@.str.1 = [19 x i8] c"\0Acurrent angle: %d\00"
define void @create_spin_angle(i32 %0, i32 %1) {
%3 = tail call i32 @set_create_total_angle(i32 0)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = icmp slt i32 %1, 0
br i1 %6, label %7, label %12
7: ; preds = %5
%8 = sub nsw i32 0, %0
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ %8, %7 ], [ %0, %2 ]
%11 = tail call i32 @create_spin(i32 %10)
br label %12
12: ; preds = %9, %5
%13 = tail call i32 (...) @systime()
%14 = tail call i32 (...) @get_create_total_angle()
%15 = tail call i64 @abs(i32 %14)
%16 = tail call i64 @abs(i32 %1)
%17 = icmp slt i64 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %12, %18
%19 = tail call i32 @msleep(i32 1)
%20 = tail call i32 (...) @get_create_total_angle()
%21 = tail call i64 @abs(i32 %20)
%22 = tail call i64 @abs(i32 %1)
%23 = icmp slt i64 %21, %22
br i1 %23, label %18, label %24
24: ; preds = %18, %12
%25 = tail call i32 (...) @systime()
%26 = sub nsw i32 %25, %13
%27 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = tail call i32 (...) @get_create_total_angle()
%29 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = tail call i32 (...) @create_stop()
ret void
}