#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 */
typedef int /*<<< orphan*/ vals;

/* Variables and functions */
int /*<<< orphan*/ gpioPWM(int, int);
void LEDlaserTick(void) {
  static int gpio[4] = {14, 15, 22, 4};
  static int pos[4] = {0, 3, 6, 9};
  static int inc[4] = {1, 1, 1, 1};
  static int vals[] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 249};
  int i;
  for (i = 0; i < 4; i++) {
    gpioPWM(gpio[i], vals[pos[i]]);
    pos[i] += inc[i];
    if ((pos[i] >= (sizeof(vals) / 4)) || (pos[i] < 0)) {
      inc[i] = -inc[i];
      pos[i] += inc[i];
    }
  }
}


x86 assembly (clang, -O0):
<LEDlaserTick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    1200 <LEDlaserTick+0xf0>
movslq -0x4(%rbp),%rcx
lea    0x2efc(%rip),%rax
mov    (%rax,%rcx,4),%edi
movslq -0x4(%rbp),%rcx
lea    0x2efe(%rip),%rax
movslq (%rax,%rcx,4),%rcx
lea    0x2f13(%rip),%rax
mov    (%rax,%rcx,4),%esi
call   1030 <gpioPWM@plt>
movslq -0x4(%rbp),%rcx
lea    0x2ef0(%rip),%rax
mov    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2ed2(%rip),%rax
add    (%rax,%rcx,4),%edx
lea    0x2ec8(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x4(%rbp),%rcx
lea    0x2eba(%rip),%rax
movslq (%rax,%rcx,4),%rax
cmp    $0xa,%rax
jae    11a9 <LEDlaserTick+0x99>
movslq -0x4(%rbp),%rcx
lea    0x2ea1(%rip),%rax
cmpl   $0x0,(%rax,%rcx,4)
jge    11ed <LEDlaserTick+0xdd>
movslq -0x4(%rbp),%rcx
xor    %edx,%edx
lea    0x2e9a(%rip),%rax
sub    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2e8c(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x4(%rbp),%rcx
lea    0x2e7e(%rip),%rax
mov    (%rax,%rcx,4),%edx
movslq -0x4(%rbp),%rcx
lea    0x2e60(%rip),%rax
add    (%rax,%rcx,4),%edx
lea    0x2e56(%rip),%rax
mov    %edx,(%rax,%rcx,4)
jmp    11f2 <LEDlaserTick+0xe2>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <LEDlaserTick+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LEDlaserTick>:
push   %rbx
movslq 0x2f78(%rip),%rax
lea    0xee1(%rip),%rbx
mov    (%rbx,%rax,4),%esi
mov    $0xe,%edi
call   1030 <gpioPWM@plt>
mov    0x2f1e(%rip),%eax
mov    0x2f58(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2f4f(%rip)
cmp    $0xa,%edx
jb     1154 <LEDlaserTick+0x44>
neg    %eax
mov    %eax,0x2f02(%rip)
mov    %ecx,0x2f3c(%rip)
movslq 0x2ed5(%rip),%rax
mov    (%rbx,%rax,4),%esi
mov    $0xf,%edi
call   1030 <gpioPWM@plt>
mov    0x2ef2(%rip),%eax
mov    0x2ebc(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2eb3(%rip)
cmp    $0xa,%edx
jb     1190 <LEDlaserTick+0x80>
neg    %eax
mov    %eax,0x2ed6(%rip)
mov    %ecx,0x2ea0(%rip)
movslq 0x2ea1(%rip),%rax
mov    (%rbx,%rax,4),%esi
mov    $0x16,%edi
call   1030 <gpioPWM@plt>
mov    0x2ebe(%rip),%eax
mov    0x2e88(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2e7f(%rip)
cmp    $0xa,%edx
jb     11cc <LEDlaserTick+0xbc>
neg    %eax
mov    %eax,0x2ea2(%rip)
mov    %ecx,0x2e6c(%rip)
movslq 0x2e6d(%rip),%rax
mov    (%rbx,%rax,4),%esi
mov    $0x4,%edi
call   1030 <gpioPWM@plt>
mov    0x2e8a(%rip),%eax
mov    0x2e54(%rip),%ecx
lea    (%rcx,%rax,1),%edx
mov    %edx,0x2e4b(%rip)
cmp    $0xa,%edx
jb     1208 <LEDlaserTick+0xf8>
neg    %eax
mov    %eax,0x2e6e(%rip)
mov    %ecx,0x2e38(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@LEDlaserTick.gpio = internal global [4 x i32] [i32 14, i32 15, i32 22, i32 4]
@LEDlaserTick.pos = internal global [4 x i32] [i32 0, i32 3, i32 6, i32 9]
@LEDlaserTick.inc = internal global [4 x i32] [i32 1, i32 1, i32 1, i32 1]
@LEDlaserTick.vals = internal global [10 x i32] [i32 0, i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 249]
define void @LEDlaserTick() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %58, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 4
br i1 %4, label %5, label %61
5: ; preds = %2
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.gpio, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.pos, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* @LEDlaserTick.vals, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @gpioPWM(i32 %9, i32 %16)
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.inc, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.pos, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = add nsw i32 %25, %21
store i32 %26, i32* %24
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.pos, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = icmp uge i64 %31, 10
br i1 %32, label %39, label %33
33: ; preds = %5
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.pos, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %57
39: ; preds = %33, %5
%40 = load i32, i32* %1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.inc, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = sub nsw i32 0, %43
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.inc, i64 0, i64 %46
store i32 %44, i32* %47
%48 = load i32, i32* %1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.inc, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [4 x i32], [4 x i32]* @LEDlaserTick.pos, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = add nsw i32 %55, %51
store i32 %56, i32* %54
br label %57
57: ; preds = %39, %33
br label %58
58: ; preds = %57
%59 = load i32, i32* %1
%60 = add nsw i32 %59, 1
store i32 %60, i32* %1
br label %2
61: ; preds = %2
ret void
}

LLVM IR (-O2):
@LEDlaserTick.pos.0 = internal unnamed_addr global i32 0
@LEDlaserTick.pos.1 = internal unnamed_addr global i32 3
@LEDlaserTick.pos.2 = internal unnamed_addr global i32 6
@LEDlaserTick.pos.3 = internal unnamed_addr global i32 9
@LEDlaserTick.inc.0 = internal unnamed_addr global i32 1
@LEDlaserTick.inc.1 = internal unnamed_addr global i32 1
@LEDlaserTick.inc.2 = internal unnamed_addr global i32 1
@LEDlaserTick.inc.3 = internal unnamed_addr global i32 1
@LEDlaserTick.vals = internal unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 249]
define void @LEDlaserTick() {
%1 = load i32, i32* @LEDlaserTick.pos.0
%2 = sext i32 %1 to i64
%3 = getelementptr inbounds [10 x i32], [10 x i32]* @LEDlaserTick.vals, i64 0, i64 %2
%4 = load i32, i32* %3
%5 = tail call i32 @gpioPWM(i32 14, i32 %4)
%6 = load i32, i32* @LEDlaserTick.inc.0
%7 = load i32, i32* @LEDlaserTick.pos.0
%8 = add nsw i32 %7, %6
store i32 %8, i32* @LEDlaserTick.pos.0
%9 = icmp ugt i32 %8, 9
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = sub nsw i32 0, %6
store i32 %11, i32* @LEDlaserTick.inc.0
store i32 %7, i32* @LEDlaserTick.pos.0
br label %12
12: ; preds = %0, %10
%13 = load i32, i32* @LEDlaserTick.pos.1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* @LEDlaserTick.vals, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 @gpioPWM(i32 15, i32 %16)
%18 = load i32, i32* @LEDlaserTick.inc.1
%19 = load i32, i32* @LEDlaserTick.pos.1
%20 = add nsw i32 %19, %18
store i32 %20, i32* @LEDlaserTick.pos.1
%21 = icmp ugt i32 %20, 9
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = sub nsw i32 0, %18
store i32 %23, i32* @LEDlaserTick.inc.1
store i32 %19, i32* @LEDlaserTick.pos.1
br label %24
24: ; preds = %22, %12
%25 = load i32, i32* @LEDlaserTick.pos.2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* @LEDlaserTick.vals, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = tail call i32 @gpioPWM(i32 22, i32 %28)
%30 = load i32, i32* @LEDlaserTick.inc.2
%31 = load i32, i32* @LEDlaserTick.pos.2
%32 = add nsw i32 %31, %30
store i32 %32, i32* @LEDlaserTick.pos.2
%33 = icmp ugt i32 %32, 9
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = sub nsw i32 0, %30
store i32 %35, i32* @LEDlaserTick.inc.2
store i32 %31, i32* @LEDlaserTick.pos.2
br label %36
36: ; preds = %34, %24
%37 = load i32, i32* @LEDlaserTick.pos.3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* @LEDlaserTick.vals, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = tail call i32 @gpioPWM(i32 4, i32 %40)
%42 = load i32, i32* @LEDlaserTick.inc.3
%43 = load i32, i32* @LEDlaserTick.pos.3
%44 = add nsw i32 %43, %42
store i32 %44, i32* @LEDlaserTick.pos.3
%45 = icmp ugt i32 %44, 9
br i1 %45, label %46, label %48
46: ; preds = %36
%47 = sub nsw i32 0, %42
store i32 %47, i32* @LEDlaserTick.inc.3
store i32 %43, i32* @LEDlaserTick.pos.3
br label %48
48: ; preds = %46, %36
ret void
}