#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*/ gpioPWM(int, int);
int /*<<< orphan*/ putTTYstr(int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void motorTick(void) {
  static int gpio_in1[2] = {8, 9};
  static int gpio_in2[2] = {7, 11};
  static int speed[2] = {80, 80};
  static int inc[2] = {-50, 50};
  int i;
  char str[256];
  for (i = 0; i < 2; i++) {
    speed[i] += inc[i];
    if (speed[i] < 0) {
      gpioPWM(gpio_in1[i], -speed[i]);
      gpioPWM(gpio_in2[i], 0);
      if (speed[i] < -205)
        inc[i] = -inc[i];
      sprintf(str, "MOT%d IN1=%3d IN2=%3d", i + 1, -speed[i], 0);
    } else {
      gpioPWM(gpio_in2[i], speed[i]);
      gpioPWM(gpio_in1[i], 0);
      if (speed[i] > 205)
        inc[i] = -inc[i];
      sprintf(str, "MOT%d IN1=%3d IN2=%3d", i + 1, 0, speed[i]);
    }
    if (i)
      putTTYstr(7, 1, str);
    else
      putTTYstr(5, 1, str);
  }
}


x86 assembly (clang, -O0):
<motorTick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    130a <motorTick+0x1da>
movslq -0x4(%rbp),%rcx
lea    0x2ef9(%rip),%rax
mov    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2ee3(%rip),%rax
add    (%rax,%rcx,4),%edx
lea    0x2ed9(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x4(%rbp),%rcx
lea    0x2ecb(%rip),%rax
cmpl   $0x0,(%rax,%rcx,4)
jge    1226 <motorTick+0xf6>
movslq -0x4(%rbp),%rcx
lea    0x2ea6(%rip),%rax
mov    (%rax,%rcx,4),%edi
movslq -0x4(%rbp),%rcx
xor    %esi,%esi
lea    0x2ea6(%rip),%rax
sub    (%rax,%rcx,4),%esi
call   1030 <gpioPWM@plt>
movslq -0x4(%rbp),%rcx
lea    0x2e8b(%rip),%rax
mov    (%rax,%rcx,4),%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
movslq -0x4(%rbp),%rcx
lea    0x2e7e(%rip),%rax
cmpl   $0xffffff33,(%rax,%rcx,4)
jge    11f5 <motorTick+0xc5>
movslq -0x4(%rbp),%rcx
xor    %edx,%edx
lea    0x2e6c(%rip),%rax
sub    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2e5e(%rip),%rax
mov    %edx,(%rax,%rcx,4)
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
movslq -0x4(%rbp),%rsi
xor    %ecx,%ecx
lea    0x2e39(%rip),%rax
sub    (%rax,%rsi,4),%ecx
lea    0xde7(%rip),%rsi
xor    %r8d,%r8d
call   1050 <sprintf@plt>
jmp    12bc <motorTick+0x18c>
movslq -0x4(%rbp),%rcx
lea    0x2e0f(%rip),%rax
mov    (%rax,%rcx,4),%edi
movslq -0x4(%rbp),%rcx
lea    0x2e09(%rip),%rax
mov    (%rax,%rcx,4),%esi
call   1030 <gpioPWM@plt>
movslq -0x4(%rbp),%rcx
lea    0x2de6(%rip),%rax
mov    (%rax,%rcx,4),%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
movslq -0x4(%rbp),%rcx
lea    0x2de1(%rip),%rax
cmpl   $0xcd,(%rax,%rcx,4)
jle    1292 <motorTick+0x162>
movslq -0x4(%rbp),%rcx
xor    %edx,%edx
lea    0x2dcf(%rip),%rax
sub    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2dc1(%rip),%rax
mov    %edx,(%rax,%rcx,4)
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
movslq -0x4(%rbp),%rcx
lea    0x2d9e(%rip),%rax
mov    (%rax,%rcx,4),%r8d
lea    0xd4b(%rip),%rsi
xor    %ecx,%ecx
call   1050 <sprintf@plt>
cmpl   $0x0,-0x4(%rbp)
je     12e1 <motorTick+0x1b1>
lea    -0x110(%rbp),%rdx
mov    $0x7,%edi
mov    $0x1,%esi
call   1040 <putTTYstr@plt>
jmp    12f7 <motorTick+0x1c7>
lea    -0x110(%rbp),%rdx
mov    $0x5,%edi
mov    $0x1,%esi
call   1040 <putTTYstr@plt>
jmp    12fc <motorTick+0x1cc>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1142 <motorTick+0x12>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<motorTick>:
sub    $0x108,%rsp
mov    0x2efb(%rip),%esi
add    0x2efd(%rip),%esi
mov    %esi,0x2eef(%rip)
js     118a <motorTick+0x5a>
mov    $0x7,%edi
call   1030 <gpioPWM@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
mov    0x2ed0(%rip),%r8d
cmp    $0xce,%r8d
jl     1177 <motorTick+0x47>
negl   0x2ec9(%rip)
lea    0xe82(%rip),%rsi
mov    %rsp,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
jmp    11ca <motorTick+0x9a>
neg    %esi
mov    $0x8,%edi
call   1030 <gpioPWM@plt>
mov    $0x7,%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
mov    0x2e90(%rip),%ecx
cmp    $0xffffff32,%ecx
jg     11b6 <motorTick+0x86>
negl   0x2e8a(%rip)
neg    %ecx
lea    0xe41(%rip),%rsi
mov    %rsp,%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1050 <sprintf@plt>
mov    %rsp,%rdx
mov    $0x5,%edi
mov    $0x1,%esi
call   1040 <putTTYstr@plt>
mov    0x2e55(%rip),%esi
add    0x2e57(%rip),%esi
mov    %esi,0x2e49(%rip)
js     1234 <motorTick+0x104>
mov    $0xb,%edi
call   1030 <gpioPWM@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
mov    0x2e2a(%rip),%r8d
cmp    $0xce,%r8d
jl     1221 <motorTick+0xf1>
negl   0x2e23(%rip)
lea    0xdd8(%rip),%rsi
mov    %rsp,%rdi
mov    $0x2,%edx
xor    %ecx,%ecx
jmp    1274 <motorTick+0x144>
neg    %esi
mov    $0x9,%edi
call   1030 <gpioPWM@plt>
mov    $0xb,%edi
xor    %esi,%esi
call   1030 <gpioPWM@plt>
mov    0x2dea(%rip),%ecx
cmp    $0xffffff32,%ecx
jg     1260 <motorTick+0x130>
negl   0x2de4(%rip)
neg    %ecx
lea    0xd97(%rip),%rsi
mov    %rsp,%rdi
mov    $0x2,%edx
xor    %r8d,%r8d
call   1050 <sprintf@plt>
mov    %rsp,%rdx
mov    $0x7,%edi
mov    $0x1,%esi
call   1040 <putTTYstr@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
@motorTick.gpio_in1 = internal global [2 x i32] [i32 8, i32 9]
@motorTick.gpio_in2 = internal global [2 x i32] [i32 7, i32 11]
@motorTick.speed = internal global [2 x i32] [i32 80, i32 80]
@motorTick.inc = internal global [2 x i32] [i32 -50, i32 50]
@.str = [22 x i8] c"MOT%d IN1=%3d IN2=%3d\00"
define void @motorTick() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %109, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 2
br i1 %5, label %6, label %112
6: ; preds = %3
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, %10
store i32 %15, i32* %13
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %61
21: ; preds = %6
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.gpio_in1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = sub nsw i32 0, %29
%31 = call i32 @gpioPWM(i32 %25, i32 %30)
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.gpio_in2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @gpioPWM(i32 %35, i32 0)
%37 = load i32, i32* %1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp slt i32 %40, -205
br i1 %41, label %42, label %51
42: ; preds = %21
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = sub nsw i32 0, %46
%48 = load i32, i32* %1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 %49
store i32 %47, i32* %50
br label %51
51: ; preds = %42, %21
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%53 = load i32, i32* %1
%54 = add nsw i32 %53, 1
%55 = load i32, i32* %1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = sub nsw i32 0, %58
%60 = call i32 @sprintf(i8* %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %54, i32 %59, i32 0)
br label %99
61: ; preds = %6
%62 = load i32, i32* %1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.gpio_in2, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = load i32, i32* %1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = call i32 @gpioPWM(i32 %65, i32 %69)
%71 = load i32, i32* %1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.gpio_in1, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = call i32 @gpioPWM(i32 %74, i32 0)
%76 = load i32, i32* %1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = icmp sgt i32 %79, 205
br i1 %80, label %81, label %90
81: ; preds = %61
%82 = load i32, i32* %1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = sub nsw i32 0, %85
%87 = load i32, i32* %1
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 %88
store i32 %86, i32* %89
br label %90
90: ; preds = %81, %61
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%92 = load i32, i32* %1
%93 = add nsw i32 %92, 1
%94 = load i32, i32* %1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = call i32 @sprintf(i8* %91, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %93, i32 0, i32 %97)
br label %99
99: ; preds = %90, %51
%100 = load i32, i32* %1
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%104 = call i32 @putTTYstr(i32 7, i32 1, i8* %103)
br label %108
105: ; preds = %99
%106 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%107 = call i32 @putTTYstr(i32 5, i32 1, i8* %106)
br label %108
108: ; preds = %105, %102
br label %109
109: ; preds = %108
%110 = load i32, i32* %1
%111 = add nsw i32 %110, 1
store i32 %111, i32* %1
br label %3
112: ; preds = %3
ret void
}

LLVM IR (-O2):
@motorTick.speed = internal unnamed_addr global [2 x i32] [i32 80, i32 80]
@motorTick.inc = internal unnamed_addr global [2 x i32] [i32 -50, i32 50]
@.str = [22 x i8] c"MOT%d IN1=%3d IN2=%3d\00"
define void @motorTick() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 0)
%4 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 0)
%5 = add nsw i32 %4, %3
store i32 %5, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %0
%8 = sub nsw i32 0, %5
%9 = call i32 @gpioPWM(i32 8, i32 %8)
%10 = call i32 @gpioPWM(i32 7, i32 0)
%11 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 0)
%12 = icmp slt i32 %11, -205
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 0)
%15 = sub nsw i32 0, %14
store i32 %15, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 0)
br label %16
16: ; preds = %13, %7
%17 = sub nsw i32 0, %11
%18 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 %17, i32 0)
br label %29
19: ; preds = %0
%20 = call i32 @gpioPWM(i32 7, i32 %5)
%21 = call i32 @gpioPWM(i32 8, i32 0)
%22 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 0)
%23 = icmp sgt i32 %22, 205
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 0)
%26 = sub nsw i32 0, %25
store i32 %26, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 0)
br label %27
27: ; preds = %24, %19
%28 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 0, i32 %22)
br label %29
29: ; preds = %16, %27
%30 = call i32 @putTTYstr(i32 5, i32 1, i8* %2)
%31 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 1)
%32 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 1)
%33 = add nsw i32 %32, %31
store i32 %33, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 1)
%34 = icmp slt i32 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %29
%36 = call i32 @gpioPWM(i32 11, i32 %33)
%37 = call i32 @gpioPWM(i32 9, i32 0)
%38 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 1)
%39 = icmp sgt i32 %38, 205
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 1)
%42 = sub nsw i32 0, %41
store i32 %42, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 1)
br label %43
43: ; preds = %40, %35
%44 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 2, i32 0, i32 %38)
br label %57
45: ; preds = %29
%46 = sub nsw i32 0, %33
%47 = call i32 @gpioPWM(i32 9, i32 %46)
%48 = call i32 @gpioPWM(i32 11, i32 0)
%49 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.speed, i64 0, i64 1)
%50 = icmp slt i32 %49, -205
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 1)
%53 = sub nsw i32 0, %52
store i32 %53, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @motorTick.inc, i64 0, i64 1)
br label %54
54: ; preds = %51, %45
%55 = sub nsw i32 0, %49
%56 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 2, i32 %55, i32 0)
br label %57
57: ; preds = %43, %54
%58 = call i32 @putTTYstr(i32 7, i32 1, i8* %2)
ret void
}