#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 crc32(unsigned char, int, unsigned long);
int /*<<< orphan*/ dump_jreg(char *, unsigned char *, int);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
double or1ksim_jtag_shift_dr(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
void *reverse_bits(unsigned long, int);
int process_read_control(int next_jreg, int argc, char *argv[]) {
  printf("Processing READ_CONTROL.\n");
  unsigned long int cmd = 3;
  unsigned long int crc_in;
  crc_in = crc32(0, 1, 0xffffffff);
  crc_in = crc32(cmd, 4, crc_in);
  cmd = reverse_bits(cmd, 4);
  crc_in = reverse_bits(crc_in, 32);
  int num_bytes = 16;
  unsigned char *jreg = malloc(num_bytes);
  if (NULL == jreg) {
    printf("ERROR: malloc for READ_CONTROL register failed.\n");
    return 0;
  }
  memset(jreg, 0, num_bytes);
  jreg[0] = 0x0;
  jreg[0] |= cmd << 1;
  jreg[0] |= crc_in << 5;
  jreg[1] = crc_in >> 3;
  jreg[2] = crc_in >> 11;
  jreg[3] = crc_in >> 19;
  jreg[4] = crc_in >> 27;
  dump_jreg("  shifting in", jreg, num_bytes);
  double t = or1ksim_jtag_shift_dr(jreg, 32 + 4 + 52 + 32 + 4 + 1);
  dump_jreg("  shifted out", jreg, num_bytes);
  unsigned long long int creg;
  unsigned char status;
  unsigned long int crc_out;
  creg = ((unsigned long long int)jreg[4] >> 5) |
         ((unsigned long long int)jreg[5] << 3) |
         ((unsigned long long int)jreg[6] << 11) |
         ((unsigned long long int)jreg[7] << 19) |
         ((unsigned long long int)jreg[8] << 27) |
         ((unsigned long long int)jreg[9] << 35) |
         ((unsigned long long int)jreg[10] << 43) |
         ((unsigned long long int)(jreg[11] & 0x1) << 51);
  status = (jreg[11] >> 1) & 0xf;
  crc_out =
      ((unsigned long int)jreg[11] >> 5) | ((unsigned long int)jreg[12] << 3) |
      ((unsigned long int)jreg[13] << 11) |
      ((unsigned long int)jreg[14] << 19) | ((unsigned long int)jreg[15] << 27);
  creg = reverse_bits(creg, 52);
  status = reverse_bits(status, 4);
  crc_out = reverse_bits(crc_out, 32);
  unsigned long int crc_computed;
  crc_computed = crc32(creg, 52, 0xffffffff);
  crc_computed = crc32(status, 4, crc_computed);
  const char *reset = (1 == ((creg >> 51) & 1)) ? "enabled" : "disabled";
  const char *stall = (1 == ((creg >> 50) & 1)) ? "stalled" : "unstalled";
  printf("  reset:        %s\n", reset);
  printf("  stall:        %s\n", stall);
  printf("  status:       0x%01x\n", status);
  if (crc_out != crc_computed) {
    printf("  CRC mismatch\n");
    printf("    CRC out:      0x%08lx\n", crc_out);
    printf("    CRC computed: 0x%08lx\n", crc_computed);
  }
  printf("  time taken:   %.12fs\n", t);
  free(jreg);
  return 1;
}


x86 assembly (clang, -O0):
<process_read_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movq   $0x3,-0x20(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1040 <crc32@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rdx
mov    $0x4,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x20,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x28(%rbp)
movl   $0x10,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x38(%rbp),%rax
jne    1233 <process_read_control+0xb3>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    151f <process_read_control+0x39f>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
or     %rdx,%rcx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rdx
shl    $0x5,%rdx
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
or     %rdx,%rcx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
shr    $0x3,%rax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
shr    $0xb,%rax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%rax
shr    $0x13,%rax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rax
shr    $0x1b,%rax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    0xd89(%rip),%rdi
call   1050 <dump_jreg@plt>
mov    -0x38(%rbp),%rdi
mov    $0x7d,%esi
call   10a0 <or1ksim_jtag_shift_dr@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    0xd71(%rip),%rdi
call   1050 <dump_jreg@plt>
mov    -0x38(%rbp),%rax
movzbl 0x4(%rax),%eax
shr    $0x5,%rax
mov    -0x38(%rbp),%rcx
movzbl 0x5(%rcx),%ecx
shl    $0x3,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0x6(%rcx),%ecx
shl    $0xb,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
shl    $0x13,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0x8(%rcx),%ecx
shl    $0x1b,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0x9(%rcx),%ecx
shl    $0x23,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xa(%rcx),%ecx
shl    $0x2b,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xb(%rcx),%ecx
and    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x33,%rcx
or     %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
movzbl 0xb(%rax),%eax
sar    $0x1,%eax
and    $0xf,%eax
mov    %al,-0x49(%rbp)
mov    -0x38(%rbp),%rax
movzbl 0xb(%rax),%eax
shr    $0x5,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xc(%rcx),%ecx
shl    $0x3,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xd(%rcx),%ecx
shl    $0xb,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xe(%rcx),%ecx
shl    $0x13,%rcx
or     %rcx,%rax
mov    -0x38(%rbp),%rcx
movzbl 0xf(%rcx),%ecx
shl    $0x1b,%rcx
or     %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x34,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x48(%rbp)
movzbl -0x49(%rbp),%eax
mov    %eax,%edi
mov    $0x4,%esi
call   1060 <reverse_bits@plt>
mov    %al,-0x49(%rbp)
mov    -0x58(%rbp),%rdi
mov    $0x20,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rax
mov    $0x34,%esi
mov    $0xffffffff,%edx
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x60(%rbp)
mov    -0x49(%rbp),%al
mov    -0x60(%rbp),%rdx
mov    $0x4,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rsi
shr    $0x33,%rsi
and    $0x1,%rsi
mov    $0x1,%edx
lea    0xc25(%rip),%rax
lea    0xc16(%rip),%rcx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x48(%rbp),%rsi
shr    $0x32,%rsi
and    $0x1,%rsi
mov    $0x1,%edx
lea    0xc04(%rip),%rax
lea    0xbff(%rip),%rcx
cmp    %rsi,%rdx
cmove  %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movzbl -0x49(%rbp),%esi
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%rax
cmp    -0x60(%rbp),%rax
je     14fc <process_read_control+0x37c>
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xbef(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x60(%rbp),%rsi
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xc00(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_read_control>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf23(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
mov    $0xffffffff,%edx
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <crc32@plt>
mov    $0x3,%edi
mov    $0x4,%esi
mov    %rax,%rdx
call   1050 <crc32@plt>
mov    %rax,%rbx
mov    $0x3,%edi
mov    $0x4,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%rbp
mov    $0x10,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1429 <process_read_control+0x299>
mov    %rax,%r13
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
add    %r15d,%r15d
mov    %ebp,%eax
shl    $0x5,%eax
or     %r15d,%eax
mov    %al,0x0(%r13)
mov    %rbp,%rax
shr    $0x3,%rax
mov    %al,0x1(%r13)
mov    %rbp,%rax
shr    $0xb,%rax
mov    %al,0x2(%r13)
mov    %rbp,%rax
shr    $0x13,%rax
mov    %al,0x3(%r13)
shr    $0x1b,%rbp
mov    %bpl,0x4(%r13)
lea    0xdaa(%rip),%rdi
mov    %r13,%rsi
mov    $0x10,%edx
call   1060 <dump_jreg@plt>
mov    %r13,%rdi
mov    $0x7d,%esi
call   10b0 <or1ksim_jtag_shift_dr@plt>
movsd  %xmm0,(%rsp)
lea    0xd92(%rip),%rdi
mov    %r13,%rsi
mov    $0x10,%edx
call   1060 <dump_jreg@plt>
movzbl 0x4(%r13),%eax
shr    $0x5,%rax
movzbl 0x5(%r13),%ecx
lea    (%rax,%rcx,8),%rax
movzbl 0x6(%r13),%ecx
shl    $0xb,%rcx
or     %rax,%rcx
movzbl 0x7(%r13),%eax
shl    $0x13,%rax
or     %rcx,%rax
movzbl 0x8(%r13),%ecx
shl    $0x1b,%rcx
or     %rax,%rcx
movzbl 0x9(%r13),%eax
shl    $0x23,%rax
or     %rcx,%rax
movzbl 0xa(%r13),%ecx
shl    $0x2b,%rcx
movzbl 0xb(%r13),%edx
mov    %edx,%edi
and    $0x1,%edi
shl    $0x33,%rdi
or     %rcx,%rdi
or     %rax,%rdi
mov    %edx,%ebp
shr    %ebp
and    $0xf,%ebp
shr    $0x5,%rdx
movzbl 0xc(%r13),%eax
lea    (%rdx,%rax,8),%rax
movzbl 0xd(%r13),%ecx
shl    $0xb,%rcx
or     %rax,%rcx
movzbl 0xe(%r13),%eax
shl    $0x13,%rax
or     %rcx,%rax
movzbl 0xf(%r13),%ebx
shl    $0x1b,%rbx
or     %rax,%rbx
mov    $0x34,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r12
mov    %rbp,%rdi
mov    $0x4,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r14
movzbl %r12b,%edi
mov    $0xffffffff,%edx
mov    $0x34,%esi
call   1050 <crc32@plt>
movzbl %bpl,%ebp
mov    %ebp,%edi
mov    $0x4,%esi
mov    %rax,%rdx
call   1050 <crc32@plt>
mov    %rax,%r15
bt     $0x33,%r12
lea    0xca2(%rip),%rax
lea    0xc93(%rip),%rsi
cmovae %rax,%rsi
bt     $0x32,%r12
lea    0xc94(%rip),%rax
lea    0xc8f(%rip),%rbx
cmovae %rax,%rbx
lea    0xc8c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc95(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    %r14,%r15
je     1406 <process_read_control+0x276>
lea    0xcff(%rip),%rdi
call   1040 <puts@plt>
lea    0xc8c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc96(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xca0(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x1,%r14d
jmp    1435 <process_read_control+0x2a5>
lea    0xcbd(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Processing READ_CONTROL.\0A\00"
@.str.1 = [49 x i8] c"ERROR: malloc for READ_CONTROL register failed.\0A\00"
@.str.2 = [14 x i8] c" shifting in\00"
@.str.3 = [14 x i8] c" shifted out\00"
@.str.4 = [8 x i8] c"enabled\00"
@.str.5 = [9 x i8] c"disabled\00"
@.str.6 = [8 x i8] c"stalled\00"
@.str.7 = [10 x i8] c"unstalled\00"
@.str.8 = [20 x i8] c" reset: %s\0A\00"
@.str.9 = [20 x i8] c" stall: %s\0A\00"
@.str.10 = [24 x i8] c" status: 0x%01x\0A\00"
@.str.11 = [16 x i8] c" CRC mismatch\0A\00"
@.str.12 = [27 x i8] c" CRC out: 0x%08lx\0A\00"
@.str.13 = [27 x i8] c" CRC computed: 0x%08lx\0A\00"
@.str.14 = [24 x i8] c" time taken: %.12fs\0A\00"
define i32 @process_read_control(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
%12 = alloca double
%13 = alloca i64
%14 = alloca i8
%15 = alloca i64
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i64 3, i64* %8
%20 = call i64 @crc32(i8 zeroext 0, i32 1, i64 4294967295)
store i64 %20, i64* %9
%21 = load i64, i64* %8
%22 = trunc i64 %21 to i8
%23 = load i64, i64* %9
%24 = call i64 @crc32(i8 zeroext %22, i32 4, i64 %23)
store i64 %24, i64* %9
%25 = load i64, i64* %8
%26 = call i8* @reverse_bits(i64 %25, i32 4)
%27 = ptrtoint i8* %26 to i64
store i64 %27, i64* %8
%28 = load i64, i64* %9
%29 = call i8* @reverse_bits(i64 %28, i32 32)
%30 = ptrtoint i8* %29 to i64
store i64 %30, i64* %9
store i32 16, i32* %10
%31 = load i32, i32* %10
%32 = call i8* @malloc(i32 %31)
store i8* %32, i8** %11
%33 = load i8*, i8** %11
%34 = icmp eq i8* null, %33
br i1 %34, label %35, label %37
35: ; preds = %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %221
37: ; preds = %3
%38 = load i8*, i8** %11
%39 = load i32, i32* %10
%40 = call i32 @memset(i8* %38, i32 0, i32 %39)
%41 = load i8*, i8** %11
%42 = getelementptr inbounds i8, i8* %41, i64 0
store i8 0, i8* %42
%43 = load i64, i64* %8
%44 = shl i64 %43, 1
%45 = load i8*, i8** %11
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = zext i8 %47 to i64
%49 = or i64 %48, %44
%50 = trunc i64 %49 to i8
store i8 %50, i8* %46
%51 = load i64, i64* %9
%52 = shl i64 %51, 5
%53 = load i8*, i8** %11
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = zext i8 %55 to i64
%57 = or i64 %56, %52
%58 = trunc i64 %57 to i8
store i8 %58, i8* %54
%59 = load i64, i64* %9
%60 = lshr i64 %59, 3
%61 = trunc i64 %60 to i8
%62 = load i8*, i8** %11
%63 = getelementptr inbounds i8, i8* %62, i64 1
store i8 %61, i8* %63
%64 = load i64, i64* %9
%65 = lshr i64 %64, 11
%66 = trunc i64 %65 to i8
%67 = load i8*, i8** %11
%68 = getelementptr inbounds i8, i8* %67, i64 2
store i8 %66, i8* %68
%69 = load i64, i64* %9
%70 = lshr i64 %69, 19
%71 = trunc i64 %70 to i8
%72 = load i8*, i8** %11
%73 = getelementptr inbounds i8, i8* %72, i64 3
store i8 %71, i8* %73
%74 = load i64, i64* %9
%75 = lshr i64 %74, 27
%76 = trunc i64 %75 to i8
%77 = load i8*, i8** %11
%78 = getelementptr inbounds i8, i8* %77, i64 4
store i8 %76, i8* %78
%79 = load i8*, i8** %11
%80 = load i32, i32* %10
%81 = call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %79, i32 %80)
%82 = load i8*, i8** %11
%83 = call double @or1ksim_jtag_shift_dr(i8* %82, i32 125)
store double %83, double* %12
%84 = load i8*, i8** %11
%85 = load i32, i32* %10
%86 = call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %84, i32 %85)
%87 = load i8*, i8** %11
%88 = getelementptr inbounds i8, i8* %87, i64 4
%89 = load i8, i8* %88
%90 = zext i8 %89 to i64
%91 = lshr i64 %90, 5
%92 = load i8*, i8** %11
%93 = getelementptr inbounds i8, i8* %92, i64 5
%94 = load i8, i8* %93
%95 = zext i8 %94 to i64
%96 = shl i64 %95, 3
%97 = or i64 %91, %96
%98 = load i8*, i8** %11
%99 = getelementptr inbounds i8, i8* %98, i64 6
%100 = load i8, i8* %99
%101 = zext i8 %100 to i64
%102 = shl i64 %101, 11
%103 = or i64 %97, %102
%104 = load i8*, i8** %11
%105 = getelementptr inbounds i8, i8* %104, i64 7
%106 = load i8, i8* %105
%107 = zext i8 %106 to i64
%108 = shl i64 %107, 19
%109 = or i64 %103, %108
%110 = load i8*, i8** %11
%111 = getelementptr inbounds i8, i8* %110, i64 8
%112 = load i8, i8* %111
%113 = zext i8 %112 to i64
%114 = shl i64 %113, 27
%115 = or i64 %109, %114
%116 = load i8*, i8** %11
%117 = getelementptr inbounds i8, i8* %116, i64 9
%118 = load i8, i8* %117
%119 = zext i8 %118 to i64
%120 = shl i64 %119, 35
%121 = or i64 %115, %120
%122 = load i8*, i8** %11
%123 = getelementptr inbounds i8, i8* %122, i64 10
%124 = load i8, i8* %123
%125 = zext i8 %124 to i64
%126 = shl i64 %125, 43
%127 = or i64 %121, %126
%128 = load i8*, i8** %11
%129 = getelementptr inbounds i8, i8* %128, i64 11
%130 = load i8, i8* %129
%131 = zext i8 %130 to i32
%132 = and i32 %131, 1
%133 = sext i32 %132 to i64
%134 = shl i64 %133, 51
%135 = or i64 %127, %134
store i64 %135, i64* %13
%136 = load i8*, i8** %11
%137 = getelementptr inbounds i8, i8* %136, i64 11
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = ashr i32 %139, 1
%141 = and i32 %140, 15
%142 = trunc i32 %141 to i8
store i8 %142, i8* %14
%143 = load i8*, i8** %11
%144 = getelementptr inbounds i8, i8* %143, i64 11
%145 = load i8, i8* %144
%146 = zext i8 %145 to i64
%147 = lshr i64 %146, 5
%148 = load i8*, i8** %11
%149 = getelementptr inbounds i8, i8* %148, i64 12
%150 = load i8, i8* %149
%151 = zext i8 %150 to i64
%152 = shl i64 %151, 3
%153 = or i64 %147, %152
%154 = load i8*, i8** %11
%155 = getelementptr inbounds i8, i8* %154, i64 13
%156 = load i8, i8* %155
%157 = zext i8 %156 to i64
%158 = shl i64 %157, 11
%159 = or i64 %153, %158
%160 = load i8*, i8** %11
%161 = getelementptr inbounds i8, i8* %160, i64 14
%162 = load i8, i8* %161
%163 = zext i8 %162 to i64
%164 = shl i64 %163, 19
%165 = or i64 %159, %164
%166 = load i8*, i8** %11
%167 = getelementptr inbounds i8, i8* %166, i64 15
%168 = load i8, i8* %167
%169 = zext i8 %168 to i64
%170 = shl i64 %169, 27
%171 = or i64 %165, %170
store i64 %171, i64* %15
%172 = load i64, i64* %13
%173 = call i8* @reverse_bits(i64 %172, i32 52)
%174 = ptrtoint i8* %173 to i64
store i64 %174, i64* %13
%175 = load i8, i8* %14
%176 = zext i8 %175 to i64
%177 = call i8* @reverse_bits(i64 %176, i32 4)
%178 = ptrtoint i8* %177 to i8
store i8 %178, i8* %14
%179 = load i64, i64* %15
%180 = call i8* @reverse_bits(i64 %179, i32 32)
%181 = ptrtoint i8* %180 to i64
store i64 %181, i64* %15
%182 = load i64, i64* %13
%183 = trunc i64 %182 to i8
%184 = call i64 @crc32(i8 zeroext %183, i32 52, i64 4294967295)
store i64 %184, i64* %16
%185 = load i8, i8* %14
%186 = load i64, i64* %16
%187 = call i64 @crc32(i8 zeroext %185, i32 4, i64 %186)
store i64 %187, i64* %16
%188 = load i64, i64* %13
%189 = lshr i64 %188, 51
%190 = and i64 %189, 1
%191 = icmp eq i64 1, %190
%192 = zext i1 %191 to i64
%193 = select i1 %191, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0)
store i8* %193, i8** %17
%194 = load i64, i64* %13
%195 = lshr i64 %194, 50
%196 = and i64 %195, 1
%197 = icmp eq i64 1, %196
%198 = zext i1 %197 to i64
%199 = select i1 %197, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0)
store i8* %199, i8** %18
%200 = load i8*, i8** %17
%201 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %200)
%202 = load i8*, i8** %18
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %202)
%204 = load i8, i8* %14
%205 = zext i8 %204 to i32
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %205)
%207 = load i64, i64* %15
%208 = load i64, i64* %16
%209 = icmp ne i64 %207, %208
br i1 %209, label %210, label %216
210: ; preds = %37
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%212 = load i64, i64* %15
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i64 %212)
%214 = load i64, i64* %16
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %214)
br label %216
216: ; preds = %210, %37
%217 = load double, double* %12
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), double %217)
%219 = load i8*, i8** %11
%220 = call i32 @free(i8* %219)
store i32 1, i32* %4
br label %221
221: ; preds = %216, %35
%222 = load i32, i32* %4
ret i32 %222
}

