#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int cos8(int);
int rand();
int tempColor(int, int);
void updateStars(uint32_t *LED, uint8_t brightness) {
  static uint32_t updateCounter = 0;
  static uint32_t starBrightness[50] = {0};
  static uint32_t starColor[50] = {0};
  static uint32_t starCount[50] = {0};
  static uint32_t starLED[50] = {0};
  static uint32_t starLength[50] = {0};
  if (updateCounter == 0) {
    updateCounter = 1;
    for (uint32_t ii = 0; ii < 50; ii++) {
      if (starCount[ii] == 0) {
        LED[starLED[ii]] = 0;
        do {
          starLED[ii] = rand() % (16 * 16);
        } while (LED[starLED[ii]] != 0);
        starLength[ii] = (rand() % (4000 - 400) + 400) * 60 / 256;
        starBrightness[ii] = rand() % (255 - 50) + 50;
        starColor[ii] = rand() % 256;
        starCount[ii] = starLength[ii];
      }
      uint32_t thisBrightness =
          brightness * starBrightness[ii] *
          cos8(256 * starCount[ii] / starLength[ii] + 128) / 255 / 255;
      LED[starLED[ii]] =
          tempColor(80 + (165 - 80) * starColor[ii] / 255, thisBrightness);
      starCount[ii]--;
    }
  }
  updateCounter--;
}


