#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 activecpu_get_icount();
int cpu_getexecutingcpu();
int /*<<< orphan*/ fatalerror(char *, char *, char *, int);
int cycles_left_to_run(void) {
  int activecpu = cpu_getexecutingcpu();
  do {
    if (!(activecpu >= 0))
      fatalerror("Fatal error: %s (%s:%d)",
                 "cycles_left_to_run"
                 "() called with no executing cpu!",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/scs/uclinux/refs/heads/"
                 "master/user/games/xmame/xmame-0.106/src/cpuexec.c",
                 815);
  } while (0);
  return activecpu_get_icount();
}


x86 assembly (clang, -O0):
<cycles_left_to_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <cpu_getexecutingcpu@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    116b <cycles_left_to_run+0x3b>
lea    0xead(%rip),%rdi
lea    0xebe(%rip),%rsi
lea    0xeea(%rip),%rdx
mov    $0x32f,%ecx
call   1050 <fatalerror@plt>
jmp    1170 <cycles_left_to_run+0x40>
mov    $0x0,%al
call   1040 <activecpu_get_icount@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cycles_left_to_run>:
push   %rax
xor    %eax,%eax
call   1030 <cpu_getexecutingcpu@plt>
test   %eax,%eax
jns    115b <cycles_left_to_run+0x2b>
lea    0xebd(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xefa(%rip),%rdx
mov    $0x32f,%ecx
call   1050 <fatalerror@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <activecpu_get_icount@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Fatal error: %s (%s:%d)\00"
@.str.1 = [51 x i8] c"cycles_left_to_run() called with no executing cpu!\00"
@.str.2 = [163 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/scs/uclinux/refs/heads/master/user/games/xmame/xmame-0.106/src/cpuexec.c\00"
define i32 @cycles_left_to_run() {
%1 = alloca i32
%2 = call i32 (...) @cpu_getexecutingcpu()
store i32 %2, i32* %1
br label %3
3: ; preds = %0
%4 = load i32, i32* %1
%5 = icmp sge i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = call i32 @fatalerror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.2, i64 0, i64 0), i32 815)
br label %8
8: ; preds = %6, %3
br label %9
9: ; preds = %8
%10 = call i32 (...) @activecpu_get_icount()
ret i32 %10
}

LLVM IR (-O2):
@.str = [24 x i8] c"Fatal error: %s (%s:%d)\00"
@.str.1 = [51 x i8] c"cycles_left_to_run() called with no executing cpu!\00"
@.str.2 = [163 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/scs/uclinux/refs/heads/master/user/games/xmame/xmame-0.106/src/cpuexec.c\00"
define i32 @cycles_left_to_run() {
%1 = tail call i32 (...) @cpu_getexecutingcpu()
%2 = icmp sgt i32 %1, -1
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @fatalerror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.2, i64 0, i64 0), i32 815)
br label %5
5: ; preds = %3, %0
%6 = tail call i32 (...) @activecpu_get_icount()
ret i32 %6
}