#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 char i;

/* Variables and functions */
int readCounter();
int /*<<< orphan*/ startCounter(int, int /*<<< orphan*/);
int /*<<< orphan*/ to_stdout(char);
void main(void) {
  int i, increased, new, old, newValue;
  newValue = 0x40000040;
  for (i = 0; i < 4; i++) {
    to_stdout((((i) < 10) ? ((i) + '0') : (((i) + 'a') - 10)));
    to_stdout('\n');
    newValue = 0x40000040 + (i << 3);
    startCounter(newValue, 0);
    increased = !((0 == 1));
    old = 0;
    do {
      if ((new = readCounter()) > old) {
        increased = increased & !((0 == 1));
        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   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    1258 <main+0x128>
cmpl   $0xa,-0x4(%rbp)
jge    1168 <main+0x38>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x44>
mov    -0x4(%rbp),%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
movsbl %al,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
add    $0x40000040,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <startCounter@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <readCounter@plt>
mov    %eax,-0xc(%rbp)
cmp    -0x10(%rbp),%eax
jle    11d6 <main+0xa6>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11dd <main+0xad>
movl   $0x0,-0x8(%rbp)
jmp    11e2 <main+0xb2>
mov    $0x0,%al
call   1030 <readCounter@plt>
and    $0x3fffffff,%eax
mov    -0x14(%rbp),%ecx
and    $0x3fffffff,%ecx
cmp    %ecx,%eax
jl     11af <main+0x7f>
cmpl   $0x0,-0x8(%rbp)
je     1222 <main+0xf2>
mov    $0x6f,%edi
call   1040 <to_stdout@plt>
mov    $0x6b,%edi
call   1040 <to_stdout@plt>
jmp    1240 <main+0x110>
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    1146 <main+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x30,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
xor    %r14d,%r14d
mov    $0x40000040,%edi
xor    %esi,%esi
call   1050 <startCounter@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x1,%ebp
cmp    %ebx,%eax
cmovle %r14d,%ebp
cmovg  %eax,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
test   $0x3fffffc0,%eax
je     1160 <main+0x30>
test   %ebp,%ebp
je     118b <main+0x5b>
mov    $0x6b,%bl
mov    $0x6f,%al
jmp    1199 <main+0x69>
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%al
mov    $0x72,%bl
movzbl %al,%edi
call   1040 <to_stdout@plt>
movzbl %bl,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
mov    $0x31,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
xor    %r14d,%r14d
mov    $0x40000048,%edi
xor    %esi,%esi
call   1050 <startCounter@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x1,%ebp
cmp    %ebx,%eax
cmovle %r14d,%ebp
cmovg  %eax,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x3ffffff8,%eax
cmp    $0x48,%eax
jb     11e0 <main+0xb0>
test   %ebp,%ebp
je     120e <main+0xde>
mov    $0x6b,%bl
mov    $0x6f,%al
jmp    121c <main+0xec>
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%al
mov    $0x72,%bl
movzbl %al,%edi
call   1040 <to_stdout@plt>
movzbl %bl,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
mov    $0x32,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
xor    %r14d,%r14d
mov    $0x40000050,%edi
xor    %esi,%esi
call   1050 <startCounter@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x1,%ebp
cmp    %ebx,%eax
cmovle %r14d,%ebp
cmovg  %eax,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x3ffffff0,%eax
cmp    $0x50,%eax
jb     1260 <main+0x130>
test   %ebp,%ebp
je     128e <main+0x15e>
mov    $0x6b,%bl
mov    $0x6f,%al
jmp    129c <main+0x16c>
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%al
mov    $0x72,%bl
movzbl %al,%edi
call   1040 <to_stdout@plt>
movzbl %bl,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
mov    $0x33,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
call   1040 <to_stdout@plt>
xor    %r14d,%r14d
mov    $0x40000058,%edi
xor    %esi,%esi
call   1050 <startCounter@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x1,%ebp
cmp    %ebx,%eax
cmovle %r14d,%ebp
cmovg  %eax,%ebx
xor    %eax,%eax
call   1030 <readCounter@plt>
and    $0x3ffffff8,%eax
cmp    $0x58,%eax
jb     12e0 <main+0x1b0>
test   %ebp,%ebp
je     130e <main+0x1de>
mov    $0x6b,%bl
mov    $0x6f,%al
jmp    131c <main+0x1ec>
mov    $0x65,%edi
call   1040 <to_stdout@plt>
mov    $0x72,%al
mov    $0x72,%bl
movzbl %al,%edi
call   1040 <to_stdout@plt>
movzbl %bl,%edi
call   1040 <to_stdout@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <to_stdout@plt>

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 0, i32* %1
br label %6
6: ; preds = %57, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %60
9: ; preds = %6
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 48
br label %19
15: ; preds = %9
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 97
%18 = sub nsw i32 %17, 10
br label %19
19: ; preds = %15, %12
%20 = phi i32 [ %14, %12 ], [ %18, %15 ]
%21 = trunc i32 %20 to i8
%22 = call i32 @to_stdout(i8 signext %21)
%23 = call i32 @to_stdout(i8 signext 10)
%24 = load i32, i32* %1
%25 = shl i32 %24, 3
%26 = add nsw i32 1073741888, %25
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = call i32 @startCounter(i32 %27, i32 0)
store i32 1, i32* %2
store i32 0, i32* %4
br label %29
29: ; preds = %39, %19
%30 = call i32 (...) @readCounter()
store i32 %30, i32* %3
%31 = load i32, i32* %4
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* %2
%35 = and i32 %34, 1
store i32 %35, i32* %2
%36 = load i32, i32* %3
store i32 %36, i32* %4
br label %38
37: ; preds = %29
store i32 0, i32* %2
br label %38
38: ; preds = %37, %33
br label %39
39: ; preds = %38
%40 = call i32 (...) @readCounter()
%41 = and i32 %40, 1073741823
%42 = load i32, i32* %5
%43 = and i32 %42, 1073741823
%44 = icmp slt i32 %41, %43
br i1 %44, label %29, label %45
45: ; preds = %39
%46 = load i32, i32* %2
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = call i32 @to_stdout(i8 signext 111)
%50 = call i32 @to_stdout(i8 signext 107)
br label %55
51: ; preds = %45
%52 = call i32 @to_stdout(i8 signext 101)
%53 = call i32 @to_stdout(i8 signext 114)
%54 = call i32 @to_stdout(i8 signext 114)
br label %55
55: ; preds = %51, %48
%56 = call i32 @to_stdout(i8 signext 10)
br label %57
57: ; preds = %55
%58 = load i32, i32* %1
%59 = add nsw i32 %58, 1
store i32 %59, i32* %1
br label %6
60: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @to_stdout(i8 signext 48)
%2 = tail call i32 @to_stdout(i8 signext 10)
%3 = tail call i32 @startCounter(i32 1073741888, i32 0)
br label %4
4: ; preds = %4, %0
%5 = phi i32 [ 1, %0 ], [ %10, %4 ]
%6 = phi i32 [ 0, %0 ], [ %11, %4 ]
%7 = tail call i32 (...) @readCounter()
%8 = icmp sgt i32 %7, %6
%9 = and i32 %5, 1
%10 = select i1 %8, i32 %9, i32 0
%11 = select i1 %8, i32 %7, i32 %6
%12 = tail call i32 (...) @readCounter()
%13 = and i32 %12, 1073741760
%14 = icmp eq i32 %13, 0
br i1 %14, label %4, label %15
15: ; preds = %4
%16 = icmp eq i32 %10, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @to_stdout(i8 signext 101)
br label %19
19: ; preds = %15, %17
%20 = phi i8 [ 114, %17 ], [ 111, %15 ]
%21 = phi i8 [ 114, %17 ], [ 107, %15 ]
%22 = tail call i32 @to_stdout(i8 signext %20)
%23 = tail call i32 @to_stdout(i8 signext %21)
%24 = tail call i32 @to_stdout(i8 signext 10)
%25 = tail call i32 @to_stdout(i8 signext 49)
%26 = tail call i32 @to_stdout(i8 signext 10)
%27 = tail call i32 @startCounter(i32 1073741896, i32 0)
br label %28
28: ; preds = %28, %19
%29 = phi i32 [ 1, %19 ], [ %34, %28 ]
%30 = phi i32 [ 0, %19 ], [ %35, %28 ]
%31 = tail call i32 (...) @readCounter()
%32 = icmp sgt i32 %31, %30
%33 = and i32 %29, 1
%34 = select i1 %32, i32 %33, i32 0
%35 = select i1 %32, i32 %31, i32 %30
%36 = tail call i32 (...) @readCounter()
%37 = and i32 %36, 1073741816
%38 = icmp ult i32 %37, 72
br i1 %38, label %28, label %39
39: ; preds = %28
%40 = icmp eq i32 %34, 0
br i1 %40, label %41, label %43
41: ; preds = %39
%42 = tail call i32 @to_stdout(i8 signext 101)
br label %43
43: ; preds = %41, %39
%44 = phi i8 [ 114, %41 ], [ 111, %39 ]
%45 = phi i8 [ 114, %41 ], [ 107, %39 ]
%46 = tail call i32 @to_stdout(i8 signext %44)
%47 = tail call i32 @to_stdout(i8 signext %45)
%48 = tail call i32 @to_stdout(i8 signext 10)
%49 = tail call i32 @to_stdout(i8 signext 50)
%50 = tail call i32 @to_stdout(i8 signext 10)
%51 = tail call i32 @startCounter(i32 1073741904, i32 0)
br label %52
52: ; preds = %52, %43
%53 = phi i32 [ 1, %43 ], [ %58, %52 ]
%54 = phi i32 [ 0, %43 ], [ %59, %52 ]
%55 = tail call i32 (...) @readCounter()
%56 = icmp sgt i32 %55, %54
%57 = and i32 %53, 1
%58 = select i1 %56, i32 %57, i32 0
%59 = select i1 %56, i32 %55, i32 %54
%60 = tail call i32 (...) @readCounter()
%61 = and i32 %60, 1073741808
%62 = icmp ult i32 %61, 80
br i1 %62, label %52, label %63
63: ; preds = %52
%64 = icmp eq i32 %58, 0
br i1 %64, label %65, label %67
65: ; preds = %63
%66 = tail call i32 @to_stdout(i8 signext 101)
br label %67
67: ; preds = %65, %63
%68 = phi i8 [ 114, %65 ], [ 111, %63 ]
%69 = phi i8 [ 114, %65 ], [ 107, %63 ]
%70 = tail call i32 @to_stdout(i8 signext %68)
%71 = tail call i32 @to_stdout(i8 signext %69)
%72 = tail call i32 @to_stdout(i8 signext 10)
%73 = tail call i32 @to_stdout(i8 signext 51)
%74 = tail call i32 @to_stdout(i8 signext 10)
%75 = tail call i32 @startCounter(i32 1073741912, i32 0)
br label %76
76: ; preds = %76, %67
%77 = phi i32 [ 1, %67 ], [ %82, %76 ]
%78 = phi i32 [ 0, %67 ], [ %83, %76 ]
%79 = tail call i32 (...) @readCounter()
%80 = icmp sgt i32 %79, %78
%81 = and i32 %77, 1
%82 = select i1 %80, i32 %81, i32 0
%83 = select i1 %80, i32 %79, i32 %78
%84 = tail call i32 (...) @readCounter()
%85 = and i32 %84, 1073741816
%86 = icmp ult i32 %85, 88
br i1 %86, label %76, label %87
87: ; preds = %76
%88 = icmp eq i32 %82, 0
br i1 %88, label %89, label %91
89: ; preds = %87
%90 = tail call i32 @to_stdout(i8 signext 101)
br label %91
91: ; preds = %89, %87
%92 = phi i8 [ 114, %89 ], [ 111, %87 ]
%93 = phi i8 [ 114, %89 ], [ 107, %87 ]
%94 = tail call i32 @to_stdout(i8 signext %92)
%95 = tail call i32 @to_stdout(i8 signext %93)
%96 = tail call i32 @to_stdout(i8 signext 10)
ret void
}