x86 assembly (clang, -O0):
<updateStars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,0x2f0a(%rip)
jne    1320 <updateStars+0x1f0>
movl   $0x1,0x2efa(%rip)
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    131b <updateStars+0x1eb>
movslq -0x10(%rbp),%rcx
lea    0x308e(%rip),%rax
cmpl   $0x0,(%rax,%rcx,4)
jne    1259 <updateStars+0x129>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
lea    0x3145(%rip),%rcx
movslq (%rcx,%rdx,4),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
movslq -0x10(%rbp),%rcx
lea    0x3120(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
lea    0x310e(%rip),%rcx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1196 <updateStars+0x66>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xe10,%ecx
cltd
idiv   %ecx
add    $0x190,%edx
imul   $0x3c,%edx,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
movslq -0x10(%rbp),%rcx
lea    0x31a3(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xcd,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
movslq -0x10(%rbp),%rcx
lea    0x2e43(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
movslq -0x10(%rbp),%rcx
lea    0x2ef6(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x10(%rbp),%rcx
lea    0x3158(%rip),%rax
mov    (%rax,%rcx,4),%edx
movslq -0x10(%rbp),%rcx
lea    0x2faa(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
movslq -0x10(%rbp),%rdx
lea    0x2df9(%rip),%rcx
imul   (%rcx,%rdx,4),%eax
mov    %eax,-0x18(%rbp)
movslq -0x10(%rbp),%rcx
lea    0x2f87(%rip),%rax
mov    (%rax,%rcx,4),%eax
shl    $0x8,%eax
movslq -0x10(%rbp),%rsi
lea    0x3116(%rip),%rcx
cltd
idivl  (%rcx,%rsi,4)
mov    %eax,%edi
add    $0x80,%edi
call   1030 <cos8@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movslq -0x10(%rbp),%rcx
lea    0x2e6f(%rip),%rax
imul   $0x55,(%rax,%rcx,4),%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x50,%edi
mov    -0x14(%rbp),%esi
call   1040 <tempColor@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rsi
lea    0x2fe5(%rip),%rcx
movslq (%rcx,%rsi,4),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x10(%rbp),%rcx
lea    0x2f03(%rip),%rax
mov    (%rax,%rcx,4),%edx
add    $0xffffffff,%edx
lea    0x2ef6(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <updateStars+0x2d>
jmp    1320 <updateStars+0x1f0>
mov    0x2d2a(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2d21(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateStars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2f0f(%rip),%eax
test   %eax,%eax
jne    1316 <updateStars+0x1e6>
mov    %rdi,%rbx
movl   $0x1,0x2efa(%rip)
lea    0x30a3(%rip),%r15
lea    0x316c(%rip),%rbp
lea    0x2fc5(%rip),%r14
xor    %r13d,%r13d
mov    %esi,0x4(%rsp)
jmp    1210 <updateStars+0xe0>
nopw   0x0(%rax,%rax,1)
lea    0x3219(%rip),%rcx
mov    (%rcx,%r13,4),%ecx
lea    0x2ece(%rip),%rdx
mov    (%rdx,%r13,4),%r12d
imul   %esi,%r12d
shl    $0x8,%eax
cltd
idiv   %ecx
lea    0x80(%rax),%edi
mov    %esi,%ebp
call   1030 <cos8@plt>
imul   %r12d,%eax
movslq %eax,%rsi
imul   $0xffffffff81018203,%rsi,%rax
shr    $0x20,%rax
add    %eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0xf,%esi
add    %eax,%esi
movslq (%r14,%r13,4),%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x20,%rcx
shr    $0x3f,%rax
lea    (%rcx,%rax,1),%edi
add    $0x50,%edi
call   1040 <tempColor@plt>
mov    %ebp,%esi
lea    0x30db(%rip),%rbp
movslq 0x0(%rbp,%r13,4),%rcx
mov    %eax,(%rbx,%rcx,4)
addl   $0xffffffff,(%r15,%r13,4)
add    $0x1,%r13
cmp    $0x32,%r13
je     1310 <updateStars+0x1e0>
mov    (%r15,%r13,4),%eax
test   %eax,%eax
jne    1180 <updateStars+0x50>
movslq 0x0(%rbp,%r13,4),%rax
movl   $0x0,(%rbx,%rax,4)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    %eax,0x0(%rbp,%r13,4)
cltq
cmpl   $0x0,(%rbx,%rax,4)
jne    1230 <updateStars+0x100>
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xb,%ecx
add    %edx,%ecx
imul   $0xe10,%ecx,%ecx
sub    %ecx,%eax
imul   $0x3c,%eax,%eax
lea    0x5dc0(%rax),%ecx
add    $0x5ebf,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x8,%eax
lea    0x3104(%rip),%r12
mov    %eax,(%r12,%r13,4)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4fec04ff,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0xcd,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x32,%eax
lea    0x2d8f(%rip),%r14
mov    %eax,(%r14,%r13,4)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %r14,%rdx
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
lea    0x2e37(%rip),%r14
mov    %eax,(%r14,%r13,4)
mov    (%r12,%r13,4),%ecx
mov    %ecx,(%r15,%r13,4)
mov    %ecx,%eax
mov    0x4(%rsp),%esi
jmp    1192 <updateStars+0x62>
mov    0x2d3a(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2d31(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@updateStars.updateCounter = internal global i32 0
@updateStars.starBrightness = internal global [50 x i32] zeroinitializer
@updateStars.starColor = internal global [50 x i32] zeroinitializer
@updateStars.starCount = internal global [50 x i32] zeroinitializer
@updateStars.starLED = internal global [50 x i32] zeroinitializer
@updateStars.starLength = internal global [50 x i32] zeroinitializer
define void @updateStars(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* @updateStars.updateCounter
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %117
9: ; preds = %2
store i32 1, i32* @updateStars.updateCounter
store i32 0, i32* %5
br label %10
10: ; preds = %113, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 50
br i1 %12, label %13, label %116
13: ; preds = %10
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starCount, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %70
19: ; preds = %13
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %20, i64 %25
store i32 0, i32* %26
br label %27
27: ; preds = %33, %19
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 256
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %31
store i32 %29, i32* %32
br label %33
33: ; preds = %27
%34 = load i32*, i32** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %34, i64 %39
%41 = load i32, i32* %40
%42 = icmp ne i32 %41, 0
br i1 %42, label %27, label %43
43: ; preds = %33
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 3600
%46 = add nsw i32 %45, 400
%47 = mul nsw i32 %46, 60
%48 = sdiv i32 %47, 256
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLength, i64 0, i64 %50
store i32 %48, i32* %51
%52 = call i32 (...) @rand()
%53 = srem i32 %52, 205
%54 = add nsw i32 %53, 50
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starBrightness, i64 0, i64 %56
store i32 %54, i32* %57
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 256
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starColor, i64 0, i64 %61
store i32 %59, i32* %62
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLength, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starCount, i64 0, i64 %68
store i32 %66, i32* %69
br label %70
70: ; preds = %43, %13
%71 = load i32, i32* %4
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starBrightness, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = mul nsw i32 %71, %75
%77 = load i32, i32* %5
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starCount, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = mul nsw i32 256, %80
%82 = load i32, i32* %5
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLength, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = sdiv i32 %81, %85
%87 = add nsw i32 %86, 128
%88 = call i32 @cos8(i32 %87)
%89 = mul nsw i32 %76, %88
%90 = sdiv i32 %89, 255
%91 = sdiv i32 %90, 255
store i32 %91, i32* %6
%92 = load i32, i32* %5
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starColor, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = mul nsw i32 85, %95
%97 = sdiv i32 %96, 255
%98 = add nsw i32 80, %97
%99 = load i32, i32* %6
%100 = call i32 @tempColor(i32 %98, i32 %99)
%101 = load i32*, i32** %3
%102 = load i32, i32* %5
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %103
%105 = load i32, i32* %104
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i32, i32* %101, i64 %106
store i32 %100, i32* %107
%108 = load i32, i32* %5
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starCount, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = add nsw i32 %111, -1
store i32 %112, i32* %110
br label %113
113: ; preds = %70
%114 = load i32, i32* %5
%115 = add nsw i32 %114, 1
store i32 %115, i32* %5
br label %10
116: ; preds = %10
br label %117
117: ; preds = %116, %2
%118 = load i32, i32* @updateStars.updateCounter
%119 = add nsw i32 %118, -1
store i32 %119, i32* @updateStars.updateCounter
ret void
}

LLVM IR (-O2):
@updateStars.updateCounter = internal unnamed_addr global i32 0
@updateStars.starBrightness = internal unnamed_addr global [50 x i32] zeroinitializer
@updateStars.starColor = internal unnamed_addr global [50 x i32] zeroinitializer
@updateStars.starCount = internal unnamed_addr global [50 x i32] zeroinitializer
@updateStars.starLED = internal unnamed_addr global [50 x i32] zeroinitializer
@updateStars.starLength = internal unnamed_addr global [50 x i32] zeroinitializer
define void @updateStars(i32* nocapture %0, i32 %1) {
%3 = load i32, i32* @updateStars.updateCounter
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %68
5: ; preds = %2
store i32 1, i32* @updateStars.updateCounter
br label %6
6: ; preds = %5, %41
%7 = phi i64 [ 0, %5 ], [ %64, %41 ]
%8 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starCount, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLength, i64 0, i64 %7
%13 = load i32, i32* %12
br label %41
14: ; preds = %6
%15 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %7
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %0, i64 %17
store i32 0, i32* %18
br label %19
19: ; preds = %19, %14
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 256
store i32 %21, i32* %15
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %19
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 3600
%29 = mul nsw i32 %28, 60
%30 = add nsw i32 %29, 24000
%31 = sdiv i32 %30, 256
%32 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLength, i64 0, i64 %7
store i32 %31, i32* %32
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 205
%35 = add nsw i32 %34, 50
%36 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starBrightness, i64 0, i64 %7
store i32 %35, i32* %36
%37 = tail call i32 (...) @rand()
%38 = srem i32 %37, 256
%39 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starColor, i64 0, i64 %7
store i32 %38, i32* %39
%40 = load i32, i32* %32
store i32 %40, i32* %8
br label %41
41: ; preds = %11, %26
%42 = phi i32 [ %40, %26 ], [ %13, %11 ]
%43 = phi i32 [ %40, %26 ], [ %9, %11 ]
%44 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starBrightness, i64 0, i64 %7
%45 = load i32, i32* %44
%46 = mul nsw i32 %45, %1
%47 = shl nsw i32 %43, 8
%48 = sdiv i32 %47, %42
%49 = add nsw i32 %48, 128
%50 = tail call i32 @cos8(i32 %49)
%51 = mul nsw i32 %46, %50
%52 = sdiv i32 %51, 65025
%53 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starColor, i64 0, i64 %7
%54 = load i32, i32* %53
%55 = sdiv i32 %54, 3
%56 = add nsw i32 %55, 80
%57 = tail call i32 @tempColor(i32 %56, i32 %52)
%58 = getelementptr inbounds [50 x i32], [50 x i32]* @updateStars.starLED, i64 0, i64 %7
%59 = load i32, i32* %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %0, i64 %60
store i32 %57, i32* %61
%62 = load i32, i32* %8
%63 = add nsw i32 %62, -1
store i32 %63, i32* %8
%64 = add nuw nsw i64 %7, 1
%65 = icmp eq i64 %64, 50
br i1 %65, label %66, label %6
66: ; preds = %41
%67 = load i32, i32* @updateStars.updateCounter
br label %68
68: ; preds = %66, %2
%69 = phi i32 [ %67, %66 ], [ %3, %2 ]
%70 = add nsw i32 %69, -1
store i32 %70, i32* @updateStars.updateCounter
ret void
}