#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 fail(char *, int);
int getreg(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv_char(char);
int /*<<< orphan*/ send_char(char);
int /*<<< orphan*/ send_char_no_wait(char);
int /*<<< orphan*/ setreg(int, int);
void control_register_test() {
  send_char('*');
  {
    unsigned x = getreg(((0x9c000000) + 5));
    if ((x & ((0x10) | (0x08) | (0x04) | (0x02))) && !(x & (0x80)))
      printf("LSR7 (0x%02x) ERR @ %i\n", x, 745);
    ((!(x & (0x80)) && ((x & 0x60) != 0x40)) ? 1 : fail("?", 745));
  };
  while (!(getreg(((0x9c000000) + 5)) & 0x01))
    ;
  setreg(((0x9c000000) + 2), 2);
  ((getreg(((0x9c000000) + 5)) == 0x60) ? 1 : fail("?", 748));
  send_char('!');
  recv_char('!');
  printf("Passed line %i\n", 751);
  ((getreg(((0x9c000000) + 5)) & (0x20)) ? 1 : fail("?", 754));
  ((getreg(((0x9c000000) + 5)) & (0x40)) ? 1 : fail("?", 755));
  send_char_no_wait('1');
  send_char_no_wait('2');
  setreg(((0x9c000000) + 2), 4);
  ((getreg(((0x9c000000) + 5)) == 0x20) ? 1 : fail("?", 763));
  {
    unsigned x = getreg(((0x9c000000) + 5));
    if ((x & ((0x10) | (0x08) | (0x04) | (0x02))) && !(x & (0x80)))
      printf("LSR7 (0x%02x) ERR @ %i\n", x, 764);
    ((!(x & (0x80)) && ((x & 0x60) != 0x40)) ? 1 : fail("?", 764));
  };
  send_char('*');
  recv_char('*');
  printf("Passed line %i\n", 767);
  printf("Passed line %i\n", 774);
  printf("OK\n");
}


x86 assembly (clang, -O0):
<control_register_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2a,%edi
call   1070 <send_char@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1e,%eax
cmp    $0x0,%eax
je     11c5 <control_register_test+0x55>
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    11c5 <control_register_test+0x55>
mov    -0x4(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x2e9,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    11ea <control_register_test+0x7a>
mov    -0x4(%rbp),%eax
and    $0x60,%eax
cmp    $0x40,%eax
je     11ea <control_register_test+0x7a>
jmp    11fb <control_register_test+0x8b>
lea    0xe27(%rip),%rdi
mov    $0x2e9,%esi
call   1040 <fail@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    121d <control_register_test+0xad>
jmp    1222 <control_register_test+0xb2>
jmp    11fb <control_register_test+0x8b>
mov    $0x9c000002,%edi
mov    $0x2,%esi
call   1050 <setreg@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
cmp    $0x60,%eax
jne    1249 <control_register_test+0xd9>
jmp    125a <control_register_test+0xea>
lea    0xdc8(%rip),%rdi
mov    $0x2ec,%esi
call   1040 <fail@plt>
mov    $0x21,%edi
call   1070 <send_char@plt>
mov    $0x21,%edi
call   1030 <recv_char@plt>
lea    0xda5(%rip),%rdi
mov    $0x2ef,%esi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
and    $0x20,%eax
cmp    $0x0,%eax
je     129c <control_register_test+0x12c>
jmp    12ad <control_register_test+0x13d>
lea    0xd75(%rip),%rdi
mov    $0x2f2,%esi
call   1040 <fail@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
and    $0x40,%eax
cmp    $0x0,%eax
je     12c8 <control_register_test+0x158>
jmp    12d9 <control_register_test+0x169>
lea    0xd49(%rip),%rdi
mov    $0x2f3,%esi
call   1040 <fail@plt>
mov    $0x31,%edi
call   1090 <send_char_no_wait@plt>
mov    $0x32,%edi
call   1090 <send_char_no_wait@plt>
mov    $0x9c000002,%edi
mov    $0x4,%esi
call   1050 <setreg@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
cmp    $0x20,%eax
jne    1314 <control_register_test+0x1a4>
jmp    1325 <control_register_test+0x1b5>
lea    0xcfd(%rip),%rdi
mov    $0x2fb,%esi
call   1040 <fail@plt>
mov    $0x9c000005,%edi
call   1080 <getreg@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1e,%eax
cmp    $0x0,%eax
je     1368 <control_register_test+0x1f8>
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1368 <control_register_test+0x1f8>
mov    -0x8(%rbp),%esi
lea    0xca4(%rip),%rdi
mov    $0x2fc,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    138d <control_register_test+0x21d>
mov    -0x8(%rbp),%eax
and    $0x60,%eax
cmp    $0x40,%eax
je     138d <control_register_test+0x21d>
jmp    139e <control_register_test+0x22e>
lea    0xc84(%rip),%rdi
mov    $0x2fc,%esi
call   1040 <fail@plt>
mov    $0x2a,%edi
call   1070 <send_char@plt>
mov    $0x2a,%edi
call   1030 <recv_char@plt>
lea    0xc61(%rip),%rdi
mov    $0x2ff,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc4e(%rip),%rdi
mov    $0x306,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<control_register_test>:
push   %rbx
mov    $0x2a,%edi
call   1080 <send_char@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
mov    %eax,%ebx
test   $0x1e,%bl
je     11ba <control_register_test+0x3a>
mov    %ebx,%eax
and    $0x80,%eax
jne    11ba <control_register_test+0x3a>
lea    0xe54(%rip),%rdi
mov    %ebx,%esi
mov    $0x2e9,%edx
xor    %eax,%eax
call   1070 <printf@plt>
test   $0x80,%bl
jne    11c7 <control_register_test+0x47>
and    $0x60,%ebx
cmp    $0x40,%ebx
jne    11e0 <control_register_test+0x60>
lea    0xe4a(%rip),%rdi
mov    $0x2e9,%esi
call   1050 <fail@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
test   $0x1,%al
je     11e0 <control_register_test+0x60>
mov    $0x9c000002,%edi
mov    $0x2,%esi
call   1060 <setreg@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
cmp    $0x60,%eax
je     121d <control_register_test+0x9d>
lea    0xe05(%rip),%rdi
mov    $0x2ec,%esi
call   1050 <fail@plt>
mov    $0x21,%edi
call   1080 <send_char@plt>
mov    $0x21,%edi
call   1030 <recv_char@plt>
lea    0xde2(%rip),%rdi
mov    $0x2ef,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
test   $0x20,%al
jne    1263 <control_register_test+0xe3>
lea    0xdbf(%rip),%rdi
mov    $0x2f2,%esi
call   1050 <fail@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
test   $0x40,%al
jne    1282 <control_register_test+0x102>
lea    0xda0(%rip),%rdi
mov    $0x2f3,%esi
call   1050 <fail@plt>
mov    $0x31,%edi
call   10a0 <send_char_no_wait@plt>
mov    $0x32,%edi
call   10a0 <send_char_no_wait@plt>
mov    $0x9c000002,%edi
mov    $0x4,%esi
call   1060 <setreg@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
cmp    $0x20,%eax
je     12c5 <control_register_test+0x145>
lea    0xd5d(%rip),%rdi
mov    $0x2fb,%esi
call   1050 <fail@plt>
mov    $0x9c000005,%edi
call   1090 <getreg@plt>
mov    %eax,%ebx
test   $0x1e,%bl
je     12f4 <control_register_test+0x174>
mov    %ebx,%eax
and    $0x80,%eax
jne    12f4 <control_register_test+0x174>
lea    0xd1a(%rip),%rdi
mov    %ebx,%esi
mov    $0x2fc,%edx
xor    %eax,%eax
call   1070 <printf@plt>
test   $0x80,%bl
jne    1301 <control_register_test+0x181>
and    $0x60,%ebx
cmp    $0x40,%ebx
jne    1312 <control_register_test+0x192>
lea    0xd10(%rip),%rdi
mov    $0x2fc,%esi
call   1050 <fail@plt>
mov    $0x2a,%edi
call   1080 <send_char@plt>
mov    $0x2a,%edi
call   1030 <recv_char@plt>
lea    0xced(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2ff,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x306,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xcd8(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"LSR7 (0x%02x) ERR @ %i\0A\00"
@.str.1 = [2 x i8] c"?\00"
@.str.2 = [16 x i8] c"Passed line %i\0A\00"
@.str.3 = [4 x i8] c"OK\0A\00"
define void @control_register_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @send_char(i8 signext 42)
%4 = call i32 @getreg(i32 -1677721595)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = and i32 %5, 30
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = load i32, i32* %1
%10 = and i32 %9, 128
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13, i32 745)
br label %15
15: ; preds = %12, %8, %0
%16 = load i32, i32* %1
%17 = and i32 %16, 128
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i32, i32* %1
%21 = and i32 %20, 96
%22 = icmp ne i32 %21, 64
br i1 %22, label %23, label %24
23: ; preds = %19
br label %26
24: ; preds = %19, %15
%25 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 745)
br label %26
26: ; preds = %24, %23
%27 = phi i32 [ 1, %23 ], [ %25, %24 ]
br label %28
28: ; preds = %33, %26
%29 = call i32 @getreg(i32 -1677721595)
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %33, label %34
33: ; preds = %28
br label %28
34: ; preds = %28
%35 = call i32 @setreg(i32 -1677721598, i32 2)
%36 = call i32 @getreg(i32 -1677721595)
%37 = icmp eq i32 %36, 96
br i1 %37, label %38, label %39
38: ; preds = %34
br label %41
39: ; preds = %34
%40 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 748)
br label %41
41: ; preds = %39, %38
%42 = phi i32 [ 1, %38 ], [ %40, %39 ]
%43 = call i32 @send_char(i8 signext 33)
%44 = call i32 @recv_char(i8 signext 33)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 751)
%46 = call i32 @getreg(i32 -1677721595)
%47 = and i32 %46, 32
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %41
br label %52
50: ; preds = %41
%51 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 754)
br label %52
52: ; preds = %50, %49
%53 = phi i32 [ 1, %49 ], [ %51, %50 ]
%54 = call i32 @getreg(i32 -1677721595)
%55 = and i32 %54, 64
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
br label %60
58: ; preds = %52
%59 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 755)
br label %60
60: ; preds = %58, %57
%61 = phi i32 [ 1, %57 ], [ %59, %58 ]
%62 = call i32 @send_char_no_wait(i8 signext 49)
%63 = call i32 @send_char_no_wait(i8 signext 50)
%64 = call i32 @setreg(i32 -1677721598, i32 4)
%65 = call i32 @getreg(i32 -1677721595)
%66 = icmp eq i32 %65, 32
br i1 %66, label %67, label %68
67: ; preds = %60
br label %70
68: ; preds = %60
%69 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 763)
br label %70
70: ; preds = %68, %67
%71 = phi i32 [ 1, %67 ], [ %69, %68 ]
%72 = call i32 @getreg(i32 -1677721595)
store i32 %72, i32* %2
%73 = load i32, i32* %2
%74 = and i32 %73, 30
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %83
76: ; preds = %70
%77 = load i32, i32* %2
%78 = and i32 %77, 128
%79 = icmp ne i32 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %76
%81 = load i32, i32* %2
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %81, i32 764)
br label %83
83: ; preds = %80, %76, %70
%84 = load i32, i32* %2
%85 = and i32 %84, 128
%86 = icmp ne i32 %85, 0
br i1 %86, label %92, label %87
87: ; preds = %83
%88 = load i32, i32* %2
%89 = and i32 %88, 96
%90 = icmp ne i32 %89, 64
br i1 %90, label %91, label %92
91: ; preds = %87
br label %94
92: ; preds = %87, %83
%93 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 764)
br label %94
94: ; preds = %92, %91
%95 = phi i32 [ 1, %91 ], [ %93, %92 ]
%96 = call i32 @send_char(i8 signext 42)
%97 = call i32 @recv_char(i8 signext 42)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 767)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 774)
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"LSR7 (0x%02x) ERR @ %i\0A\00"
@.str.1 = [2 x i8] c"?\00"
@.str.2 = [16 x i8] c"Passed line %i\0A\00"
@str = [3 x i8] c"OK\00"
define void @control_register_test() {
%1 = tail call i32 @send_char(i8 signext 42)
%2 = tail call i32 @getreg(i32 -1677721595)
%3 = and i32 %2, 30
%4 = icmp ne i32 %3, 0
%5 = and i32 %2, 128
%6 = icmp eq i32 %5, 0
%7 = and i1 %4, %6
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %2, i32 745)
br label %10
10: ; preds = %8, %0
%11 = icmp ne i32 %5, 0
%12 = and i32 %2, 96
%13 = icmp eq i32 %12, 64
%14 = or i1 %11, %13
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 745)
br label %17
17: ; preds = %10, %15
br label %18
18: ; preds = %17, %18
%19 = tail call i32 @getreg(i32 -1677721595)
%20 = and i32 %19, 1
%21 = icmp eq i32 %20, 0
br i1 %21, label %18, label %22
22: ; preds = %18
%23 = tail call i32 @setreg(i32 -1677721598, i32 2)
%24 = tail call i32 @getreg(i32 -1677721595)
%25 = icmp eq i32 %24, 96
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 748)
br label %28
28: ; preds = %22, %26
%29 = tail call i32 @send_char(i8 signext 33)
%30 = tail call i32 @recv_char(i8 signext 33)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 751)
%32 = tail call i32 @getreg(i32 -1677721595)
%33 = and i32 %32, 32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 754)
br label %37
37: ; preds = %28, %35
%38 = tail call i32 @getreg(i32 -1677721595)
%39 = and i32 %38, 64
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 755)
br label %43
43: ; preds = %37, %41
%44 = tail call i32 @send_char_no_wait(i8 signext 49)
%45 = tail call i32 @send_char_no_wait(i8 signext 50)
%46 = tail call i32 @setreg(i32 -1677721598, i32 4)
%47 = tail call i32 @getreg(i32 -1677721595)
%48 = icmp eq i32 %47, 32
br i1 %48, label %51, label %49
49: ; preds = %43
%50 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 763)
br label %51
51: ; preds = %43, %49
%52 = tail call i32 @getreg(i32 -1677721595)
%53 = and i32 %52, 30
%54 = icmp ne i32 %53, 0
%55 = and i32 %52, 128
%56 = icmp eq i32 %55, 0
%57 = and i1 %54, %56
br i1 %57, label %58, label %60
58: ; preds = %51
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %52, i32 764)
br label %60
60: ; preds = %58, %51
%61 = icmp ne i32 %55, 0
%62 = and i32 %52, 96
%63 = icmp eq i32 %62, 64
%64 = or i1 %61, %63
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 764)
br label %67
67: ; preds = %60, %65
%68 = tail call i32 @send_char(i8 signext 42)
%69 = tail call i32 @recv_char(i8 signext 42)
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 767)
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 774)
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}