#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*/ SelectShiftIR();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int read_jtag_tdo();
int /*<<< orphan*/ send_cmd(int /*<<< orphan*/, int);
int /*<<< orphan*/ send_cmdWord_msb_first(unsigned int, int, int);
int /*<<< orphan*/ send_cmdWord_msb_last(int, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syncJTAGs();
void checkStatusReg() {
  unsigned int DYMMYWORD = 0xFFFFFFFF;
  unsigned int NOOP = 0x20000000;
  unsigned int SYNCWORD = 0xAA995566;
  unsigned int STATUS_REG = 0x2800E002;
  int v, n;
  syncJTAGs();
  SelectShiftIR();
  send_cmdWord_msb_last(0x3FC5, 1, 14);
  send_cmd(0, 1);
  send_cmd(0, 1);
  send_cmd(0, 0);
  send_cmd(0, 0);
  for (n = 0; n < 31; n++)
    send_cmd(0, 0);
  send_cmdWord_msb_first(DYMMYWORD, 0, 32);
  send_cmdWord_msb_first(SYNCWORD, 0, 32);
  send_cmdWord_msb_first(NOOP, 0, 32);
  send_cmdWord_msb_first(STATUS_REG, 0, 32);
  send_cmdWord_msb_first(NOOP, 0, 32);
  send_cmdWord_msb_first(NOOP, 1, 32);
  for (n = 0; n < 3; n++)
    send_cmd(0, 1);
  send_cmd(0, 0);
  send_cmd(0, 0);
  send_cmdWord_msb_last(0x3FC4, 1, 14);
  send_cmd(0, 1);
  send_cmd(0, 1);
  send_cmd(0, 0);
  send_cmd(0, 0);
  fprintf(stderr, "\nSTAT: ");
  for (n = 0; n < 32; n++) {
    v = read_jtag_tdo();
    send_cmd(0, 0);
    fprintf(stderr, "%d", v);
  }
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<checkStatusReg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0x20000000,-0x8(%rbp)
movl   $0xaa995566,-0xc(%rbp)
movl   $0x2800e002,-0x10(%rbp)
mov    $0x0,%al
call   1040 <syncJTAGs@plt>
mov    $0x0,%al
call   1050 <SelectShiftIR@plt>
mov    $0x3fc5,%edi
mov    $0x1,%esi
mov    $0xe,%edx
call   1030 <send_cmdWord_msb_last@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x1f,-0x18(%rbp)
jge    1208 <checkStatusReg+0x98>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e7 <checkStatusReg+0x77>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    -0x10(%rbp),%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1290 <checkStatusReg+0x120>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126c <checkStatusReg+0xfc>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
mov    $0x3fc4,%edi
mov    $0x1,%esi
mov    $0xe,%edx
call   1030 <send_cmdWord_msb_last@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    1343 <checkStatusReg+0x1d3>
mov    $0x0,%al
call   1080 <read_jtag_tdo@plt>
mov    %eax,-0x14(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1090 <send_cmd@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12fe <checkStatusReg+0x18e>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkStatusReg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <syncJTAGs@plt>
xor    %eax,%eax
call   1050 <SelectShiftIR@plt>
mov    $0x3fc5,%edi
mov    $0x1,%esi
mov    $0xe,%edx
call   1030 <send_cmdWord_msb_last@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
mov    $0x20,%ebx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    $0xaa995566,%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    $0x20000000,%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    $0x2800e002,%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    $0x20000000,%edi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
mov    $0x20000000,%edi
mov    $0x1,%esi
mov    $0x20,%edx
call   1070 <send_cmdWord_msb_first@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
mov    $0x3fc4,%edi
mov    $0x1,%esi
mov    $0xe,%edx
call   1030 <send_cmdWord_msb_last@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
mov    0x2c1d(%rip),%r15
mov    (%r15),%edi
lea    0xc33(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xc2d(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <read_jtag_tdo@plt>
mov    %eax,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1090 <send_cmd@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebx
jne    13e0 <checkStatusReg+0x270>
mov    (%r15),%edi
lea    0xbfb(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"\0ASTAT: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @checkStatusReg() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 -1, i32* %1
store i32 536870912, i32* %2
store i32 -1432791706, i32* %3
store i32 671145986, i32* %4
%7 = call i32 (...) @syncJTAGs()
%8 = call i32 (...) @SelectShiftIR()
%9 = call i32 @send_cmdWord_msb_last(i32 16325, i32 1, i32 14)
%10 = call i32 @send_cmd(i32 0, i32 1)
%11 = call i32 @send_cmd(i32 0, i32 1)
%12 = call i32 @send_cmd(i32 0, i32 0)
%13 = call i32 @send_cmd(i32 0, i32 0)
store i32 0, i32* %6
br label %14
14: ; preds = %19, %0
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 31
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call i32 @send_cmd(i32 0, i32 0)
br label %19
19: ; preds = %17
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %14
22: ; preds = %14
%23 = load i32, i32* %1
%24 = call i32 @send_cmdWord_msb_first(i32 %23, i32 0, i32 32)
%25 = load i32, i32* %3
%26 = call i32 @send_cmdWord_msb_first(i32 %25, i32 0, i32 32)
%27 = load i32, i32* %2
%28 = call i32 @send_cmdWord_msb_first(i32 %27, i32 0, i32 32)
%29 = load i32, i32* %4
%30 = call i32 @send_cmdWord_msb_first(i32 %29, i32 0, i32 32)
%31 = load i32, i32* %2
%32 = call i32 @send_cmdWord_msb_first(i32 %31, i32 0, i32 32)
%33 = load i32, i32* %2
%34 = call i32 @send_cmdWord_msb_first(i32 %33, i32 1, i32 32)
store i32 0, i32* %6
br label %35
35: ; preds = %40, %22
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 3
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = call i32 @send_cmd(i32 0, i32 1)
br label %40
40: ; preds = %38
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %35
43: ; preds = %35
%44 = call i32 @send_cmd(i32 0, i32 0)
%45 = call i32 @send_cmd(i32 0, i32 0)
%46 = call i32 @send_cmdWord_msb_last(i32 16324, i32 1, i32 14)
%47 = call i32 @send_cmd(i32 0, i32 1)
%48 = call i32 @send_cmd(i32 0, i32 1)
%49 = call i32 @send_cmd(i32 0, i32 0)
%50 = call i32 @send_cmd(i32 0, i32 0)
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %53
53: ; preds = %62, %43
%54 = load i32, i32* %6
%55 = icmp slt i32 %54, 32
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = call i32 (...) @read_jtag_tdo()
store i32 %57, i32* %5
%58 = call i32 @send_cmd(i32 0, i32 0)
%59 = load i32, i32* @stderr
%60 = load i32, i32* %5
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %56
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %53
65: ; preds = %53
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"\0ASTAT: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @checkStatusReg() {
%1 = tail call i32 (...) @syncJTAGs()
%2 = tail call i32 (...) @SelectShiftIR()
%3 = tail call i32 @send_cmdWord_msb_last(i32 16325, i32 1, i32 14)
%4 = tail call i32 @send_cmd(i32 0, i32 1)
%5 = tail call i32 @send_cmd(i32 0, i32 1)
%6 = tail call i32 @send_cmd(i32 0, i32 0)
%7 = tail call i32 @send_cmd(i32 0, i32 0)
%8 = tail call i32 @send_cmd(i32 0, i32 0)
%9 = tail call i32 @send_cmd(i32 0, i32 0)
%10 = tail call i32 @send_cmd(i32 0, i32 0)
%11 = tail call i32 @send_cmd(i32 0, i32 0)
%12 = tail call i32 @send_cmd(i32 0, i32 0)
%13 = tail call i32 @send_cmd(i32 0, i32 0)
%14 = tail call i32 @send_cmd(i32 0, i32 0)
%15 = tail call i32 @send_cmd(i32 0, i32 0)
%16 = tail call i32 @send_cmd(i32 0, i32 0)
%17 = tail call i32 @send_cmd(i32 0, i32 0)
%18 = tail call i32 @send_cmd(i32 0, i32 0)
%19 = tail call i32 @send_cmd(i32 0, i32 0)
%20 = tail call i32 @send_cmd(i32 0, i32 0)
%21 = tail call i32 @send_cmd(i32 0, i32 0)
%22 = tail call i32 @send_cmd(i32 0, i32 0)
%23 = tail call i32 @send_cmd(i32 0, i32 0)
%24 = tail call i32 @send_cmd(i32 0, i32 0)
%25 = tail call i32 @send_cmd(i32 0, i32 0)
%26 = tail call i32 @send_cmd(i32 0, i32 0)
%27 = tail call i32 @send_cmd(i32 0, i32 0)
%28 = tail call i32 @send_cmd(i32 0, i32 0)
%29 = tail call i32 @send_cmd(i32 0, i32 0)
%30 = tail call i32 @send_cmd(i32 0, i32 0)
%31 = tail call i32 @send_cmd(i32 0, i32 0)
%32 = tail call i32 @send_cmd(i32 0, i32 0)
%33 = tail call i32 @send_cmd(i32 0, i32 0)
%34 = tail call i32 @send_cmd(i32 0, i32 0)
%35 = tail call i32 @send_cmd(i32 0, i32 0)
%36 = tail call i32 @send_cmd(i32 0, i32 0)
%37 = tail call i32 @send_cmd(i32 0, i32 0)
%38 = tail call i32 @send_cmd(i32 0, i32 0)
%39 = tail call i32 @send_cmdWord_msb_first(i32 -1, i32 0, i32 32)
%40 = tail call i32 @send_cmdWord_msb_first(i32 -1432791706, i32 0, i32 32)
%41 = tail call i32 @send_cmdWord_msb_first(i32 536870912, i32 0, i32 32)
%42 = tail call i32 @send_cmdWord_msb_first(i32 671145986, i32 0, i32 32)
%43 = tail call i32 @send_cmdWord_msb_first(i32 536870912, i32 0, i32 32)
%44 = tail call i32 @send_cmdWord_msb_first(i32 536870912, i32 1, i32 32)
%45 = tail call i32 @send_cmd(i32 0, i32 1)
%46 = tail call i32 @send_cmd(i32 0, i32 1)
%47 = tail call i32 @send_cmd(i32 0, i32 1)
%48 = tail call i32 @send_cmd(i32 0, i32 0)
%49 = tail call i32 @send_cmd(i32 0, i32 0)
%50 = tail call i32 @send_cmdWord_msb_last(i32 16324, i32 1, i32 14)
%51 = tail call i32 @send_cmd(i32 0, i32 1)
%52 = tail call i32 @send_cmd(i32 0, i32 1)
%53 = tail call i32 @send_cmd(i32 0, i32 0)
%54 = tail call i32 @send_cmd(i32 0, i32 0)
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %57
57: ; preds = %0, %57
%58 = phi i32 [ 0, %0 ], [ %63, %57 ]
%59 = tail call i32 (...) @read_jtag_tdo()
%60 = tail call i32 @send_cmd(i32 0, i32 0)
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%63 = add nuw nsw i32 %58, 1
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %57
65: ; preds = %57
%66 = load i32, i32* @stderr
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}