LLVM IR (-O2):
@.str.2 = [14 x i8] c" shifting in\00"
@.str.3 = [14 x i8] c" shifted out\00"
@.str.4 = [8 x i8] c"enabled\00"
@.str.5 = [9 x i8] c"disabled\00"
@.str.6 = [8 x i8] c"stalled\00"
@.str.7 = [10 x i8] c"unstalled\00"
@.str.8 = [20 x i8] c" reset: %s\0A\00"
@.str.9 = [20 x i8] c" stall: %s\0A\00"
@.str.10 = [24 x i8] c" status: 0x%01x\0A\00"
@.str.12 = [27 x i8] c" CRC out: 0x%08lx\0A\00"
@.str.13 = [27 x i8] c" CRC computed: 0x%08lx\0A\00"
@.str.14 = [24 x i8] c" time taken: %.12fs\0A\00"
@str = [25 x i8] c"Processing READ_CONTROL.\00"
@str.15 = [15 x i8] c" CRC mismatch\00"
@str.16 = [48 x i8] c"ERROR: malloc for READ_CONTROL register failed.\00"
define i32 @process_read_control(i32 %0, i32 %1, i8** nocapture readnone %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%5 = tail call i64 @crc32(i8 zeroext 0, i32 1, i64 4294967295)
%6 = tail call i64 @crc32(i8 zeroext 3, i32 4, i64 %5)
%7 = tail call i8* @reverse_bits(i64 3, i32 4)
%8 = tail call i8* @reverse_bits(i64 %6, i32 32)
%9 = ptrtoint i8* %8 to i64
%10 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.16, i64 0, i64 0))
br label %129
14: ; preds = %3
%15 = ptrtoint i8* %7 to i64
%16 = tail call i32 @memset(i8* %10, i32 0, i32 16)
%17 = shl i64 %15, 1
%18 = shl i64 %9, 5
%19 = or i64 %18, %17
%20 = trunc i64 %19 to i8
store i8 %20, i8* %10
%21 = lshr i64 %9, 3
%22 = trunc i64 %21 to i8
%23 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %22, i8* %23
%24 = lshr i64 %9, 11
%25 = trunc i64 %24 to i8
%26 = getelementptr inbounds i8, i8* %10, i64 2
store i8 %25, i8* %26
%27 = lshr i64 %9, 19
%28 = trunc i64 %27 to i8
%29 = getelementptr inbounds i8, i8* %10, i64 3
store i8 %28, i8* %29
%30 = lshr i64 %9, 27
%31 = trunc i64 %30 to i8
%32 = getelementptr inbounds i8, i8* %10, i64 4
store i8 %31, i8* %32
%33 = tail call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 16)
%34 = tail call double @or1ksim_jtag_shift_dr(i8* %10, i32 125)
%35 = tail call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %10, i32 16)
%36 = load i8, i8* %32
%37 = lshr i8 %36, 5
%38 = zext i8 %37 to i64
%39 = getelementptr inbounds i8, i8* %10, i64 5
%40 = load i8, i8* %39
%41 = zext i8 %40 to i64
%42 = shl nuw nsw i64 %41, 3
%43 = or i64 %42, %38
%44 = getelementptr inbounds i8, i8* %10, i64 6
%45 = load i8, i8* %44
%46 = zext i8 %45 to i64
%47 = shl nuw nsw i64 %46, 11
%48 = or i64 %43, %47
%49 = getelementptr inbounds i8, i8* %10, i64 7
%50 = load i8, i8* %49
%51 = zext i8 %50 to i64
%52 = shl nuw nsw i64 %51, 19
%53 = or i64 %48, %52
%54 = getelementptr inbounds i8, i8* %10, i64 8
%55 = load i8, i8* %54
%56 = zext i8 %55 to i64
%57 = shl nuw nsw i64 %56, 27
%58 = or i64 %53, %57
%59 = getelementptr inbounds i8, i8* %10, i64 9
%60 = load i8, i8* %59
%61 = zext i8 %60 to i64
%62 = shl nuw nsw i64 %61, 35
%63 = or i64 %58, %62
%64 = getelementptr inbounds i8, i8* %10, i64 10
%65 = load i8, i8* %64
%66 = zext i8 %65 to i64
%67 = shl nuw nsw i64 %66, 43
%68 = or i64 %63, %67
%69 = getelementptr inbounds i8, i8* %10, i64 11
%70 = load i8, i8* %69
%71 = and i8 %70, 1
%72 = zext i8 %71 to i64
%73 = shl nuw nsw i64 %72, 51
%74 = or i64 %68, %73
%75 = lshr i8 %70, 1
%76 = and i8 %75, 15
%77 = lshr i8 %70, 5
%78 = zext i8 %77 to i64
%79 = getelementptr inbounds i8, i8* %10, i64 12
%80 = load i8, i8* %79
%81 = zext i8 %80 to i64
%82 = shl nuw nsw i64 %81, 3
%83 = or i64 %82, %78
%84 = getelementptr inbounds i8, i8* %10, i64 13
%85 = load i8, i8* %84
%86 = zext i8 %85 to i64
%87 = shl nuw nsw i64 %86, 11
%88 = or i64 %83, %87
%89 = getelementptr inbounds i8, i8* %10, i64 14
%90 = load i8, i8* %89
%91 = zext i8 %90 to i64
%92 = shl nuw nsw i64 %91, 19
%93 = or i64 %88, %92
%94 = getelementptr inbounds i8, i8* %10, i64 15
%95 = load i8, i8* %94
%96 = zext i8 %95 to i64
%97 = shl nuw nsw i64 %96, 27
%98 = or i64 %93, %97
%99 = tail call i8* @reverse_bits(i64 %74, i32 52)
%100 = ptrtoint i8* %99 to i64
%101 = zext i8 %76 to i64
%102 = tail call i8* @reverse_bits(i64 %101, i32 4)
%103 = ptrtoint i8* %102 to i64
%104 = trunc i64 %103 to i8
%105 = tail call i8* @reverse_bits(i64 %98, i32 32)
%106 = ptrtoint i8* %105 to i64
%107 = trunc i64 %100 to i8
%108 = tail call i64 @crc32(i8 zeroext %107, i32 52, i64 4294967295)
%109 = tail call i64 @crc32(i8 zeroext %104, i32 4, i64 %108)
%110 = and i64 %100, 2251799813685248
%111 = icmp eq i64 %110, 0
%112 = select i1 %111, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%113 = and i64 %100, 1125899906842624
%114 = icmp eq i64 %113, 0
%115 = select i1 %114, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0)
%116 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %112)
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %115)
%118 = trunc i64 %103 to i32
%119 = and i32 %118, 255
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %119)
%121 = icmp eq i64 %109, %106
br i1 %121, label %126, label %122
122: ; preds = %14
%123 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i64 %106)
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %109)
br label %126
126: ; preds = %122, %14
%127 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), double %34)
%128 = tail call i32 @free(i8* %10)
br label %129
129: ; preds = %126, %12
%130 = phi i32 [ 0, %12 ], [ 1, %126 ]
ret i32 %130
}