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

/* Variables and functions */
int GetByte(int /*<<< orphan*/);
int GetPort(int /*<<< orphan*/);
int /*<<< orphan*/ PinGetPIN_A();
int /*<<< orphan*/ PinGetPIN_D();
scalar_t__ PinGetPIN__IORQ();
int /*<<< orphan*/ PinGetPIN__M1();
int /*<<< orphan*/ PinGetPIN__MREQ();
int /*<<< orphan*/ PinGetPIN__RD();
int /*<<< orphan*/ PinGetPIN__WR();
int /*<<< orphan*/ PinSetPIN_D(int);
int /*<<< orphan*/ PinSetPIN__CLK(int);
int /*<<< orphan*/ PinSetPIN__INT(int);
int /*<<< orphan*/ SetByte(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ SetPort(int /*<<< orphan*/, int /*<<< orphan*/);
int CPU_STEP(int intClocks, int doDebug) {
  if (intClocks) {
    PinSetPIN__INT(0);
  } else {
    PinSetPIN__INT(1);
  }
  PinSetPIN__CLK(1);
  if ((!PinGetPIN__M1()) && PinGetPIN__IORQ()) {
    PinSetPIN_D(0xFF);
  }
  if ((!PinGetPIN__MREQ()) && (!PinGetPIN__RD())) {
    uint16_t addr = PinGetPIN_A();
    uint8_t data = GetByte(addr);
    PinSetPIN_D(data);
  }
  if ((!PinGetPIN__IORQ()) && (!PinGetPIN__RD())) {
    uint16_t addr = PinGetPIN_A();
    uint8_t data = GetPort(addr);
    PinSetPIN_D(data);
  }
  if ((!PinGetPIN__MREQ()) && (!PinGetPIN__WR())) {
    SetByte(PinGetPIN_A(), PinGetPIN_D());
  }
  if ((!PinGetPIN__IORQ()) && (!PinGetPIN__WR())) {
    SetPort(PinGetPIN_A(), PinGetPIN_D());
  }
  PinSetPIN__CLK(0);
  return 1;
}


x86 assembly (clang, -O0):
<CPU_STEP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1204 <CPU_STEP+0x24>
xor    %edi,%edi
call   1100 <PinSetPIN__INT@plt>
jmp    120e <CPU_STEP+0x2e>
mov    $0x1,%edi
call   1100 <PinSetPIN__INT@plt>
mov    $0x1,%edi
call   10f0 <PinSetPIN__CLK@plt>
mov    $0x0,%al
call   1090 <PinGetPIN__M1@plt>
cmp    $0x0,%eax
jne    1243 <CPU_STEP+0x63>
mov    $0x0,%al
call   10c0 <PinGetPIN__IORQ@plt>
cmp    $0x0,%rax
je     1243 <CPU_STEP+0x63>
mov    $0xff,%edi
call   1080 <PinSetPIN_D@plt>
mov    $0x0,%al
call   1040 <PinGetPIN__MREQ@plt>
cmp    $0x0,%eax
jne    1280 <CPU_STEP+0xa0>
mov    $0x0,%al
call   10a0 <PinGetPIN__RD@plt>
cmp    $0x0,%eax
jne    1280 <CPU_STEP+0xa0>
mov    $0x0,%al
call   1070 <PinGetPIN_A@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   10d0 <GetByte@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1080 <PinSetPIN_D@plt>
mov    $0x0,%al
call   10c0 <PinGetPIN__IORQ@plt>
cmp    $0x0,%rax
jne    12be <CPU_STEP+0xde>
mov    $0x0,%al
call   10a0 <PinGetPIN__RD@plt>
cmp    $0x0,%eax
jne    12be <CPU_STEP+0xde>
mov    $0x0,%al
call   1070 <PinGetPIN_A@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <GetPort@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <PinSetPIN_D@plt>
mov    $0x0,%al
call   1040 <PinGetPIN__MREQ@plt>
cmp    $0x0,%eax
jne    12f9 <CPU_STEP+0x119>
mov    $0x0,%al
call   1060 <PinGetPIN__WR@plt>
cmp    $0x0,%eax
jne    12f9 <CPU_STEP+0x119>
mov    $0x0,%al
call   1070 <PinGetPIN_A@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10e0 <PinGetPIN_D@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   10b0 <SetByte@plt>
mov    $0x0,%al
call   10c0 <PinGetPIN__IORQ@plt>
cmp    $0x0,%rax
jne    1335 <CPU_STEP+0x155>
mov    $0x0,%al
call   1060 <PinGetPIN__WR@plt>
cmp    $0x0,%eax
jne    1335 <CPU_STEP+0x155>
mov    $0x0,%al
call   1070 <PinGetPIN_A@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   10e0 <PinGetPIN_D@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1030 <SetPort@plt>
xor    %edi,%edi
call   10f0 <PinSetPIN__CLK@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CPU_STEP>:
push   %rbx
xor    %eax,%eax
test   %edi,%edi
sete   %al
mov    %eax,%edi
call   1100 <PinSetPIN__INT@plt>
mov    $0x1,%edi
call   10f0 <PinSetPIN__CLK@plt>
xor    %eax,%eax
call   1090 <PinGetPIN__M1@plt>
test   %eax,%eax
jne    121a <CPU_STEP+0x3a>
xor    %eax,%eax
call   10c0 <PinGetPIN__IORQ@plt>
test   %rax,%rax
je     121a <CPU_STEP+0x3a>
mov    $0xff,%edi
call   1080 <PinSetPIN_D@plt>
xor    %eax,%eax
call   1040 <PinGetPIN__MREQ@plt>
test   %eax,%eax
jne    1245 <CPU_STEP+0x65>
xor    %eax,%eax
call   10a0 <PinGetPIN__RD@plt>
test   %eax,%eax
jne    1245 <CPU_STEP+0x65>
xor    %eax,%eax
call   1070 <PinGetPIN_A@plt>
mov    %eax,%edi
call   10d0 <GetByte@plt>
mov    %eax,%edi
call   1080 <PinSetPIN_D@plt>
xor    %eax,%eax
call   10c0 <PinGetPIN__IORQ@plt>
test   %rax,%rax
jne    1271 <CPU_STEP+0x91>
xor    %eax,%eax
call   10a0 <PinGetPIN__RD@plt>
test   %eax,%eax
jne    1271 <CPU_STEP+0x91>
xor    %eax,%eax
call   1070 <PinGetPIN_A@plt>
mov    %eax,%edi
call   1050 <GetPort@plt>
mov    %eax,%edi
call   1080 <PinSetPIN_D@plt>
xor    %eax,%eax
call   1040 <PinGetPIN__MREQ@plt>
test   %eax,%eax
jne    12a0 <CPU_STEP+0xc0>
xor    %eax,%eax
call   1060 <PinGetPIN__WR@plt>
test   %eax,%eax
jne    12a0 <CPU_STEP+0xc0>
xor    %eax,%eax
call   1070 <PinGetPIN_A@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10e0 <PinGetPIN_D@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <SetByte@plt>
xor    %eax,%eax
call   10c0 <PinGetPIN__IORQ@plt>
test   %rax,%rax
jne    12d0 <CPU_STEP+0xf0>
xor    %eax,%eax
call   1060 <PinGetPIN__WR@plt>
test   %eax,%eax
jne    12d0 <CPU_STEP+0xf0>
xor    %eax,%eax
call   1070 <PinGetPIN_A@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10e0 <PinGetPIN_D@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <SetPort@plt>
xor    %edi,%edi
call   10f0 <PinSetPIN__CLK@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @CPU_STEP(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @PinSetPIN__INT(i32 0)
br label %15
13: ; preds = %2
%14 = call i32 @PinSetPIN__INT(i32 1)
br label %15
15: ; preds = %13, %11
%16 = call i32 @PinSetPIN__CLK(i32 1)
%17 = call i32 (...) @PinGetPIN__M1()
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = call i64 (...) @PinGetPIN__IORQ()
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @PinSetPIN_D(i32 255)
br label %24
24: ; preds = %22, %19, %15
%25 = call i32 (...) @PinGetPIN__MREQ()
%26 = icmp ne i32 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = call i32 (...) @PinGetPIN__RD()
%29 = icmp ne i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = call i32 (...) @PinGetPIN_A()
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = call i32 @GetByte(i32 %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i32 @PinSetPIN_D(i32 %34)
br label %36
36: ; preds = %30, %27, %24
%37 = call i64 (...) @PinGetPIN__IORQ()
%38 = icmp ne i64 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %36
%40 = call i32 (...) @PinGetPIN__RD()
%41 = icmp ne i32 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %39
%43 = call i32 (...) @PinGetPIN_A()
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = call i32 @GetPort(i32 %44)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = call i32 @PinSetPIN_D(i32 %46)
br label %48
48: ; preds = %42, %39, %36
%49 = call i32 (...) @PinGetPIN__MREQ()
%50 = icmp ne i32 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %48
%52 = call i32 (...) @PinGetPIN__WR()
%53 = icmp ne i32 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %51
%55 = call i32 (...) @PinGetPIN_A()
%56 = call i32 (...) @PinGetPIN_D()
%57 = call i32 @SetByte(i32 %55, i32 %56)
br label %58
58: ; preds = %54, %51, %48
%59 = call i64 (...) @PinGetPIN__IORQ()
%60 = icmp ne i64 %59, 0
br i1 %60, label %68, label %61
61: ; preds = %58
%62 = call i32 (...) @PinGetPIN__WR()
%63 = icmp ne i32 %62, 0
br i1 %63, label %68, label %64
64: ; preds = %61
%65 = call i32 (...) @PinGetPIN_A()
%66 = call i32 (...) @PinGetPIN_D()
%67 = call i32 @SetPort(i32 %65, i32 %66)
br label %68
68: ; preds = %64, %61, %58
%69 = call i32 @PinSetPIN__CLK(i32 0)
ret i32 1
}

LLVM IR (-O2):
define i32 @CPU_STEP(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @PinSetPIN__INT(i32 %4)
%6 = tail call i32 @PinSetPIN__CLK(i32 1)
%7 = tail call i32 (...) @PinGetPIN__M1()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = tail call i64 (...) @PinGetPIN__IORQ()
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @PinSetPIN_D(i32 255)
br label %14
14: ; preds = %12, %9, %2
%15 = tail call i32 (...) @PinGetPIN__MREQ()
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = tail call i32 (...) @PinGetPIN__RD()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i32 (...) @PinGetPIN_A()
%22 = tail call i32 @GetByte(i32 %21)
%23 = tail call i32 @PinSetPIN_D(i32 %22)
br label %24
24: ; preds = %20, %17, %14
%25 = tail call i64 (...) @PinGetPIN__IORQ()
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = tail call i32 (...) @PinGetPIN__RD()
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = tail call i32 (...) @PinGetPIN_A()
%32 = tail call i32 @GetPort(i32 %31)
%33 = tail call i32 @PinSetPIN_D(i32 %32)
br label %34
34: ; preds = %30, %27, %24
%35 = tail call i32 (...) @PinGetPIN__MREQ()
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = tail call i32 (...) @PinGetPIN__WR()
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = tail call i32 (...) @PinGetPIN_A()
%42 = tail call i32 (...) @PinGetPIN_D()
%43 = tail call i32 @SetByte(i32 %41, i32 %42)
br label %44
44: ; preds = %40, %37, %34
%45 = tail call i64 (...) @PinGetPIN__IORQ()
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = tail call i32 (...) @PinGetPIN__WR()
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = tail call i32 (...) @PinGetPIN_A()
%52 = tail call i32 (...) @PinGetPIN_D()
%53 = tail call i32 @SetPort(i32 %51, i32 %52)
br label %54
54: ; preds = %50, %47, %44
%55 = tail call i32 @PinSetPIN__CLK(i32 0)
ret i32 1
}