#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*/ enableBranchPrediction();
int /*<<< orphan*/ enableCaches();
int /*<<< orphan*/ mnist_cnn_eval(unsigned int *, unsigned int *);
int /*<<< orphan*/ monitorInit();
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ setDecodeRegionNS(int, unsigned int);
int /*<<< orphan*/ yield();
int main(void) {
  unsigned int tmp;
  unsigned int inference;
  enableBranchPrediction();
  enableCaches();
  tmp = (1) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) |
        (1 << 7);
  setDecodeRegionNS(0, tmp);
  setDecodeRegionNS(1, tmp);
  setDecodeRegionNS(2, tmp);
  monitorInit();
  mnist_cnn_eval(((unsigned int *)0x80370000), &inference);
  printf("Inference from Secure world: %d\n", inference);
  yield();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <enableBranchPrediction@plt>
mov    $0x0,%al
call   1070 <enableCaches@plt>
movl   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%esi
xor    %edi,%edi
call   1080 <setDecodeRegionNS@plt>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1080 <setDecodeRegionNS@plt>
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1080 <setDecodeRegionNS@plt>
mov    $0x0,%al
call   1030 <monitorInit@plt>
mov    $0x80370000,%edi
lea    -0xc(%rbp),%rsi
call   1050 <mnist_cnn_eval@plt>
mov    -0xc(%rbp),%esi
lea    0xe29(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <yield@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1090 <enableBranchPrediction@plt>
xor    %eax,%eax
call   1070 <enableCaches@plt>
xor    %edi,%edi
mov    $0xff,%esi
call   1080 <setDecodeRegionNS@plt>
mov    $0x1,%edi
mov    $0xff,%esi
call   1080 <setDecodeRegionNS@plt>
mov    $0x2,%edi
mov    $0xff,%esi
call   1080 <setDecodeRegionNS@plt>
xor    %eax,%eax
call   1030 <monitorInit@plt>
lea    0x4(%rsp),%rsi
mov    $0x80370000,%edi
call   1050 <mnist_cnn_eval@plt>
mov    0x4(%rsp),%esi
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <yield@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Inference from Secure world: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @enableBranchPrediction()
%5 = call i32 (...) @enableCaches()
store i32 255, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @setDecodeRegionNS(i32 0, i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @setDecodeRegionNS(i32 1, i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @setDecodeRegionNS(i32 2, i32 %10)
%12 = call i32 (...) @monitorInit()
%13 = call i32 @mnist_cnn_eval(i32* inttoptr (i64 2151088128 to i32*), i32* %3)
%14 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @yield()
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Inference from Secure world: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @enableBranchPrediction()
%4 = tail call i32 (...) @enableCaches()
%5 = tail call i32 @setDecodeRegionNS(i32 0, i32 255)
%6 = tail call i32 @setDecodeRegionNS(i32 1, i32 255)
%7 = tail call i32 @setDecodeRegionNS(i32 2, i32 255)
%8 = tail call i32 (...) @monitorInit()
%9 = call i32 @mnist_cnn_eval(i32* inttoptr (i64 2151088128 to i32*), i32* %1)
%10 = load i32, i32* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (...) @yield()
ret i32 0
}