#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 GetTimer(int);
int /*<<< orphan*/ PresetTimer(int, int /*<<< orphan*/);
int /*<<< orphan*/ PrintToScreen(char *, int);
int /*<<< orphan*/ SetMotor(int, int /*<<< orphan*/);
void onTimer(void) {
  int currtime = GetTimer(1);
  if (currtime >= 500) {
    SetMotor(1, 0);
    SetMotor(2, 0);
    SetMotor(3, 0);
    SetMotor(4, 0);
    SetMotor(5, 0);
    SetMotor(6, 0);
    SetMotor(7, 0);
    SetMotor(8, 0);
    SetMotor(9, 0);
    SetMotor(10, 0);
    PrintToScreen("Emergency stop! %i\n", currtime);
    PresetTimer(1, 0);
  }
}


x86 assembly (clang, -O0):
<onTimer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1030 <GetTimer@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jl     11f5 <onTimer+0xb5>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x7,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0xa,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    -0x4(%rbp),%esi
lea    0xe1c(%rip),%rdi
call   1060 <PrintToScreen@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1050 <PresetTimer@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onTimer>:
push   %rbx
mov    $0x1,%edi
call   1030 <GetTimer@plt>
cmp    $0x1f4,%eax
jl     11eb <onTimer+0xab>
mov    %eax,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x7,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
mov    $0xa,%edi
xor    %esi,%esi
call   1040 <SetMotor@plt>
lea    0xe29(%rip),%rdi
mov    %ebx,%esi
call   1060 <PrintToScreen@plt>
mov    $0x1,%edi
xor    %esi,%esi
pop    %rbx
jmp    1050 <PresetTimer@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Emergency stop! %i\0A\00"
define void @onTimer() {
%1 = alloca i32
%2 = call i32 @GetTimer(i32 1)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp sge i32 %3, 500
br i1 %4, label %5, label %19
5: ; preds = %0
%6 = call i32 @SetMotor(i32 1, i32 0)
%7 = call i32 @SetMotor(i32 2, i32 0)
%8 = call i32 @SetMotor(i32 3, i32 0)
%9 = call i32 @SetMotor(i32 4, i32 0)
%10 = call i32 @SetMotor(i32 5, i32 0)
%11 = call i32 @SetMotor(i32 6, i32 0)
%12 = call i32 @SetMotor(i32 7, i32 0)
%13 = call i32 @SetMotor(i32 8, i32 0)
%14 = call i32 @SetMotor(i32 9, i32 0)
%15 = call i32 @SetMotor(i32 10, i32 0)
%16 = load i32, i32* %1
%17 = call i32 @PrintToScreen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @PresetTimer(i32 1, i32 0)
br label %19
19: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Emergency stop! %i\0A\00"
define void @onTimer() {
%1 = tail call i32 @GetTimer(i32 1)
%2 = icmp sgt i32 %1, 499
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = tail call i32 @SetMotor(i32 1, i32 0)
%5 = tail call i32 @SetMotor(i32 2, i32 0)
%6 = tail call i32 @SetMotor(i32 3, i32 0)
%7 = tail call i32 @SetMotor(i32 4, i32 0)
%8 = tail call i32 @SetMotor(i32 5, i32 0)
%9 = tail call i32 @SetMotor(i32 6, i32 0)
%10 = tail call i32 @SetMotor(i32 7, i32 0)
%11 = tail call i32 @SetMotor(i32 8, i32 0)
%12 = tail call i32 @SetMotor(i32 9, i32 0)
%13 = tail call i32 @SetMotor(i32 10, i32 0)
%14 = tail call i32 @PrintToScreen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %1)
%15 = tail call i32 @PresetTimer(i32 1, i32 0)
br label %16
16: ; preds = %3, %0
ret void
}