#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 */
unsigned long clockticks_in_msec(unsigned long, unsigned long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int stck(unsigned long *);
int main() {
  int cc;
  unsigned long start, end, diff;
  cc = stck(&start);
  if (cc)
    printf("cc != 0!\n");
  sleep(1);
  cc = stck(&end);
  if (cc)
    printf("cc != 0!\n");
  diff = clockticks_in_msec(end, start);
  if (diff >= 1000 && diff < 1500)
    printf("OK.....Testcase passed\n");
  else
    printf("FAILED.....Testcase failed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <stck@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1171 <main+0x31>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    -0x18(%rbp),%rdi
call   1040 <stck@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     119d <main+0x5d>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <clockticks_in_msec@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x3e8,-0x20(%rbp)
jb     11db <main+0x9b>
cmpq   $0x5dc,-0x20(%rbp)
jae    11db <main+0x9b>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xa7>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
call   1040 <stck@plt>
test   %eax,%eax
je     115e <main+0x1e>
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0x8(%rsp),%rdi
call   1040 <stck@plt>
test   %eax,%eax
je     1182 <main+0x42>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
call   1050 <clockticks_in_msec@plt>
add    $0xfffffffffffffc18,%rax
cmp    $0x1f4,%rax
lea    0xe77(%rip),%rax
lea    0xe55(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"cc != 0!\0A\00"
@.str.1 = [24 x i8] c"OK.....Testcase passed\0A\00"
@.str.2 = [28 x i8] c"FAILED.....Testcase failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @stck(i64* %3)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = call i32 @sleep(i32 1)
%13 = call i32 @stck(i64* %4)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i64, i64* %4
%20 = load i64, i64* %3
%21 = call i64 @clockticks_in_msec(i64 %19, i64 %20)
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = icmp uge i64 %22, 1000
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i64, i64* %5
%26 = icmp ult i64 %25, 1500
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %31
29: ; preds = %24, %18
%30 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
ret i32 0
}

LLVM IR (-O2):
@str = [27 x i8] c"FAILED.....Testcase failed\00"
@str.3 = [23 x i8] c"OK.....Testcase passed\00"
@str.5 = [9 x i8] c"cc != 0!\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @stck(i64* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = call i32 @sleep(i32 1)
%11 = call i32 @stck(i64* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = load i64, i64* %2
%17 = load i64, i64* %1
%18 = call i64 @clockticks_in_msec(i64 %16, i64 %17)
%19 = add i64 %18, -1000
%20 = icmp ult i64 %19, 500
%21 = select i1 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0)
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}