void backLightFlash2(unsigned char *red, unsigned char *green,
                     unsigned char *blue) {
  static unsigned int delayCnt = 0;
  static unsigned char rgbState = 1;
  if (delayCnt == 5) {
    *red = 0xff;
    *green = 0xff;
    *blue = 0xff;
    switch (rgbState) {
    case 1:
      *red = 0x0;
      break;
    case 3:
      *green = 0x0;
      break;
    case 5:
      *blue = 0x0;
      break;
    case 7:
      *red = 0x0;
      *green = 0x0;
      break;
    case 9:
      *red = 0x0;
      *blue = 0x0;
      break;
    case 11:
      *green = 0x0;
      *blue = 0x0;
      break;
    case 13:
      *red = 0x0;
      *green = 0x0;
      *blue = 0x0;
      break;
    }
    delayCnt = 0;
    if (rgbState == 14)
      rgbState = 1;
    else
      rgbState += 1;
  } else
    delayCnt++;
}


x86 assembly (clang, -O0):
<backLightFlash2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x5,0x2f11(%rip)
jne    120c <backLightFlash2+0x10c>
mov    -0x8(%rbp),%rax
movb   $0xff,(%rax)
mov    -0x10(%rbp),%rax
movb   $0xff,(%rax)
mov    -0x18(%rbp),%rax
movb   $0xff,(%rax)
movzbl 0x2ee7(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xc,%eax
ja     11d1 <backLightFlash2+0xd1>
mov    -0x20(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d1 <backLightFlash2+0xd1>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,0x2e4d(%rip)
movzbl 0x2e3e(%rip),%eax
cmp    $0xe,%eax
jne    11f7 <backLightFlash2+0xf7>
movb   $0x1,0x2e2e(%rip)
jmp    1207 <backLightFlash2+0x107>
movzbl 0x2e22(%rip),%eax
add    $0x1,%eax
mov    %al,0x2e19(%rip)
jmp    121b <backLightFlash2+0x11b>
mov    0x2e16(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e0d(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<backLightFlash2>:
mov    0x2f22(%rip),%eax
cmp    $0x5,%eax
jne    113a <backLightFlash2+0x3a>
movb   $0xff,(%rdi)
movb   $0xff,(%rsi)
movb   $0xff,(%rdx)
mov    0x2f06(%rip),%al
lea    -0x1(%rax),%ecx
cmp    $0xc,%cl
ja     1144 <backLightFlash2+0x44>
movzbl %cl,%ecx
lea    0xed4(%rip),%r8
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
jmp    *%rcx
mov    %rsi,%rdi
jmp    1170 <backLightFlash2+0x70>
add    $0x1,%eax
mov    %eax,0x2ee5(%rip)
ret
movl   $0x0,0x2eda(%rip)
cmp    $0xe,%al
jne    117d <backLightFlash2+0x7d>
movb   $0x1,0x2ec7(%rip)
ret
movb   $0x0,(%rdi)
mov    %rsi,%rdi
jmp    1170 <backLightFlash2+0x70>
movb   $0x0,(%rdi)
jmp    116d <backLightFlash2+0x6d>
movb   $0x0,(%rdi)
movb   $0x0,(%rsi)
mov    %rdx,%rdi
movb   $0x0,(%rdi)
movl   $0x0,0x2eab(%rip)
add    $0x1,%al
mov    %al,0x2e9b(%rip)
ret

LLVM IR (-O0):
@backLightFlash2.delayCnt = internal global i32 0
@backLightFlash2.rgbState = internal global i8 1
define void @backLightFlash2(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* @backLightFlash2.delayCnt
%8 = icmp eq i32 %7, 5
br i1 %8, label %9, label %45
9: ; preds = %3
%10 = load i8*, i8** %4
store i8 -1, i8* %10
%11 = load i8*, i8** %5
store i8 -1, i8* %11
%12 = load i8*, i8** %6
store i8 -1, i8* %12
%13 = load i8, i8* @backLightFlash2.rgbState
%14 = zext i8 %13 to i32
switch i32 %14, label %34 [
i32 1, label %15
i32 3, label %17
i32 5, label %19
i32 7, label %21
i32 9, label %24
i32 11, label %27
i32 13, label %30
]
15: ; preds = %9
%16 = load i8*, i8** %4
store i8 0, i8* %16
br label %34
17: ; preds = %9
%18 = load i8*, i8** %5
store i8 0, i8* %18
br label %34
19: ; preds = %9
%20 = load i8*, i8** %6
store i8 0, i8* %20
br label %34
21: ; preds = %9
%22 = load i8*, i8** %4
store i8 0, i8* %22
%23 = load i8*, i8** %5
store i8 0, i8* %23
br label %34
24: ; preds = %9
%25 = load i8*, i8** %4
store i8 0, i8* %25
%26 = load i8*, i8** %6
store i8 0, i8* %26
br label %34
27: ; preds = %9
%28 = load i8*, i8** %5
store i8 0, i8* %28
%29 = load i8*, i8** %6
store i8 0, i8* %29
br label %34
30: ; preds = %9
%31 = load i8*, i8** %4
store i8 0, i8* %31
%32 = load i8*, i8** %5
store i8 0, i8* %32
%33 = load i8*, i8** %6
store i8 0, i8* %33
br label %34
34: ; preds = %9, %30, %27, %24, %21, %19, %17, %15
store i32 0, i32* @backLightFlash2.delayCnt
%35 = load i8, i8* @backLightFlash2.rgbState
%36 = zext i8 %35 to i32
%37 = icmp eq i32 %36, 14
br i1 %37, label %38, label %39
38: ; preds = %34
store i8 1, i8* @backLightFlash2.rgbState
br label %44
39: ; preds = %34
%40 = load i8, i8* @backLightFlash2.rgbState
%41 = zext i8 %40 to i32
%42 = add nsw i32 %41, 1
%43 = trunc i32 %42 to i8
store i8 %43, i8* @backLightFlash2.rgbState
br label %44
44: ; preds = %39, %38
br label %48
45: ; preds = %3
%46 = load i32, i32* @backLightFlash2.delayCnt
%47 = add i32 %46, 1
store i32 %47, i32* @backLightFlash2.delayCnt
br label %48
48: ; preds = %45, %44
ret void
}

LLVM IR (-O2):
@backLightFlash2.delayCnt = internal unnamed_addr global i32 0
@backLightFlash2.rgbState = internal unnamed_addr global i8 1
define void @backLightFlash2(i8* nocapture writeonly %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = load i32, i32* @backLightFlash2.delayCnt
%5 = icmp eq i32 %4, 5
br i1 %5, label %6, label %21
6: ; preds = %3
store i8 -1, i8* %0
store i8 -1, i8* %1
store i8 -1, i8* %2
%7 = load i8, i8* @backLightFlash2.rgbState
switch i8 %7, label %16 [
i8 1, label %14
i8 3, label %8
i8 5, label %9
i8 7, label %10
i8 9, label %11
i8 11, label %12
i8 13, label %13
]
8: ; preds = %6
br label %14
9: ; preds = %6
br label %14
10: ; preds = %6
store i8 0, i8* %0
br label %14
11: ; preds = %6
store i8 0, i8* %0
br label %14
12: ; preds = %6
store i8 0, i8* %1
br label %14
13: ; preds = %6
store i8 0, i8* %0
store i8 0, i8* %1
br label %14
14: ; preds = %6, %13, %12, %11, %10, %9, %8
%15 = phi i8* [ %2, %13 ], [ %2, %12 ], [ %2, %11 ], [ %1, %10 ], [ %2, %9 ], [ %1, %8 ], [ %0, %6 ]
store i8 0, i8* %15
store i32 0, i32* @backLightFlash2.delayCnt
br label %19
16: ; preds = %6
store i32 0, i32* @backLightFlash2.delayCnt
%17 = icmp eq i8 %7, 14
br i1 %17, label %18, label %19
18: ; preds = %16
store i8 1, i8* @backLightFlash2.rgbState
br label %23
19: ; preds = %14, %16
%20 = add i8 %7, 1
store i8 %20, i8* @backLightFlash2.rgbState
br label %23
21: ; preds = %3
%22 = add i32 %4, 1
store i32 %22, i32* @backLightFlash2.delayCnt
br label %23
23: ; preds = %18, %19, %21
ret void
}