#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*/ delay();
int /*<<< orphan*/ leds_OFF_all();
int /*<<< orphan*/ leds_ON(unsigned short);
void leds_flowing(unsigned int numbers) {
  unsigned short i = 1;
  while (numbers--) {
    for (i = 1; i <= 4; i++) {
      leds_OFF_all();
      leds_ON(i);
      delay();
    }
  }
}


x86 assembly (clang, -O0):
<leds_flowing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movw   $0x1,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1195 <leds_flowing+0x65>
movw   $0x1,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
cmp    $0x4,%eax
jg     1190 <leds_flowing+0x60>
mov    $0x0,%al
call   1050 <leds_OFF_all@plt>
movzwl -0x6(%rbp),%edi
call   1030 <leds_ON@plt>
mov    $0x0,%al
call   1040 <delay@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    115b <leds_flowing+0x2b>
jmp    1141 <leds_flowing+0x11>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leds_flowing>:
push   %rbx
test   %edi,%edi
je     11a5 <leds_flowing+0x75>
mov    %edi,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <leds_OFF_all@plt>
mov    $0x1,%edi
call   1030 <leds_ON@plt>
xor    %eax,%eax
call   1040 <delay@plt>
xor    %eax,%eax
call   1050 <leds_OFF_all@plt>
mov    $0x2,%edi
call   1030 <leds_ON@plt>
xor    %eax,%eax
call   1040 <delay@plt>
xor    %eax,%eax
call   1050 <leds_OFF_all@plt>
mov    $0x3,%edi
call   1030 <leds_ON@plt>
xor    %eax,%eax
call   1040 <delay@plt>
xor    %eax,%eax
call   1050 <leds_OFF_all@plt>
mov    $0x4,%edi
call   1030 <leds_ON@plt>
xor    %eax,%eax
call   1040 <delay@plt>
add    $0xffffffff,%ebx
jne    1140 <leds_flowing+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @leds_flowing(i32 %0) {
%2 = alloca i32
%3 = alloca i16
store i32 %0, i32* %2
store i16 1, i16* %3
br label %4
4: ; preds = %21, %1
%5 = load i32, i32* %2
%6 = add i32 %5, -1
store i32 %6, i32* %2
%7 = icmp ne i32 %5, 0
br i1 %7, label %8, label %22
8: ; preds = %4
store i16 1, i16* %3
br label %9
9: ; preds = %18, %8
%10 = load i16, i16* %3
%11 = zext i16 %10 to i32
%12 = icmp sle i32 %11, 4
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = call i32 (...) @leds_OFF_all()
%15 = load i16, i16* %3
%16 = call i32 @leds_ON(i16 zeroext %15)
%17 = call i32 (...) @delay()
br label %18
18: ; preds = %13
%19 = load i16, i16* %3
%20 = add i16 %19, 1
store i16 %20, i16* %3
br label %9
21: ; preds = %9
br label %4
22: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @leds_flowing(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %19, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %17, %3 ], [ %0, %1 ]
%5 = tail call i32 (...) @leds_OFF_all()
%6 = tail call i32 @leds_ON(i16 zeroext 1)
%7 = tail call i32 (...) @delay()
%8 = tail call i32 (...) @leds_OFF_all()
%9 = tail call i32 @leds_ON(i16 zeroext 2)
%10 = tail call i32 (...) @delay()
%11 = tail call i32 (...) @leds_OFF_all()
%12 = tail call i32 @leds_ON(i16 zeroext 3)
%13 = tail call i32 (...) @delay()
%14 = tail call i32 (...) @leds_OFF_all()
%15 = tail call i32 @leds_ON(i16 zeroext 4)
%16 = tail call i32 (...) @delay()
%17 = add i32 %4, -1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %3
19: ; preds = %3, %1
ret void
}