#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*/ print(int);
int readCounter();
int /*<<< orphan*/ startCounter(int, int /*<<< orphan*/);
int /*<<< orphan*/ to_stdout(char);
void main(void) {
  int i, increased, new, old, newValue;
  newValue = 0x40000040;
  increased = (0 == 0);
  for (i = 1; i <= 6; i++) {
    print(i);
    newValue = 0x40000040 | (i << 3);
    startCounter(newValue, 0);
    old = 0;
    do {
      if ((new = readCounter()) > old) {
        increased = increased & (0 == 0);
        old = new;
      } else {
        increased = (0 == 1);
      }
    } while ((readCounter() & 0x3fffffff) < (newValue & 0x3fffffff));
    if (increased) {
      to_stdout('o');
      to_stdout('k');
    } else {
      to_stdout('e');
      to_stdout('r');
      to_stdout('r');
    }
    to_stdout('\n');
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x40000040,-0x14(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jg     1237 <main+0xf7>
mov    -0x4(%rbp),%edi
call   1050 <print@plt>
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
or     $0x40000040,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1060 <startCounter@plt>
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <readCounter@plt>
mov    %eax,-0xc(%rbp)
cmp    -0x10(%rbp),%eax
jle    11b5 <main+0x75>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11bc <main+0x7c>
movl   $0x0,-0x8(%rbp)
jmp    11c1 <main+0x81>
mov    $0x0,%al
call   1030 <readCounter@plt>
and    $0x3fffffff,%eax
mov    -0x14(%rbp),%ecx
and    $0x3fffffff,%ecx
cmp    %ecx,%eax
jl     118e <main+0x4e>
cmpl   $0x0,-0x8(%rbp)
je     1201 <main+0xc1>
mov    $0x6f,%edi
call   1040 <to_stdout@plt>
mov    $0x6b,%edi
call   1040 <to_stdout@plt>
jmp    121f <main+0xdf>
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115d <main+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r14d
xor    %r15d,%r15d
mov    $0x1,%ebx
jmp    1194 <main+0x54>
nopl   0x0(%rax,%rax,1)
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%al
mov    $0x72,%bpl
movzbl %al,%edi
call   1040 <to_stdout@plt>
movzbl %bpl,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
add    $0x1,%r14d
cmp    $0x7,%r14d
je     11f6 <main+0xb6>
mov    %r14d,%edi
call   1050 <print@plt>
lea    0x0(,%r14,8),%r12d
or     $0x40000040,%r12d
mov    %r12d,%edi
xor    %esi,%esi
call   1060 <startCounter@plt>
and    $0x3ffffff8,%r12d
xor    %ebp,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x1,%ebx
cmp    %ebp,%eax
cmovle %r15d,%ebx
cmovg  %eax,%ebp
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x3fffffff,%eax
cmp    %r12d,%eax
jb     11c0 <main+0x80>
test   %ebx,%ebx
je     1160 <main+0x20>
mov    $0x6b,%bpl
mov    $0x6f,%al
jmp    116f <main+0x2f>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 1073741888, i32* %5
store i32 1, i32* %2
store i32 1, i32* %1
br label %6
6: ; preds = %45, %0
%7 = load i32, i32* %1
%8 = icmp sle i32 %7, 6
br i1 %8, label %9, label %48
9: ; preds = %6
%10 = load i32, i32* %1
%11 = call i32 @print(i32 %10)
%12 = load i32, i32* %1
%13 = shl i32 %12, 3
%14 = or i32 1073741888, %13
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i32 @startCounter(i32 %15, i32 0)
store i32 0, i32* %4
br label %17
17: ; preds = %27, %9
%18 = call i32 (...) @readCounter()
store i32 %18, i32* %3
%19 = load i32, i32* %4
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %2
%23 = and i32 %22, 1
store i32 %23, i32* %2
%24 = load i32, i32* %3
store i32 %24, i32* %4
br label %26
25: ; preds = %17
store i32 0, i32* %2
br label %26
26: ; preds = %25, %21
br label %27
27: ; preds = %26
%28 = call i32 (...) @readCounter()
%29 = and i32 %28, 1073741823
%30 = load i32, i32* %5
%31 = and i32 %30, 1073741823
%32 = icmp slt i32 %29, %31
br i1 %32, label %17, label %33
33: ; preds = %27
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @to_stdout(i8 signext 111)
%38 = call i32 @to_stdout(i8 signext 107)
br label %43
39: ; preds = %33
%40 = call i32 @to_stdout(i8 signext 101)
%41 = call i32 @to_stdout(i8 signext 114)
%42 = call i32 @to_stdout(i8 signext 114)
br label %43
43: ; preds = %39, %36
%44 = call i32 @to_stdout(i8 signext 10)
br label %45
45: ; preds = %43
%46 = load i32, i32* %1
%47 = add nsw i32 %46, 1
store i32 %47, i32* %1
br label %6
48: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @main() {
br label %1
1: ; preds = %0, %24
%2 = phi i32 [ 1, %0 ], [ %30, %24 ]
%3 = phi i32 [ 1, %0 ], [ %15, %24 ]
%4 = tail call i32 @print(i32 %2)
%5 = shl nuw nsw i32 %2, 3
%6 = or i32 %5, 1073741888
%7 = tail call i32 @startCounter(i32 %6, i32 0)
%8 = and i32 %6, 1073741816
br label %9
9: ; preds = %9, %1
%10 = phi i32 [ %3, %1 ], [ %15, %9 ]
%11 = phi i32 [ 0, %1 ], [ %16, %9 ]
%12 = tail call i32 (...) @readCounter()
%13 = icmp sgt i32 %12, %11
%14 = and i32 %10, 1
%15 = select i1 %13, i32 %14, i32 0
%16 = select i1 %13, i32 %12, i32 %11
%17 = tail call i32 (...) @readCounter()
%18 = and i32 %17, 1073741823
%19 = icmp ult i32 %18, %8
br i1 %19, label %9, label %20
20: ; preds = %9
%21 = icmp eq i32 %15, 0
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @to_stdout(i8 signext 101)
br label %24
24: ; preds = %20, %22
%25 = phi i8 [ 114, %22 ], [ 111, %20 ]
%26 = phi i8 [ 114, %22 ], [ 107, %20 ]
%27 = tail call i32 @to_stdout(i8 signext %25)
%28 = tail call i32 @to_stdout(i8 signext %26)
%29 = tail call i32 @to_stdout(i8 signext 10)
%30 = add nuw nsw i32 %2, 1
%31 = icmp eq i32 %30, 7
br i1 %31, label %32, label %1
32: ; preds = %24
ret void
}