#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*/ putsSPI2(int, unsigned int *);
int /*<<< orphan*/ write_latch(unsigned int);
void send_frame(unsigned long int led_strip_colors[], unsigned int ledStripLen,
                unsigned int litLen) {
  unsigned int i, j;
  unsigned int red, green, blue;
  unsigned int txData[3];
  j = 0;
  for (i = 0; i < ledStripLen; i++) {
    blue = (unsigned int)(led_strip_colors[j] & 0xFF);
    green = (unsigned int)((led_strip_colors[j] >> 8) & 0xFF);
    red = (unsigned int)((led_strip_colors[j] >> 16) & 0xFF);
    if (i < litLen) {
      txData[0] = green | 0x80;
      txData[1] = red | 0x80;
      txData[2] = blue | 0x80;
    } else {
      txData[0] = 0x80;
      txData[1] = 0x80;
      txData[2] = 0x80;
    }
    putsSPI2(3, txData);
    if (j == 2)
      j = 0;
    else
      j++;
  }
  write_latch(ledStripLen);
}


x86 assembly (clang, -O0):
<send_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1217 <send_frame+0xf7>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
and    $0xff,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11c2 <send_frame+0xa2>
mov    -0x20(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0x28(%rbp)
jmp    11d7 <send_frame+0xb7>
movl   $0x80,-0x30(%rbp)
movl   $0x80,-0x2c(%rbp)
movl   $0x80,-0x28(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
call   1040 <putsSPI2@plt>
cmpl   $0x2,-0x18(%rbp)
jne    11fb <send_frame+0xdb>
movl   $0x0,-0x18(%rbp)
jmp    1204 <send_frame+0xe4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1209 <send_frame+0xe9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <send_frame+0x20>
mov    -0xc(%rbp),%edi
call   1030 <write_latch@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_frame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
test   %esi,%esi
je     11cc <send_frame+0xac>
mov    %edx,%ebp
mov    %rdi,%r14
lea    0xc(%rsp),%r15
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1192 <send_frame+0x72>
nopw   0x0(%rax,%rax,1)
movabs $0x8000000080,%rax
mov    %rax,0xc(%rsp)
mov    $0x80,%eax
mov    %eax,0x14(%rsp)
mov    $0x3,%edi
mov    %r15,%rsi
call   1040 <putsSPI2@plt>
cmp    $0x2,%r12d
lea    0x1(%r12),%eax
mov    $0x0,%ecx
cmove  %ecx,%eax
add    $0x1,%r13d
mov    %eax,%r12d
cmp    %r13d,%ebx
je     11cc <send_frame+0xac>
cmp    %ebp,%r13d
jae    1150 <send_frame+0x30>
mov    %r12d,%eax
mov    (%r14,%rax,8),%eax
mov    %eax,%ecx
shr    $0x10,%ecx
or     $0x80,%ecx
mov    %eax,%edx
shr    $0x8,%edx
or     $0x80,%edx
or     $0x80,%eax
movzbl %dl,%edx
mov    %edx,0xc(%rsp)
movzbl %cl,%ecx
mov    %ecx,0x10(%rsp)
movzbl %al,%eax
jmp    1164 <send_frame+0x44>
mov    %ebx,%edi
call   1030 <write_latch@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @send_frame(i64* %0, i32 %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [3 x i32]
store i64* %0, i64** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %68, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %71
17: ; preds = %13
%18 = load i64*, i64** %4
%19 = load i32, i32* %8
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %18, i64 %20
%22 = load i64, i64* %21
%23 = and i64 %22, 255
%24 = trunc i64 %23 to i32
store i32 %24, i32* %11
%25 = load i64*, i64** %4
%26 = load i32, i32* %8
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %25, i64 %27
%29 = load i64, i64* %28
%30 = lshr i64 %29, 8
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
store i32 %32, i32* %10
%33 = load i64*, i64** %4
%34 = load i32, i32* %8
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i64, i64* %33, i64 %35
%37 = load i64, i64* %36
%38 = lshr i64 %37, 16
%39 = and i64 %38, 255
%40 = trunc i64 %39 to i32
store i32 %40, i32* %9
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = icmp ult i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %17
%45 = load i32, i32* %10
%46 = or i32 %45, 128
%47 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
store i32 %46, i32* %47
%48 = load i32, i32* %9
%49 = or i32 %48, 128
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 1
store i32 %49, i32* %50
%51 = load i32, i32* %11
%52 = or i32 %51, 128
%53 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 2
store i32 %52, i32* %53
br label %58
54: ; preds = %17
%55 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
store i32 128, i32* %55
%56 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 1
store i32 128, i32* %56
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 2
store i32 128, i32* %57
br label %58
58: ; preds = %54, %44
%59 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
%60 = call i32 @putsSPI2(i32 3, i32* %59)
%61 = load i32, i32* %8
%62 = icmp eq i32 %61, 2
br i1 %62, label %63, label %64
63: ; preds = %58
store i32 0, i32* %8
br label %67
64: ; preds = %58
%65 = load i32, i32* %8
%66 = add i32 %65, 1
store i32 %66, i32* %8
br label %67
67: ; preds = %64, %63
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add i32 %69, 1
store i32 %70, i32* %7
br label %13
71: ; preds = %13
%72 = load i32, i32* %5
%73 = call i32 @write_latch(i32 %72)
ret void
}

LLVM IR (-O2):
define void @send_frame(i64* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = icmp eq i32 %1, 0
br i1 %6, label %37, label %7
7: ; preds = %3
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
br label %11
11: ; preds = %7, %29
%12 = phi i32 [ 0, %7 ], [ %35, %29 ]
%13 = phi i32 [ 0, %7 ], [ %34, %29 ]
%14 = icmp ult i32 %12, %2
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = zext i32 %13 to i64
%17 = getelementptr inbounds i64, i64* %0, i64 %16
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = lshr i32 %19, 16
%21 = and i32 %20, 127
%22 = lshr i32 %19, 8
%23 = and i32 %22, 127
%24 = and i32 %19, 127
%25 = or i32 %23, 128
store i32 %25, i32* %8
%26 = or i32 %21, 128
store i32 %26, i32* %9
%27 = or i32 %24, 128
br label %29
28: ; preds = %11
store i32 128, i32* %8
store i32 128, i32* %9
br label %29
29: ; preds = %28, %15
%30 = phi i32 [ 128, %28 ], [ %27, %15 ]
store i32 %30, i32* %10
%31 = call i32 @putsSPI2(i32 3, i32* %8)
%32 = icmp eq i32 %13, 2
%33 = add i32 %13, 1
%34 = select i1 %32, i32 0, i32 %33
%35 = add nuw i32 %12, 1
%36 = icmp eq i32 %35, %1
br i1 %36, label %37, label %11
37: ; preds = %29, %3
%38 = call i32 @write_latch(i32 %1)
ret void
}