#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*/ gpioServo(int, int);
void servoTick(void) {
  static int wid1 = 1500, wid2 = 1500, wid3 = 1500;
  static int inc1 = 50, inc2 = 75, inc3 = 100;
  gpioServo(17, wid1);
  gpioServo(18, wid2);
  gpioServo(21, wid3);
  wid1 += inc1;
  if ((wid1 < 1000) || (wid1 > 2000)) {
    inc1 = -inc1;
    wid1 += inc1;
  }
  wid2 += inc2;
  if ((wid2 < 1000) || (wid2 > 2000)) {
    inc2 = -inc2;
    wid2 += inc2;
  }
  wid3 += inc3;
  if ((wid3 < 1000) || (wid3 > 2000)) {
    inc3 = -inc3;
    wid3 += inc3;
  }
}


x86 assembly (clang, -O0):
<servoTick>:
push   %rbp
mov    %rsp,%rbp
mov    0x2f0e(%rip),%esi
mov    $0x11,%edi
call   1030 <gpioServo@plt>
mov    0x2f02(%rip),%esi
mov    $0x12,%edi
call   1030 <gpioServo@plt>
mov    0x2ef6(%rip),%esi
mov    $0x15,%edi
call   1030 <gpioServo@plt>
mov    0x2eea(%rip),%eax
add    0x2ed8(%rip),%eax
mov    %eax,0x2ed2(%rip)
cmpl   $0x3e8,0x2ec8(%rip)
jl     1176 <servoTick+0x66>
cmpl   $0x7d0,0x2eb8(%rip)
jle    1196 <servoTick+0x86>
xor    %eax,%eax
sub    0x2eb6(%rip),%eax
mov    %eax,0x2eb0(%rip)
mov    0x2eaa(%rip),%eax
add    0x2e98(%rip),%eax
mov    %eax,0x2e92(%rip)
mov    0x2e9c(%rip),%eax
add    0x2e8a(%rip),%eax
mov    %eax,0x2e84(%rip)
cmpl   $0x3e8,0x2e7a(%rip)
jl     11c8 <servoTick+0xb8>
cmpl   $0x7d0,0x2e6a(%rip)
jle    11e8 <servoTick+0xd8>
xor    %eax,%eax
sub    0x2e68(%rip),%eax
mov    %eax,0x2e62(%rip)
mov    0x2e5c(%rip),%eax
add    0x2e4a(%rip),%eax
mov    %eax,0x2e44(%rip)
mov    0x2e4e(%rip),%eax
add    0x2e3c(%rip),%eax
mov    %eax,0x2e36(%rip)
cmpl   $0x3e8,0x2e2c(%rip)
jl     121a <servoTick+0x10a>
cmpl   $0x7d0,0x2e1c(%rip)
jle    123a <servoTick+0x12a>
xor    %eax,%eax
sub    0x2e1a(%rip),%eax
mov    %eax,0x2e14(%rip)
mov    0x2e0e(%rip),%eax
add    0x2dfc(%rip),%eax
mov    %eax,0x2df6(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<servoTick>:
push   %rax
mov    0x2f11(%rip),%esi
mov    $0x11,%edi
call   1030 <gpioServo@plt>
mov    0x2f05(%rip),%esi
mov    $0x12,%edi
call   1030 <gpioServo@plt>
mov    0x2ef9(%rip),%esi
mov    $0x15,%edi
call   1030 <gpioServo@plt>
mov    0x2eed(%rip),%eax
mov    0x2edb(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2ed2(%rip)
lea    (%rcx,%rax,1),%edx
add    $0xfffff82f,%edx
cmp    $0xfffffc16,%edx
ja     1175 <servoTick+0x65>
neg    %eax
mov    %eax,0x2ec5(%rip)
mov    %ecx,0x2eb3(%rip)
mov    0x2ebd(%rip),%eax
mov    0x2eab(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2ea2(%rip)
lea    (%rcx,%rax,1),%edx
add    $0xfffff82f,%edx
cmp    $0xfffffc16,%edx
ja     11a9 <servoTick+0x99>
neg    %eax
mov    %eax,0x2e95(%rip)
mov    %ecx,0x2e83(%rip)
mov    0x2e8d(%rip),%eax
mov    0x2e7b(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2e72(%rip)
lea    (%rcx,%rax,1),%edx
add    $0xfffff82f,%edx
cmp    $0xfffffc16,%edx
ja     11dd <servoTick+0xcd>
neg    %eax
mov    %eax,0x2e65(%rip)
mov    %ecx,0x2e53(%rip)
pop    %rax
ret

LLVM IR (-O0):
@servoTick.wid1 = internal global i32 1500
@servoTick.wid2 = internal global i32 1500
@servoTick.wid3 = internal global i32 1500
@servoTick.inc1 = internal global i32 50
@servoTick.inc2 = internal global i32 75
@servoTick.inc3 = internal global i32 100
define void @servoTick() {
%1 = load i32, i32* @servoTick.wid1
%2 = call i32 @gpioServo(i32 17, i32 %1)
%3 = load i32, i32* @servoTick.wid2
%4 = call i32 @gpioServo(i32 18, i32 %3)
%5 = load i32, i32* @servoTick.wid3
%6 = call i32 @gpioServo(i32 21, i32 %5)
%7 = load i32, i32* @servoTick.inc1
%8 = load i32, i32* @servoTick.wid1
%9 = add nsw i32 %8, %7
store i32 %9, i32* @servoTick.wid1
%10 = load i32, i32* @servoTick.wid1
%11 = icmp slt i32 %10, 1000
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = load i32, i32* @servoTick.wid1
%14 = icmp sgt i32 %13, 2000
br i1 %14, label %15, label %21
15: ; preds = %12, %0
%16 = load i32, i32* @servoTick.inc1
%17 = sub nsw i32 0, %16
store i32 %17, i32* @servoTick.inc1
%18 = load i32, i32* @servoTick.inc1
%19 = load i32, i32* @servoTick.wid1
%20 = add nsw i32 %19, %18
store i32 %20, i32* @servoTick.wid1
br label %21
21: ; preds = %15, %12
%22 = load i32, i32* @servoTick.inc2
%23 = load i32, i32* @servoTick.wid2
%24 = add nsw i32 %23, %22
store i32 %24, i32* @servoTick.wid2
%25 = load i32, i32* @servoTick.wid2
%26 = icmp slt i32 %25, 1000
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = load i32, i32* @servoTick.wid2
%29 = icmp sgt i32 %28, 2000
br i1 %29, label %30, label %36
30: ; preds = %27, %21
%31 = load i32, i32* @servoTick.inc2
%32 = sub nsw i32 0, %31
store i32 %32, i32* @servoTick.inc2
%33 = load i32, i32* @servoTick.inc2
%34 = load i32, i32* @servoTick.wid2
%35 = add nsw i32 %34, %33
store i32 %35, i32* @servoTick.wid2
br label %36
36: ; preds = %30, %27
%37 = load i32, i32* @servoTick.inc3
%38 = load i32, i32* @servoTick.wid3
%39 = add nsw i32 %38, %37
store i32 %39, i32* @servoTick.wid3
%40 = load i32, i32* @servoTick.wid3
%41 = icmp slt i32 %40, 1000
br i1 %41, label %45, label %42
42: ; preds = %36
%43 = load i32, i32* @servoTick.wid3
%44 = icmp sgt i32 %43, 2000
br i1 %44, label %45, label %51
45: ; preds = %42, %36
%46 = load i32, i32* @servoTick.inc3
%47 = sub nsw i32 0, %46
store i32 %47, i32* @servoTick.inc3
%48 = load i32, i32* @servoTick.inc3
%49 = load i32, i32* @servoTick.wid3
%50 = add nsw i32 %49, %48
store i32 %50, i32* @servoTick.wid3
br label %51
51: ; preds = %45, %42
ret void
}

LLVM IR (-O2):
@servoTick.wid1 = internal unnamed_addr global i32 1500
@servoTick.wid2 = internal unnamed_addr global i32 1500
@servoTick.wid3 = internal unnamed_addr global i32 1500
@servoTick.inc1 = internal unnamed_addr global i32 50
@servoTick.inc2 = internal unnamed_addr global i32 75
@servoTick.inc3 = internal unnamed_addr global i32 100
define void @servoTick() {
%1 = load i32, i32* @servoTick.wid1
%2 = tail call i32 @gpioServo(i32 17, i32 %1)
%3 = load i32, i32* @servoTick.wid2
%4 = tail call i32 @gpioServo(i32 18, i32 %3)
%5 = load i32, i32* @servoTick.wid3
%6 = tail call i32 @gpioServo(i32 21, i32 %5)
%7 = load i32, i32* @servoTick.inc1
%8 = load i32, i32* @servoTick.wid1
%9 = add nsw i32 %8, %7
store i32 %9, i32* @servoTick.wid1
%10 = add i32 %9, -2001
%11 = icmp ult i32 %10, -1001
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = sub nsw i32 0, %7
store i32 %13, i32* @servoTick.inc1
store i32 %8, i32* @servoTick.wid1
br label %14
14: ; preds = %0, %12
%15 = load i32, i32* @servoTick.inc2
%16 = load i32, i32* @servoTick.wid2
%17 = add nsw i32 %16, %15
store i32 %17, i32* @servoTick.wid2
%18 = add i32 %17, -2001
%19 = icmp ult i32 %18, -1001
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = sub nsw i32 0, %15
store i32 %21, i32* @servoTick.inc2
store i32 %16, i32* @servoTick.wid2
br label %22
22: ; preds = %14, %20
%23 = load i32, i32* @servoTick.inc3
%24 = load i32, i32* @servoTick.wid3
%25 = add nsw i32 %24, %23
store i32 %25, i32* @servoTick.wid3
%26 = add i32 %25, -2001
%27 = icmp ult i32 %26, -1001
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = sub nsw i32 0, %23
store i32 %29, i32* @servoTick.inc3
store i32 %24, i32* @servoTick.wid3
br label %30
30: ; preds = %22, %28
ret void
}