#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*/ gpio_set(int, int);
int /*<<< orphan*/ gpio_set_function(int, int);
unsigned long sys_timer_get_counter();
int /*<<< orphan*/ sys_timer_wait(unsigned int);
void blinker(unsigned int t_on, unsigned int t_off, unsigned int blink_time) {
  unsigned long stop_time = sys_timer_get_counter() + blink_time * 1000000;
  gpio_set_function(16, 1);
  while (sys_timer_get_counter() < stop_time) {
    gpio_set(16, 0);
    sys_timer_wait(t_on);
    gpio_set(16, 1);
    sys_timer_wait(t_off);
  }
}


x86 assembly (clang, -O0):
<blinker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1040 <sys_timer_get_counter@plt>
imul   $0xf4240,-0xc(%rbp),%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    $0x10,%edi
mov    $0x1,%esi
call   1030 <gpio_set_function@plt>
mov    $0x0,%al
call   1040 <sys_timer_get_counter@plt>
cmp    -0x18(%rbp),%rax
jae    11b8 <blinker+0x78>
mov    $0x10,%edi
xor    %esi,%esi
call   1050 <gpio_set@plt>
mov    -0x4(%rbp),%edi
call   1060 <sys_timer_wait@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1050 <gpio_set@plt>
mov    -0x8(%rbp),%edi
call   1060 <sys_timer_wait@plt>
jmp    1177 <blinker+0x37>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blinker>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <sys_timer_get_counter@plt>
imul   $0xf4240,%r14d,%ebx
add    %rax,%rbx
mov    $0x10,%edi
mov    $0x1,%esi
call   1030 <gpio_set_function@plt>
nop
xor    %eax,%eax
call   1040 <sys_timer_get_counter@plt>
cmp    %rbx,%rax
jae    11a8 <blinker+0x68>
mov    $0x10,%edi
xor    %esi,%esi
call   1050 <gpio_set@plt>
mov    %ebp,%edi
call   1060 <sys_timer_wait@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1050 <gpio_set@plt>
mov    %r15d,%edi
call   1060 <sys_timer_wait@plt>
jmp    1170 <blinker+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @blinker(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i64 (...) @sys_timer_get_counter()
%9 = load i32, i32* %6
%10 = mul i32 %9, 1000000
%11 = zext i32 %10 to i64
%12 = add i64 %8, %11
store i64 %12, i64* %7
%13 = call i32 @gpio_set_function(i32 16, i32 1)
br label %14
14: ; preds = %18, %3
%15 = call i64 (...) @sys_timer_get_counter()
%16 = load i64, i64* %7
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = call i32 @gpio_set(i32 16, i32 0)
%20 = load i32, i32* %4
%21 = call i32 @sys_timer_wait(i32 %20)
%22 = call i32 @gpio_set(i32 16, i32 1)
%23 = load i32, i32* %5
%24 = call i32 @sys_timer_wait(i32 %23)
br label %14
25: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @blinker(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 (...) @sys_timer_get_counter()
%5 = mul i32 %2, 1000000
%6 = zext i32 %5 to i64
%7 = add i64 %4, %6
%8 = tail call i32 @gpio_set_function(i32 16, i32 1)
%9 = tail call i64 (...) @sys_timer_get_counter()
%10 = icmp ult i64 %9, %7
br i1 %10, label %11, label %18
11: ; preds = %3, %11
%12 = tail call i32 @gpio_set(i32 16, i32 0)
%13 = tail call i32 @sys_timer_wait(i32 %0)
%14 = tail call i32 @gpio_set(i32 16, i32 1)
%15 = tail call i32 @sys_timer_wait(i32 %1)
%16 = tail call i64 (...) @sys_timer_get_counter()
%17 = icmp ult i64 %16, %7
br i1 %17, label %11, label %18
18: ; preds = %11, %3
ret void
}