#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*/ launch_core(int);
int /*<<< orphan*/ uart_puts(char *);
int wait_core();
void test_one(int cpu) {
  int stat;
  *(volatile unsigned long *)4 = 0xdeadbeef;
  uart_puts("Starting core ...\n");
  launch_core(cpu);
  stat = wait_core();
  if (stat)
    uart_puts(" Core verified to start\n");
  else
    uart_puts("** Core failed to start\n");
  *((volatile unsigned long *)(0x01f01c00 + 0x1A4)) = 0;
}


x86 assembly (clang, -O0):
<test_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x4,%eax
mov    $0xdeadbeef,%ecx
mov    %rcx,(%rax)
lea    0xeb1(%rip),%rdi
call   1040 <uart_puts@plt>
mov    -0x4(%rbp),%edi
call   1030 <launch_core@plt>
mov    $0x0,%al
call   1050 <wait_core@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1181 <test_one+0x51>
lea    0xe9c(%rip),%rdi
call   1040 <uart_puts@plt>
jmp    118d <test_one+0x5d>
lea    0xea4(%rip),%rdi
call   1040 <uart_puts@plt>
mov    $0x1f01da4,%eax
movq   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_one>:
push   %rbx
mov    %edi,%ebx
mov    $0xdeadbeef,%eax
mov    %rax,0x4
lea    0xeb9(%rip),%rdi
call   1040 <uart_puts@plt>
mov    %ebx,%edi
call   1030 <launch_core@plt>
xor    %eax,%eax
call   1050 <wait_core@plt>
test   %eax,%eax
lea    0xec9(%rip),%rax
lea    0xea9(%rip),%rdi
cmove  %rax,%rdi
call   1040 <uart_puts@plt>
movq   $0x0,0x1f01da4
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Starting core ...\0A\00"
@.str.1 = [25 x i8] c" Core verified to start\0A\00"
@.str.2 = [25 x i8] c"** Core failed to start\0A\00"
define void @test_one(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store volatile i64 3735928559, i64* inttoptr (i64 4 to i64*)
%4 = call i32 @uart_puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @launch_core(i32 %5)
%7 = call i32 (...) @wait_core()
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @uart_puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %1
%13 = call i32 @uart_puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
store volatile i64 0, i64* inttoptr (i64 32513444 to i64*)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Starting core ...\0A\00"
@.str.1 = [25 x i8] c" Core verified to start\0A\00"
@.str.2 = [25 x i8] c"** Core failed to start\0A\00"
define void @test_one(i32 %0) {
store volatile i64 3735928559, i64* inttoptr (i64 4 to i64*)
%2 = tail call i32 @uart_puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @launch_core(i32 %0)
%4 = tail call i32 (...) @wait_core()
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32 @uart_puts(i8* %6)
store volatile i64 0, i64* inttoptr (i64 32513444 to i64*)
ret void
}