#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 */
typedef int /*<<< orphan*/ jmp_buf;

/* Variables and functions */
int /*<<< orphan*/ cpuSetInterrupt(int);
int /*<<< orphan*/ execNextInstruction();
int /*<<< orphan*/ handleInterrupts();
int /*<<< orphan*/ popEnvironment();
int /*<<< orphan*/ pushEnvironment(int /*<<< orphan*/ *);
int setjmp(int /*<<< orphan*/);
int /*<<< orphan*/ timerTick();
void cpuStep(void) {
  jmp_buf myEnvironment;
  int exception;
  exception = setjmp(myEnvironment);
  if (exception == 0) {
    pushEnvironment(&myEnvironment);
    timerTick();
    execNextInstruction();
    handleInterrupts();
  } else {
    cpuSetInterrupt(exception);
    handleInterrupts();
  }
  popEnvironment();
}


x86 assembly (clang, -O0):
<cpuStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    -0x4(%rbp),%edi
call   1070 <setjmp@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <cpuStep+0x40>
lea    -0x4(%rbp),%rdi
call   1060 <pushEnvironment@plt>
mov    $0x0,%al
call   1090 <timerTick@plt>
mov    $0x0,%al
call   1040 <execNextInstruction@plt>
mov    $0x0,%al
call   1080 <handleInterrupts@plt>
jmp    11bf <cpuStep+0x4f>
mov    -0x8(%rbp),%edi
call   1050 <cpuSetInterrupt@plt>
mov    $0x0,%al
call   1080 <handleInterrupts@plt>
mov    $0x0,%al
call   1030 <popEnvironment@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuStep>:
push   %rbx
sub    $0x10,%rsp
call   1070 <setjmp@plt>
test   %eax,%eax
je     1187 <cpuStep+0x17>
mov    %eax,%edi
call   1050 <cpuSetInterrupt@plt>
jmp    11a1 <cpuStep+0x31>
lea    0xc(%rsp),%rdi
call   1060 <pushEnvironment@plt>
xor    %eax,%eax
mov    %eax,%ebx
call   1090 <timerTick@plt>
mov    %ebx,%eax
call   1040 <execNextInstruction@plt>
xor    %eax,%eax
mov    %eax,%ebx
call   1080 <handleInterrupts@plt>
mov    %ebx,%eax
call   1030 <popEnvironment@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @cpuStep() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* %1
%4 = call i32 @setjmp(i32 %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = call i32 @pushEnvironment(i32* %1)
%9 = call i32 (...) @timerTick()
%10 = call i32 (...) @execNextInstruction()
%11 = call i32 (...) @handleInterrupts()
br label %16
12: ; preds = %0
%13 = load i32, i32* %2
%14 = call i32 @cpuSetInterrupt(i32 %13)
%15 = call i32 (...) @handleInterrupts()
br label %16
16: ; preds = %12, %7
%17 = call i32 (...) @popEnvironment()
ret void
}

LLVM IR (-O2):
define void @cpuStep() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @setjmp(i32 undef)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @pushEnvironment(i32* %1)
%7 = call i32 (...) @timerTick()
%8 = call i32 (...) @execNextInstruction()
br label %11
9: ; preds = %0
%10 = call i32 @cpuSetInterrupt(i32 %3)
br label %11
11: ; preds = %9, %5
%12 = call i32 (...) @handleInterrupts()
%13 = call i32 (...) @popEnvironment()
ret void
}