#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*/ analogWrite(int, int);
int /*<<< orphan*/ delay(int);
void fade(int fadeSpeed, int rPin, int gPin, int bPin) {
  for (int fadeValue = 0; fadeValue < 255; fadeValue += fadeSpeed) {
    analogWrite(rPin, fadeValue);
    analogWrite(gPin, 0);
    analogWrite(bPin, 0);
    delay(50);
  }
  for (int fadeValue = 255; fadeValue > 0; fadeValue -= fadeSpeed) {
    analogWrite(rPin, fadeValue);
    analogWrite(gPin, 0);
    analogWrite(bPin, 0);
    delay(50);
  }
  for (int fadeValue = 0; fadeValue < 255; fadeValue += fadeSpeed) {
    analogWrite(rPin, 0);
    analogWrite(gPin, fadeValue);
    analogWrite(bPin, 0);
    delay(50);
  }
  for (int fadeValue = 255; fadeValue > 0; fadeValue -= fadeSpeed) {
    analogWrite(rPin, 0);
    analogWrite(gPin, fadeValue);
    analogWrite(bPin, 0);
    delay(50);
  }
  for (int fadeValue = 0; fadeValue < 255; fadeValue += fadeSpeed) {
    analogWrite(rPin, 0);
    analogWrite(gPin, 0);
    analogWrite(bPin, fadeValue);
    delay(50);
  }
  for (int fadeValue = 255; fadeValue > 0; fadeValue -= fadeSpeed) {
    analogWrite(rPin, 0);
    analogWrite(gPin, 0);
    analogWrite(bPin, fadeValue);
    delay(50);
  }
}


