#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(0x40025000, 0x01, 1);
  } else {
    led_toggle_state = 0;
    GPIOPinWrite(0x40025000, 0x01, 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    $0x40025000,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <GPIOPinWrite@plt>
jmp    1194 <LedToggle+0x74>
movb   $0x0,0x2eb5(%rip)
mov    $0x40025000,%edi
mov    $0x1,%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     1160 <LedToggle+0x40>
movzbl 0x2ef7(%rip),%edx
xor    $0x1,%edx
mov    %dl,0x2eee(%rip)
mov    $0x40025000,%edi
mov    $0x1,%esi
call   1030 <GPIOPinWrite@plt>
mov    %rbx,0x2ee0(%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 1073893376, i32 1, i32 1)
br label %16
14: ; preds = %8
store i8 0, i8* @LedToggle.led_toggle_state
%15 = call i32 @GPIOPinWrite(i32 1073893376, i32 1, 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 %11, label %5
5: ; preds = %0
%6 = load i1, i1* @LedToggle.led_toggle_state
%7 = xor i1 %6, true
%8 = xor i1 %6, true
%9 = zext i1 %8 to i32
store i1 %7, i1* @LedToggle.led_toggle_state
%10 = tail call i32 @GPIOPinWrite(i32 1073893376, i32 1, i32 %9)
store i64 %1, i64* @LedToggle.timer_counter_last
br label %11
11: ; preds = %0, %5
ret void
}