#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*/ sleep(int /*<<< orphan*/, int);
int /*<<< orphan*/ writeToLED(char *, char *);
void flashNTimes(int times) {
  for (int i = 0; i < times; i++) {
    writeToLED("/sys/class/leds/beaglebone:green:usr0/brightness", "1");
    sleep(0, 100000000);
    writeToLED("/sys/class/leds/beaglebone:green:usr0/brightness", "0");
    sleep(0, 100000000);
  }
}


x86 assembly (clang, -O0):
<flashNTimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118a <flashNTimes+0x6a>
lea    0xebb(%rip),%rdi
lea    0xee5(%rip),%rsi
call   1030 <writeToLED@plt>
xor    %edi,%edi
mov    $0x5f5e100,%esi
call   1040 <sleep@plt>
lea    0xe9c(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1030 <writeToLED@plt>
xor    %edi,%edi
mov    $0x5f5e100,%esi
call   1040 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <flashNTimes+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flashNTimes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1183 <flashNTimes+0x63>
mov    %edi,%ebx
lea    0xecb(%rip),%r14
lea    0xef5(%rip),%r15
lea    0xef0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <writeToLED@plt>
xor    %edi,%edi
mov    $0x5f5e100,%esi
call   1040 <sleep@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <writeToLED@plt>
xor    %edi,%edi
mov    $0x5f5e100,%esi
call   1040 <sleep@plt>
add    $0xffffffff,%ebx
jne    1150 <flashNTimes+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"/sys/class/leds/beaglebone:green:usr0/brightness\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
define void @flashNTimes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %13, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = call i32 @writeToLED(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @sleep(i32 0, i32 100000000)
%11 = call i32 @writeToLED(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @sleep(i32 0, i32 100000000)
br label %13
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"/sys/class/leds/beaglebone:green:usr0/brightness\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
define void @flashNTimes(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %4, label %3
3: ; preds = %4, %1
ret void
4: ; preds = %1, %4
%5 = phi i32 [ %10, %4 ], [ 0, %1 ]
%6 = tail call i32 @writeToLED(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @sleep(i32 0, i32 100000000)
%8 = tail call i32 @writeToLED(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @sleep(i32 0, i32 100000000)
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, %0
br i1 %11, label %3, label %4
}