x86 assembly (clang, -O0):
<fade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jge    117f <fade+0x5f>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    113b <fade+0x1b>
movl   $0xff,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11c9 <fade+0xa9>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <fade+0x66>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jge    1214 <fade+0xf4>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11d0 <fade+0xb0>
movl   $0xff,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    125e <fade+0x13e>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    121b <fade+0xfb>
movl   $0x0,-0x24(%rbp)
cmpl   $0xff,-0x24(%rbp)
jge    12a9 <fade+0x189>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1265 <fade+0x145>
movl   $0xff,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    12f3 <fade+0x1d3>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    -0x10(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
jmp    12b0 <fade+0x190>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fade>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
add    %ebp,%ebx
cmp    $0xff,%ebx
jl     1140 <fade+0x20>
mov    $0xff,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
sub    %ebp,%ebx
test   %ebx,%ebx
jg     1180 <fade+0x60>
xor    %ebx,%ebx
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
add    %ebp,%ebx
cmp    $0xff,%ebx
jl     11b0 <fade+0x90>
mov    $0xff,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
sub    %ebp,%ebx
test   %ebx,%ebx
jg     11f0 <fade+0xd0>
xor    %ebx,%ebx
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
add    %ebp,%ebx
cmp    $0xff,%ebx
jl     1220 <fade+0x100>
mov    $0xff,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <analogWrite@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1040 <analogWrite@plt>
mov    $0x32,%edi
call   1030 <delay@plt>
sub    %ebp,%ebx
test   %ebx,%ebx
jg     1260 <fade+0x140>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fade(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %27, %4
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 255
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = load i32, i32* %6
%20 = load i32, i32* %9
%21 = call i32 @analogWrite(i32 %19, i32 %20)
%22 = load i32, i32* %7
%23 = call i32 @analogWrite(i32 %22, i32 0)
%24 = load i32, i32* %8
%25 = call i32 @analogWrite(i32 %24, i32 0)
%26 = call i32 @delay(i32 50)
br label %27
27: ; preds = %18
%28 = load i32, i32* %5
%29 = load i32, i32* %9
%30 = add nsw i32 %29, %28
store i32 %30, i32* %9
br label %15
31: ; preds = %15
store i32 255, i32* %10
br label %32
32: ; preds = %44, %31
%33 = load i32, i32* %10
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = load i32, i32* %6
%37 = load i32, i32* %10
%38 = call i32 @analogWrite(i32 %36, i32 %37)
%39 = load i32, i32* %7
%40 = call i32 @analogWrite(i32 %39, i32 0)
%41 = load i32, i32* %8
%42 = call i32 @analogWrite(i32 %41, i32 0)
%43 = call i32 @delay(i32 50)
br label %44
44: ; preds = %35
%45 = load i32, i32* %5
%46 = load i32, i32* %10
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %10
br label %32
48: ; preds = %32
store i32 0, i32* %11
br label %49
49: ; preds = %61, %48
%50 = load i32, i32* %11
%51 = icmp slt i32 %50, 255
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i32, i32* %6
%54 = call i32 @analogWrite(i32 %53, i32 0)
%55 = load i32, i32* %7
%56 = load i32, i32* %11
%57 = call i32 @analogWrite(i32 %55, i32 %56)
%58 = load i32, i32* %8
%59 = call i32 @analogWrite(i32 %58, i32 0)
%60 = call i32 @delay(i32 50)
br label %61
61: ; preds = %52
%62 = load i32, i32* %5
%63 = load i32, i32* %11
%64 = add nsw i32 %63, %62
store i32 %64, i32* %11
br label %49
65: ; preds = %49
store i32 255, i32* %12
br label %66
66: ; preds = %78, %65
%67 = load i32, i32* %12
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %82
69: ; preds = %66
%70 = load i32, i32* %6
%71 = call i32 @analogWrite(i32 %70, i32 0)
%72 = load i32, i32* %7
%73 = load i32, i32* %12
%74 = call i32 @analogWrite(i32 %72, i32 %73)
%75 = load i32, i32* %8
%76 = call i32 @analogWrite(i32 %75, i32 0)
%77 = call i32 @delay(i32 50)
br label %78
78: ; preds = %69
%79 = load i32, i32* %5
%80 = load i32, i32* %12
%81 = sub nsw i32 %80, %79
store i32 %81, i32* %12
br label %66
82: ; preds = %66
store i32 0, i32* %13
br label %83
83: ; preds = %95, %82
%84 = load i32, i32* %13
%85 = icmp slt i32 %84, 255
br i1 %85, label %86, label %99
86: ; preds = %83
%87 = load i32, i32* %6
%88 = call i32 @analogWrite(i32 %87, i32 0)
%89 = load i32, i32* %7
%90 = call i32 @analogWrite(i32 %89, i32 0)
%91 = load i32, i32* %8
%92 = load i32, i32* %13
%93 = call i32 @analogWrite(i32 %91, i32 %92)
%94 = call i32 @delay(i32 50)
br label %95
95: ; preds = %86
%96 = load i32, i32* %5
%97 = load i32, i32* %13
%98 = add nsw i32 %97, %96
store i32 %98, i32* %13
br label %83
99: ; preds = %83
store i32 255, i32* %14
br label %100
100: ; preds = %112, %99
%101 = load i32, i32* %14
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %116
103: ; preds = %100
%104 = load i32, i32* %6
%105 = call i32 @analogWrite(i32 %104, i32 0)
%106 = load i32, i32* %7
%107 = call i32 @analogWrite(i32 %106, i32 0)
%108 = load i32, i32* %8
%109 = load i32, i32* %14
%110 = call i32 @analogWrite(i32 %108, i32 %109)
%111 = call i32 @delay(i32 50)
br label %112
112: ; preds = %103
%113 = load i32, i32* %5
%114 = load i32, i32* %14
%115 = sub nsw i32 %114, %113
store i32 %115, i32* %14
br label %100
116: ; preds = %100
ret void
}

LLVM IR (-O2):
define void @fade(i32 %0, i32 %1, i32 %2, i32 %3) {
br label %5
5: ; preds = %4, %5
%6 = phi i32 [ 0, %4 ], [ %11, %5 ]
%7 = tail call i32 @analogWrite(i32 %1, i32 %6)
%8 = tail call i32 @analogWrite(i32 %2, i32 0)
%9 = tail call i32 @analogWrite(i32 %3, i32 0)
%10 = tail call i32 @delay(i32 50)
%11 = add nsw i32 %6, %0
%12 = icmp slt i32 %11, 255
br i1 %12, label %5, label %13
13: ; preds = %5, %13
%14 = phi i32 [ %19, %13 ], [ 255, %5 ]
%15 = tail call i32 @analogWrite(i32 %1, i32 %14)
%16 = tail call i32 @analogWrite(i32 %2, i32 0)
%17 = tail call i32 @analogWrite(i32 %3, i32 0)
%18 = tail call i32 @delay(i32 50)
%19 = sub nsw i32 %14, %0
%20 = icmp sgt i32 %19, 0
br i1 %20, label %13, label %21
21: ; preds = %13, %21
%22 = phi i32 [ %27, %21 ], [ 0, %13 ]
%23 = tail call i32 @analogWrite(i32 %1, i32 0)
%24 = tail call i32 @analogWrite(i32 %2, i32 %22)
%25 = tail call i32 @analogWrite(i32 %3, i32 0)
%26 = tail call i32 @delay(i32 50)
%27 = add nsw i32 %22, %0
%28 = icmp slt i32 %27, 255
br i1 %28, label %21, label %29
29: ; preds = %21, %29
%30 = phi i32 [ %35, %29 ], [ 255, %21 ]
%31 = tail call i32 @analogWrite(i32 %1, i32 0)
%32 = tail call i32 @analogWrite(i32 %2, i32 %30)
%33 = tail call i32 @analogWrite(i32 %3, i32 0)
%34 = tail call i32 @delay(i32 50)
%35 = sub nsw i32 %30, %0
%36 = icmp sgt i32 %35, 0
br i1 %36, label %29, label %37
37: ; preds = %29, %37
%38 = phi i32 [ %43, %37 ], [ 0, %29 ]
%39 = tail call i32 @analogWrite(i32 %1, i32 0)
%40 = tail call i32 @analogWrite(i32 %2, i32 0)
%41 = tail call i32 @analogWrite(i32 %3, i32 %38)
%42 = tail call i32 @delay(i32 50)
%43 = add nsw i32 %38, %0
%44 = icmp slt i32 %43, 255
br i1 %44, label %37, label %46
45: ; preds = %46
ret void
46: ; preds = %37, %46
%47 = phi i32 [ %52, %46 ], [ 255, %37 ]
%48 = tail call i32 @analogWrite(i32 %1, i32 0)
%49 = tail call i32 @analogWrite(i32 %2, i32 0)
%50 = tail call i32 @analogWrite(i32 %3, i32 %47)
%51 = tail call i32 @delay(i32 50)
%52 = sub nsw i32 %47, %0
%53 = icmp sgt i32 %52, 0
br i1 %53, label %46, label %45
}