#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ oosmos_DelayMS(int);
int oosmos_GetFreeRunningUS();
int /*<<< orphan*/ printf(char *, ...);
extern int main(void) {
  printf("Delaying %d milliseconds...\n", 3000);
  const uint32_t Start = oosmos_GetFreeRunningUS();
  oosmos_DelayMS(3000);
  const uint32_t End = oosmos_GetFreeRunningUS();
  if (End - (Start + ((3000) * (1000ull))) <= 4000) {
    printf("SUCCESS\n");
  } else {
    printf("FAILED\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0xbb8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <oosmos_GetFreeRunningUS@plt>
mov    %eax,-0x8(%rbp)
mov    $0xbb8,%edi
call   1050 <oosmos_DelayMS@plt>
mov    $0x0,%al
call   1040 <oosmos_GetFreeRunningUS@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    $0x2dc6c0,%rcx
sub    %rcx,%rax
cmp    $0xfa0,%rax
ja     11a1 <main+0x71>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <main+0x7f>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
mov    $0xbb8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <oosmos_GetFreeRunningUS@plt>
mov    %eax,%ebx
mov    $0xbb8,%edi
call   1060 <oosmos_DelayMS@plt>
xor    %eax,%eax
call   1050 <oosmos_GetFreeRunningUS@plt>
cltq
movslq %ebx,%rcx
sub    %rcx,%rax
add    $0xffffffffffd23940,%rax
cmp    $0xfa1,%rax
lea    0xe9b(%rip),%rax
lea    0xe8d(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Delaying %d milliseconds...\0A\00"
@.str.1 = [9 x i8] c"SUCCESS\0A\00"
@.str.2 = [8 x i8] c"FAILED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 3000)
%5 = call i32 (...) @oosmos_GetFreeRunningUS()
store i32 %5, i32* %2
%6 = call i32 @oosmos_DelayMS(i32 3000)
%7 = call i32 (...) @oosmos_GetFreeRunningUS()
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = add i64 %11, 3000000
%13 = sub i64 %9, %12
%14 = icmp ule i64 %13, 4000
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Delaying %d milliseconds...\0A\00"
@str = [7 x i8] c"FAILED\00"
@str.3 = [8 x i8] c"SUCCESS\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 3000)
%2 = tail call i32 (...) @oosmos_GetFreeRunningUS()
%3 = tail call i32 @oosmos_DelayMS(i32 3000)
%4 = tail call i32 (...) @oosmos_GetFreeRunningUS()
%5 = sext i32 %4 to i64
%6 = sext i32 %2 to i64
%7 = sub nsw i64 -3000000, %6
%8 = add nsw i64 %7, %5
%9 = icmp ult i64 %8, 4001
%10 = select i1 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}