#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*/ GPIOPinWrite(int, int, int);
unsigned long TimeGet();
void LedToggle(void) {
  static unsigned char led_toggle_state = 0;
  static unsigned long timer_counter_last = 0;
  unsigned long timer_counter_now;
  timer_counter_now = TimeGet();
  if ((timer_counter_now - timer_counter_last) < (500)) {
    return;
  }
  if (led_toggle_state == 0) {
    led_toggle_state = 1;
    GPIOPinWrite(0x40026000, 0x00000004, 0x00000004);
  } else {
    led_toggle_state = 0;
    GPIOPinWrite(0x40026000, 0x00000004, 0);
  }
  timer_counter_last = timer_counter_now;
}


x86 assembly (clang, -O0):
<LedToggle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <TimeGet@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
sub    0x2f02(%rip),%rax
cmp    $0x1f4,%rax
jae    114f <LedToggle+0x2f>
jmp    119f <LedToggle+0x7f>
movzbl 0x2ee2(%rip),%eax
cmp    $0x0,%eax
jne    117c <LedToggle+0x5c>
movb   $0x1,0x2ed2(%rip)
mov    $0x40026000,%edi
mov    $0x4,%edx
mov    %edx,%esi
call   1030 <GPIOPinWrite@plt>
jmp    1194 <LedToggle+0x74>
movb   $0x0,0x2eb5(%rip)
mov    $0x40026000,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x8(%rbp),%rax
mov    %rax,0x2ea1(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LedToggle>:
push   %rbx
xor    %eax,%eax
call   1040 <TimeGet@plt>
mov    %rax,%rbx
sub    0x2f0e(%rip),%rax
cmp    $0x1f4,%rax
jb     1167 <LedToggle+0x47>
movzbl 0x2ef7(%rip),%eax
xor    $0x1,%eax
lea    0x0(,%rax,4),%edx
mov    %al,0x2ee7(%rip)
mov    $0x40026000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    %rbx,0x2ed9(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@LedToggle.led_toggle_state = internal global i8 0
@LedToggle.timer_counter_last = internal global i64 0
define void @LedToggle() {
%1 = alloca i64
%2 = call i64 (...) @TimeGet()
store i64 %2, i64* %1
%3 = load i64, i64* %1
%4 = load i64, i64* @LedToggle.timer_counter_last
%5 = sub i64 %3, %4
%6 = icmp ult i64 %5, 500
br i1 %6, label %7, label %8
7: ; preds = %0
br label %18
8: ; preds = %0
%9 = load i8, i8* @LedToggle.led_toggle_state
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
store i8 1, i8* @LedToggle.led_toggle_state
%13 = call i32 @GPIOPinWrite(i32 1073897472, i32 4, i32 4)
br label %16
14: ; preds = %8
store i8 0, i8* @LedToggle.led_toggle_state
%15 = call i32 @GPIOPinWrite(i32 1073897472, i32 4, i32 0)
br label %16
16: ; preds = %14, %12
%17 = load i64, i64* %1
store i64 %17, i64* @LedToggle.timer_counter_last
br label %18
18: ; preds = %16, %7
ret void
}

LLVM IR (-O2):
@LedToggle.led_toggle_state = internal unnamed_addr global i1 false
@LedToggle.timer_counter_last = internal unnamed_addr global i64 0
define void @LedToggle() {
%1 = tail call i64 (...) @TimeGet()
%2 = load i64, i64* @LedToggle.timer_counter_last
%3 = sub i64 %1, %2
%4 = icmp ult i64 %3, 500
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = load i1, i1* @LedToggle.led_toggle_state
%7 = xor i1 %6, true
%8 = select i1 %6, i32 0, i32 4
store i1 %7, i1* @LedToggle.led_toggle_state
%9 = tail call i32 @GPIOPinWrite(i32 1073897472, i32 4, i32 %8)
store i64 %1, i64* @LedToggle.timer_counter_last
br label %10
10: ; preds = %0, %5
ret void
}