#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, int);
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 strtoul(char *, int /*<<< orphan*/ *, int);
int process_write_command(int next_jreg, int argc, char *argv[]) {
  printf("Processing WRITE_COMMAND.\n");
  if (next_jreg + 3 > argc) {
    printf("WRITE_COMMAND usage: WRITE_COMMAND <access_type> <address> "
           "<length>\n");
    return 0;
  }
  unsigned long int cmd = 2;
  unsigned long int access_type = strtoul(argv[next_jreg], NULL, 16);
  unsigned long int addr = strtoul(argv[next_jreg + 1], NULL, 16);
  unsigned long int len = strtoul(argv[next_jreg + 2], NULL, 16) - 1;
  if (access_type > 0xf) {
    printf("ERROR: WRITE_COMMAND access type 0x%lx too large\n", access_type);
    return 0;
  }
  if (addr > 0xffffffff) {
    printf("ERROR: WRITE_COMMAND address 0x%lx too large\n", addr);
    return 0;
  }
  if ((len + 1) < 0x1) {
    printf("ERROR: WRITE_COMMAND length 0x%lx too small\n", len + 1);
    return 0;
  } else if ((len + 1) > 0x10000) {
    printf("ERROR: WRITE_COMMAND length 0x%lx too large\n", len + 1);
    return 0;
  }
  unsigned long int crc_in;
  crc_in = crc32(0, 1, 0xffffffff);
  crc_in = crc32(cmd, 4, crc_in);
  crc_in = crc32(access_type, 4, crc_in);
  crc_in = crc32(addr, 32, crc_in);
  crc_in = crc32(len, 16, crc_in);
  cmd = reverse_bits(cmd, 4);
  access_type = reverse_bits(access_type, 4);
  addr = reverse_bits(addr, 32);
  len = reverse_bits(len, 16);
  crc_in = reverse_bits(crc_in, 32);
  int num_bytes = 16;
  unsigned char *jreg = malloc(num_bytes);
  if (NULL == jreg) {
    printf("ERROR: malloc for WRITE_COMMAND register failed.\n");
    return 0;
  }
  memset(jreg, 0, num_bytes);
  jreg[0] = 0x0;
  jreg[0] |= cmd << 1;
  jreg[0] |= access_type << 5;
  jreg[1] = access_type >> 3;
  jreg[1] |= addr << 1;
  jreg[2] = addr >> 7;
  jreg[3] = addr >> 15;
  jreg[4] = addr >> 23;
  jreg[5] = addr >> 31;
  jreg[5] |= len << 1;
  jreg[6] = len >> 7;
  jreg[7] = len >> 15;
  jreg[7] |= crc_in << 1;
  jreg[8] = crc_in >> 7;
  jreg[9] = crc_in >> 15;
  jreg[10] = crc_in >> 23;
  jreg[11] = crc_in >> 31;
  dump_jreg("  shifting in", jreg, num_bytes);
  double t = or1ksim_jtag_shift_dr(jreg, 32 + 4 + 32 + 16 + 32 + 4 + 4 + 1);
  dump_jreg("  shifted out", jreg, num_bytes);
  unsigned char status;
  unsigned long int crc_out;
  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);
  status = reverse_bits(status, 4);
  crc_out = reverse_bits(crc_out, 32);
  unsigned long int crc_computed = crc32(status, 4, 0xffffffff);
  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_write_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
cmp    -0xc(%rbp),%eax
jle    11d9 <process_write_command+0x49>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
movq   $0x2,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10b0 <strtoul@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10b0 <strtoul@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10b0 <strtoul@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
cmpq   $0xf,-0x28(%rbp)
jbe    1277 <process_write_command+0xe7>
mov    -0x28(%rbp),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
mov    $0xffffffff,%eax
cmp    %rax,-0x30(%rbp)
jbe    12a4 <process_write_command+0x114>
mov    -0x30(%rbp),%rsi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
cmp    $0x1,%rax
jae    12d8 <process_write_command+0x148>
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
cmp    $0x10000,%rax
jbe    130e <process_write_command+0x17e>
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
jmp    1313 <process_write_command+0x183>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1040 <crc32@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %ecx,%edx
mov    $0x4,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %ecx,%edx
mov    $0x4,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %ecx,%edx
mov    $0x20,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %ecx,%edx
mov    $0x10,%esi
movzbl %al,%edi
call   1040 <crc32@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x4,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x10,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x40(%rbp)
movl   $0x10,-0x44(%rbp)
mov    -0x44(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
xor    %eax,%eax
cmp    -0x50(%rbp),%rax
jne    1427 <process_write_command+0x297>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16a8 <process_write_command+0x518>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x50(%rbp),%rax
movzbl (%rax),%ecx
or     %rdx,%rcx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rdx
shl    $0x5,%rdx
mov    -0x50(%rbp),%rax
movzbl (%rax),%ecx
or     %rdx,%rcx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
shr    $0x3,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x30(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x50(%rbp),%rax
movzbl 0x1(%rax),%ecx
or     %rdx,%rcx
mov    %cl,0x1(%rax)
mov    -0x30(%rbp),%rax
shr    $0x7,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x30(%rbp),%rax
shr    $0xf,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x30(%rbp),%rax
shr    $0x17,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x30(%rbp),%rax
shr    $0x1f,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x38(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x50(%rbp),%rax
movzbl 0x5(%rax),%ecx
or     %rdx,%rcx
mov    %cl,0x5(%rax)
mov    -0x38(%rbp),%rax
shr    $0x7,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x38(%rbp),%rax
shr    $0xf,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x40(%rbp),%rdx
shl    $0x1,%rdx
mov    -0x50(%rbp),%rax
movzbl 0x7(%rax),%ecx
or     %rdx,%rcx
mov    %cl,0x7(%rax)
mov    -0x40(%rbp),%rax
shr    $0x7,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x40(%rbp),%rax
shr    $0xf,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x9(%rax)
mov    -0x40(%rbp),%rax
shr    $0x17,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0xa(%rax)
mov    -0x40(%rbp),%rax
shr    $0x1f,%rax
mov    %al,%cl
mov    -0x50(%rbp),%rax
mov    %cl,0xb(%rax)
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
lea    0xbdd(%rip),%rdi
call   1050 <dump_jreg@plt>
mov    -0x50(%rbp),%rdi
mov    $0x7d,%esi
call   10a0 <or1ksim_jtag_shift_dr@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
lea    0xbc5(%rip),%rdi
call   1050 <dump_jreg@plt>
mov    -0x50(%rbp),%rax
movzbl 0xb(%rax),%eax
sar    $0x1,%eax
and    $0xf,%eax
mov    %al,-0x59(%rbp)
mov    -0x50(%rbp),%rax
movzbl 0xb(%rax),%eax
shr    $0x5,%rax
mov    -0x50(%rbp),%rcx
movzbl 0xc(%rcx),%ecx
shl    $0x3,%rcx
or     %rcx,%rax
mov    -0x50(%rbp),%rcx
movzbl 0xd(%rcx),%ecx
shl    $0xb,%rcx
or     %rcx,%rax
mov    -0x50(%rbp),%rcx
movzbl 0xe(%rcx),%ecx
shl    $0x13,%rcx
or     %rcx,%rax
mov    -0x50(%rbp),%rcx
movzbl 0xf(%rcx),%ecx
shl    $0x1b,%rcx
or     %rcx,%rax
mov    %rax,-0x68(%rbp)
movzbl -0x59(%rbp),%eax
mov    %eax,%edi
mov    $0x4,%esi
call   1060 <reverse_bits@plt>
mov    %al,-0x59(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x20,%esi
call   1060 <reverse_bits@plt>
mov    %rax,-0x68(%rbp)
mov    $0x4,%esi
mov    $0xffffffff,%edx
movzbl -0x59(%rbp),%edi
call   1040 <crc32@plt>
mov    %rax,-0x70(%rbp)
movzbl -0x59(%rbp),%esi
lea    0xb2a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
je     1685 <process_write_command+0x4f5>
lea    0xb26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x68(%rbp),%rsi
lea    0xb24(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xb2d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xb35(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x50(%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_write_command>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xf80(%rip),%rdi
call   1040 <puts@plt>
lea    0x3(%rbx),%eax
cmp    %ebp,%eax
jle    11dc <process_write_command+0x3c>
lea    0xfc7(%rip),%rdi
call   1040 <puts@plt>
xor    %r13d,%r13d
jmp    1278 <process_write_command+0xd8>
movslq %ebx,%rbp
mov    (%r15,%rbp,8),%rdi
xor    %r13d,%r13d
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtoul@plt>
movslq %eax,%r14
mov    0x8(%r15,%rbp,8),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtoul@plt>
mov    %eax,%ebx
mov    0x10(%r15,%rbp,8),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtoul@plt>
cmp    $0x10,%r14d
jb     122b <process_write_command+0x8b>
lea    0xdda(%rip),%rdi
mov    %r14,%rsi
jmp    1271 <process_write_command+0xd1>
movslq %ebx,%r15
test   %r15d,%r15d
js     124f <process_write_command+0xaf>
add    $0xffffffff,%eax
movslq %eax,%r12
mov    %r12,%rsi
inc    %rsi
jne    125e <process_write_command+0xbe>
lea    0xe18(%rip),%rdi
xor    %r13d,%r13d
xor    %esi,%esi
jmp    1271 <process_write_command+0xd1>
lea    0xddc(%rip),%rdi
xor    %r13d,%r13d
mov    %r15,%rsi
jmp    1271 <process_write_command+0xd1>
cmp    $0x10001,%rsi
jb     128a <process_write_command+0xea>
lea    0xe1f(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
xor    %edi,%edi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1050 <crc32@plt>
mov    $0x2,%edi
mov    $0x4,%esi
mov    %eax,%edx
call   1050 <crc32@plt>
movzbl %r14b,%edi
mov    $0x4,%esi
mov    %eax,%edx
call   1050 <crc32@plt>
movzbl %r15b,%edi
mov    $0x20,%esi
mov    %eax,%edx
call   1050 <crc32@plt>
movzbl %r12b,%edi
mov    $0x10,%esi
mov    %eax,%edx
call   1050 <crc32@plt>
mov    %rax,0x8(%rsp)
mov    $0x2,%edi
mov    $0x4,%esi
call   1070 <reverse_bits@plt>
mov    %rax,0x10(%rsp)
mov    %r14,%rdi
mov    $0x4,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    $0x20,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x10,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rdi
mov    $0x20,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r15
mov    $0x10,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1507 <process_write_command+0x367>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    0x10(%rsp),%rcx
add    %ecx,%ecx
mov    %ebp,%eax
shl    $0x5,%eax
or     %ecx,%eax
mov    %al,(%r14)
lea    (%rbx,%rbx,1),%eax
shr    $0x3,%ebp
or     %eax,%ebp
mov    %bpl,0x1(%r14)
mov    %rbx,%rax
shr    $0x7,%rax
mov    %al,0x2(%r14)
mov    %rbx,%rax
shr    $0xf,%rax
mov    %al,0x3(%r14)
mov    %rbx,%rax
shr    $0x17,%rax
mov    %al,0x4(%r14)
shr    $0x1f,%rbx
lea    (%r12,%r12,1),%eax
or     %eax,%ebx
mov    %bl,0x5(%r14)
mov    %r12,%rax
shr    $0x7,%rax
mov    %al,0x6(%r14)
lea    (%r15,%r15,1),%eax
shr    $0xf,%r12d
or     %eax,%r12d
mov    %r12b,0x7(%r14)
mov    %r15,%rax
shr    $0x7,%rax
mov    %al,0x8(%r14)
mov    %r15,%rax
shr    $0xf,%rax
mov    %al,0x9(%r14)
mov    %r15,%rax
shr    $0x17,%rax
mov    %al,0xa(%r14)
shr    $0x1f,%r15
mov    %r15b,0xb(%r14)
lea    0xcc5(%rip),%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1060 <dump_jreg@plt>
mov    %r14,%rdi
mov    $0x7d,%esi
call   10b0 <or1ksim_jtag_shift_dr@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xcac(%rip),%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1060 <dump_jreg@plt>
movzbl 0xb(%r14),%edi
movzbl %dil,%eax
shr    %edi
and    $0xf,%edi
shr    $0x5,%rax
movzbl 0xc(%r14),%ecx
lea    (%rax,%rcx,8),%rax
movzbl 0xd(%r14),%ecx
shl    $0xb,%rcx
or     %rax,%rcx
movzbl 0xe(%r14),%eax
shl    $0x13,%rax
or     %rcx,%rax
movzbl 0xf(%r14),%ebx
shl    $0x1b,%rbx
or     %rax,%rbx
mov    $0x4,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <reverse_bits@plt>
mov    %rax,%r15
movzbl %bpl,%ebx
mov    %ebx,%edi
mov    $0x4,%esi
mov    $0xffffffff,%edx
call   1050 <crc32@plt>
mov    %rax,%rbp
lea    0xc32(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    %r15,%rbp
je     14e0 <process_write_command+0x340>
lea    0xc9d(%rip),%rdi
call   1040 <puts@plt>
lea    0xc29(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc33(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc3d(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x1,%r13d
jmp    1278 <process_write_command+0xd8>
lea    0xc57(%rip),%rdi
call   1040 <puts@plt>
jmp    1278 <process_write_command+0xd8>

LLVM IR (-O0):
@.str = [27 x i8] c"Processing WRITE_COMMAND.\0A\00"
@.str.1 = [69 x i8] c"WRITE_COMMAND usage: WRITE_COMMAND <access_type> <address> <length>\0A\00"
@.str.2 = [50 x i8] c"ERROR: WRITE_COMMAND access type 0x%lx too large\0A\00"
@.str.3 = [46 x i8] c"ERROR: WRITE_COMMAND address 0x%lx too large\0A\00"
@.str.4 = [45 x i8] c"ERROR: WRITE_COMMAND length 0x%lx too small\0A\00"
@.str.5 = [45 x i8] c"ERROR: WRITE_COMMAND length 0x%lx too large\0A\00"
@.str.6 = [50 x i8] c"ERROR: malloc for WRITE_COMMAND register failed.\0A\00"
@.str.7 = [14 x i8] c" shifting in\00"
@.str.8 = [14 x i8] c" shifted out\00"
@.str.9 = [24 x i8] c" status: 0x%01x\0A\00"
@.str.10 = [16 x i8] c" CRC mismatch\0A\00"
@.str.11 = [27 x i8] c" CRC out: 0x%08lx\0A\00"
@.str.12 = [27 x i8] c" CRC computed: 0x%08lx\0A\00"
@.str.13 = [24 x i8] c" time taken: %.12fs\0A\00"
define i32 @process_write_command(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 i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i8*
%15 = alloca double
%16 = alloca i8
%17 = alloca i64
%18 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 3
%22 = load i32, i32* %6
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %293
26: ; preds = %3
store i64 2, i64* %8
%27 = load i8**, i8*** %7
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strtoul(i8* %31, i32* null, i32 16)
%33 = sext i32 %32 to i64
store i64 %33, i64* %9
%34 = load i8**, i8*** %7
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @strtoul(i8* %39, i32* null, i32 16)
%41 = sext i32 %40 to i64
store i64 %41, i64* %10
%42 = load i8**, i8*** %7
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @strtoul(i8* %47, i32* null, i32 16)
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
store i64 %50, i64* %11
%51 = load i64, i64* %9
%52 = icmp ugt i64 %51, 15
br i1 %52, label %53, label %56
53: ; preds = %26
%54 = load i64, i64* %9
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i64 %54)
store i32 0, i32* %4
br label %293
56: ; preds = %26
%57 = load i64, i64* %10
%58 = icmp ugt i64 %57, 4294967295
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i64, i64* %10
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i64 %60)
store i32 0, i32* %4
br label %293
62: ; preds = %56
%63 = load i64, i64* %11
%64 = add i64 %63, 1
%65 = icmp ult i64 %64, 1
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i64, i64* %11
%68 = add i64 %67, 1
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i64 %68)
store i32 0, i32* %4
br label %293
70: ; preds = %62
%71 = load i64, i64* %11
%72 = add i64 %71, 1
%73 = icmp ugt i64 %72, 65536
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i64, i64* %11
%76 = add i64 %75, 1
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i64 %76)
store i32 0, i32* %4
br label %293
78: ; preds = %70
br label %79
79: ; preds = %78
%80 = call i64 @crc32(i8 zeroext 0, i32 1, i32 -1)
store i64 %80, i64* %12
%81 = load i64, i64* %8
%82 = trunc i64 %81 to i8
%83 = load i64, i64* %12
%84 = trunc i64 %83 to i32
%85 = call i64 @crc32(i8 zeroext %82, i32 4, i32 %84)
store i64 %85, i64* %12
%86 = load i64, i64* %9
%87 = trunc i64 %86 to i8
%88 = load i64, i64* %12
%89 = trunc i64 %88 to i32
%90 = call i64 @crc32(i8 zeroext %87, i32 4, i32 %89)
store i64 %90, i64* %12
%91 = load i64, i64* %10
%92 = trunc i64 %91 to i8
%93 = load i64, i64* %12
%94 = trunc i64 %93 to i32
%95 = call i64 @crc32(i8 zeroext %92, i32 32, i32 %94)
store i64 %95, i64* %12
%96 = load i64, i64* %11
%97 = trunc i64 %96 to i8
%98 = load i64, i64* %12
%99 = trunc i64 %98 to i32
%100 = call i64 @crc32(i8 zeroext %97, i32 16, i32 %99)
store i64 %100, i64* %12
%101 = load i64, i64* %8
%102 = call i8* @reverse_bits(i64 %101, i32 4)
%103 = ptrtoint i8* %102 to i64
store i64 %103, i64* %8
%104 = load i64, i64* %9
%105 = call i8* @reverse_bits(i64 %104, i32 4)
%106 = ptrtoint i8* %105 to i64
store i64 %106, i64* %9
%107 = load i64, i64* %10
%108 = call i8* @reverse_bits(i64 %107, i32 32)
%109 = ptrtoint i8* %108 to i64
store i64 %109, i64* %10
%110 = load i64, i64* %11
%111 = call i8* @reverse_bits(i64 %110, i32 16)
%112 = ptrtoint i8* %111 to i64
store i64 %112, i64* %11
%113 = load i64, i64* %12
%114 = call i8* @reverse_bits(i64 %113, i32 32)
%115 = ptrtoint i8* %114 to i64
store i64 %115, i64* %12
store i32 16, i32* %13
%116 = load i32, i32* %13
%117 = call i8* @malloc(i32 %116)
store i8* %117, i8** %14
%118 = load i8*, i8** %14
%119 = icmp eq i8* null, %118
br i1 %119, label %120, label %122
120: ; preds = %79
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %4
br label %293
122: ; preds = %79
%123 = load i8*, i8** %14
%124 = load i32, i32* %13
%125 = call i32 @memset(i8* %123, i32 0, i32 %124)
%126 = load i8*, i8** %14
%127 = getelementptr inbounds i8, i8* %126, i64 0
store i8 0, i8* %127
%128 = load i64, i64* %8
%129 = shl i64 %128, 1
%130 = load i8*, i8** %14
%131 = getelementptr inbounds i8, i8* %130, i64 0
%132 = load i8, i8* %131
%133 = zext i8 %132 to i64
%134 = or i64 %133, %129
%135 = trunc i64 %134 to i8
store i8 %135, i8* %131
%136 = load i64, i64* %9
%137 = shl i64 %136, 5
%138 = load i8*, i8** %14
%139 = getelementptr inbounds i8, i8* %138, i64 0
%140 = load i8, i8* %139
%141 = zext i8 %140 to i64
%142 = or i64 %141, %137
%143 = trunc i64 %142 to i8
store i8 %143, i8* %139
%144 = load i64, i64* %9
%145 = lshr i64 %144, 3
%146 = trunc i64 %145 to i8
%147 = load i8*, i8** %14
%148 = getelementptr inbounds i8, i8* %147, i64 1
store i8 %146, i8* %148
%149 = load i64, i64* %10
%150 = shl i64 %149, 1
%151 = load i8*, i8** %14
%152 = getelementptr inbounds i8, i8* %151, i64 1
%153 = load i8, i8* %152
%154 = zext i8 %153 to i64
%155 = or i64 %154, %150
%156 = trunc i64 %155 to i8
store i8 %156, i8* %152
%157 = load i64, i64* %10
%158 = lshr i64 %157, 7
%159 = trunc i64 %158 to i8
%160 = load i8*, i8** %14
%161 = getelementptr inbounds i8, i8* %160, i64 2
store i8 %159, i8* %161
%162 = load i64, i64* %10
%163 = lshr i64 %162, 15
%164 = trunc i64 %163 to i8
%165 = load i8*, i8** %14
%166 = getelementptr inbounds i8, i8* %165, i64 3
store i8 %164, i8* %166
%167 = load i64, i64* %10
%168 = lshr i64 %167, 23
%169 = trunc i64 %168 to i8
%170 = load i8*, i8** %14
%171 = getelementptr inbounds i8, i8* %170, i64 4
store i8 %169, i8* %171
%172 = load i64, i64* %10
%173 = lshr i64 %172, 31
%174 = trunc i64 %173 to i8
%175 = load i8*, i8** %14
%176 = getelementptr inbounds i8, i8* %175, i64 5
store i8 %174, i8* %176
%177 = load i64, i64* %11
%178 = shl i64 %177, 1
%179 = load i8*, i8** %14
%180 = getelementptr inbounds i8, i8* %179, i64 5
%181 = load i8, i8* %180
%182 = zext i8 %181 to i64
%183 = or i64 %182, %178
%184 = trunc i64 %183 to i8
store i8 %184, i8* %180
%185 = load i64, i64* %11
%186 = lshr i64 %185, 7
%187 = trunc i64 %186 to i8
%188 = load i8*, i8** %14
%189 = getelementptr inbounds i8, i8* %188, i64 6
store i8 %187, i8* %189
%190 = load i64, i64* %11
%191 = lshr i64 %190, 15
%192 = trunc i64 %191 to i8
%193 = load i8*, i8** %14
%194 = getelementptr inbounds i8, i8* %193, i64 7
store i8 %192, i8* %194
%195 = load i64, i64* %12
%196 = shl i64 %195, 1
%197 = load i8*, i8** %14
%198 = getelementptr inbounds i8, i8* %197, i64 7
%199 = load i8, i8* %198
%200 = zext i8 %199 to i64
%201 = or i64 %200, %196
%202 = trunc i64 %201 to i8
store i8 %202, i8* %198
%203 = load i64, i64* %12
%204 = lshr i64 %203, 7
%205 = trunc i64 %204 to i8
%206 = load i8*, i8** %14
%207 = getelementptr inbounds i8, i8* %206, i64 8
store i8 %205, i8* %207
%208 = load i64, i64* %12
%209 = lshr i64 %208, 15
%210 = trunc i64 %209 to i8
%211 = load i8*, i8** %14
%212 = getelementptr inbounds i8, i8* %211, i64 9
store i8 %210, i8* %212
%213 = load i64, i64* %12
%214 = lshr i64 %213, 23
%215 = trunc i64 %214 to i8
%216 = load i8*, i8** %14
%217 = getelementptr inbounds i8, i8* %216, i64 10
store i8 %215, i8* %217
%218 = load i64, i64* %12
%219 = lshr i64 %218, 31
%220 = trunc i64 %219 to i8
%221 = load i8*, i8** %14
%222 = getelementptr inbounds i8, i8* %221, i64 11
store i8 %220, i8* %222
%223 = load i8*, i8** %14
%224 = load i32, i32* %13
%225 = call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %223, i32 %224)
%226 = load i8*, i8** %14
%227 = call double @or1ksim_jtag_shift_dr(i8* %226, i32 125)
store double %227, double* %15
%228 = load i8*, i8** %14
%229 = load i32, i32* %13
%230 = call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %228, i32 %229)
%231 = load i8*, i8** %14
%232 = getelementptr inbounds i8, i8* %231, i64 11
%233 = load i8, i8* %232
%234 = zext i8 %233 to i32
%235 = ashr i32 %234, 1
%236 = and i32 %235, 15
%237 = trunc i32 %236 to i8
store i8 %237, i8* %16
%238 = load i8*, i8** %14
%239 = getelementptr inbounds i8, i8* %238, i64 11
%240 = load i8, i8* %239
%241 = zext i8 %240 to i64
%242 = lshr i64 %241, 5
%243 = load i8*, i8** %14
%244 = getelementptr inbounds i8, i8* %243, i64 12
%245 = load i8, i8* %244
%246 = zext i8 %245 to i64
%247 = shl i64 %246, 3
%248 = or i64 %242, %247
%249 = load i8*, i8** %14
%250 = getelementptr inbounds i8, i8* %249, i64 13
%251 = load i8, i8* %250
%252 = zext i8 %251 to i64
%253 = shl i64 %252, 11
%254 = or i64 %248, %253
%255 = load i8*, i8** %14
%256 = getelementptr inbounds i8, i8* %255, i64 14
%257 = load i8, i8* %256
%258 = zext i8 %257 to i64
%259 = shl i64 %258, 19
%260 = or i64 %254, %259
%261 = load i8*, i8** %14
%262 = getelementptr inbounds i8, i8* %261, i64 15
%263 = load i8, i8* %262
%264 = zext i8 %263 to i64
%265 = shl i64 %264, 27
%266 = or i64 %260, %265
store i64 %266, i64* %17
%267 = load i8, i8* %16
%268 = zext i8 %267 to i64
%269 = call i8* @reverse_bits(i64 %268, i32 4)
%270 = ptrtoint i8* %269 to i8
store i8 %270, i8* %16
%271 = load i64, i64* %17
%272 = call i8* @reverse_bits(i64 %271, i32 32)
%273 = ptrtoint i8* %272 to i64
store i64 %273, i64* %17
%274 = load i8, i8* %16
%275 = call i64 @crc32(i8 zeroext %274, i32 4, i32 -1)
store i64 %275, i64* %18
%276 = load i8, i8* %16
%277 = zext i8 %276 to i32
%278 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %277)
%279 = load i64, i64* %17
%280 = load i64, i64* %18
%281 = icmp ne i64 %279, %280
br i1 %281, label %282, label %288
282: ; preds = %122
%283 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%284 = load i64, i64* %17
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i64 %284)
%286 = load i64, i64* %18
%287 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i64 %286)
br label %288
288: ; preds = %282, %122
%289 = load double, double* %15
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), double %289)
%291 = load i8*, i8** %14
%292 = call i32 @free(i8* %291)
store i32 1, i32* %4
br label %293
293: ; preds = %288, %120, %74, %66, %59, %53, %24
%294 = load i32, i32* %4
ret i32 %294
}

LLVM IR (-O2):
@.str.2 = [50 x i8] c"ERROR: WRITE_COMMAND access type 0x%lx too large\0A\00"
@.str.3 = [46 x i8] c"ERROR: WRITE_COMMAND address 0x%lx too large\0A\00"
@.str.4 = [45 x i8] c"ERROR: WRITE_COMMAND length 0x%lx too small\0A\00"
@.str.5 = [45 x i8] c"ERROR: WRITE_COMMAND length 0x%lx too large\0A\00"
@.str.7 = [14 x i8] c" shifting in\00"
@.str.8 = [14 x i8] c" shifted out\00"
@.str.9 = [24 x i8] c" status: 0x%01x\0A\00"
@.str.11 = [27 x i8] c" CRC out: 0x%08lx\0A\00"
@.str.12 = [27 x i8] c" CRC computed: 0x%08lx\0A\00"
@.str.13 = [24 x i8] c" time taken: %.12fs\0A\00"
@str = [26 x i8] c"Processing WRITE_COMMAND.\00"
@str.14 = [15 x i8] c" CRC mismatch\00"
@str.15 = [49 x i8] c"ERROR: malloc for WRITE_COMMAND register failed.\00"
@str.16 = [68 x i8] c"WRITE_COMMAND usage: WRITE_COMMAND <access_type> <address> <length>\00"
define i32 @process_write_command(i32 %0, i32 %1, i8** nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = add nsw i32 %0, 3
%6 = icmp sgt i32 %5, %1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.16, i64 0, i64 0))
br label %162
9: ; preds = %3
%10 = sext i32 %0 to i64
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @strtoul(i8* nocapture %12, i32* null, i32 16)
%14 = sext i32 %13 to i64
%15 = add nsw i32 %0, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %2, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @strtoul(i8* nocapture %18, i32* null, i32 16)
%20 = sext i32 %19 to i64
%21 = add nsw i32 %0, 2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %2, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 @strtoul(i8* nocapture %24, i32* null, i32 16)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = icmp ugt i32 %13, 15
br i1 %28, label %29, label %31
29: ; preds = %9
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i64 %14)
br label %162
31: ; preds = %9
%32 = icmp slt i32 %19, 0
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i64 %20)
br label %162
35: ; preds = %31
%36 = add nsw i64 %27, 1
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i64 0)
br label %162
40: ; preds = %35
%41 = icmp ugt i64 %36, 65536
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i64 %36)
br label %162
44: ; preds = %40
%45 = tail call i64 @crc32(i8 zeroext 0, i32 1, i32 -1)
%46 = trunc i64 %45 to i32
%47 = tail call i64 @crc32(i8 zeroext 2, i32 4, i32 %46)
%48 = trunc i32 %13 to i8
%49 = trunc i64 %47 to i32
%50 = tail call i64 @crc32(i8 zeroext %48, i32 4, i32 %49)
%51 = trunc i32 %19 to i8
%52 = trunc i64 %50 to i32
%53 = tail call i64 @crc32(i8 zeroext %51, i32 32, i32 %52)
%54 = trunc i32 %26 to i8
%55 = trunc i64 %53 to i32
%56 = tail call i64 @crc32(i8 zeroext %54, i32 16, i32 %55)
%57 = tail call i8* @reverse_bits(i64 2, i32 4)
%58 = tail call i8* @reverse_bits(i64 %14, i32 4)
%59 = ptrtoint i8* %58 to i64
%60 = tail call i8* @reverse_bits(i64 %20, i32 32)
%61 = ptrtoint i8* %60 to i64
%62 = tail call i8* @reverse_bits(i64 %27, i32 16)
%63 = ptrtoint i8* %62 to i64
%64 = tail call i8* @reverse_bits(i64 %56, i32 32)
%65 = ptrtoint i8* %64 to i64
%66 = tail call dereferenceable_or_null(16) i8* @malloc(i32 16)
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %70
68: ; preds = %44
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0))
br label %162
70: ; preds = %44
%71 = ptrtoint i8* %57 to i64
%72 = tail call i32 @memset(i8* %66, i32 0, i32 16)
%73 = shl i64 %71, 1
%74 = shl i64 %59, 5
%75 = or i64 %74, %73
%76 = trunc i64 %75 to i8
store i8 %76, i8* %66
%77 = lshr i64 %59, 3
%78 = getelementptr inbounds i8, i8* %66, i64 1
%79 = shl i64 %61, 1
%80 = or i64 %79, %77
%81 = trunc i64 %80 to i8
store i8 %81, i8* %78
%82 = lshr i64 %61, 7
%83 = trunc i64 %82 to i8
%84 = getelementptr inbounds i8, i8* %66, i64 2
store i8 %83, i8* %84
%85 = lshr i64 %61, 15
%86 = trunc i64 %85 to i8
%87 = getelementptr inbounds i8, i8* %66, i64 3
store i8 %86, i8* %87
%88 = lshr i64 %61, 23
%89 = trunc i64 %88 to i8
%90 = getelementptr inbounds i8, i8* %66, i64 4
store i8 %89, i8* %90
%91 = lshr i64 %61, 31
%92 = getelementptr inbounds i8, i8* %66, i64 5
%93 = shl i64 %63, 1
%94 = or i64 %93, %91
%95 = trunc i64 %94 to i8
store i8 %95, i8* %92
%96 = lshr i64 %63, 7
%97 = trunc i64 %96 to i8
%98 = getelementptr inbounds i8, i8* %66, i64 6
store i8 %97, i8* %98
%99 = lshr i64 %63, 15
%100 = getelementptr inbounds i8, i8* %66, i64 7
%101 = shl i64 %65, 1
%102 = or i64 %101, %99
%103 = trunc i64 %102 to i8
store i8 %103, i8* %100
%104 = lshr i64 %65, 7
%105 = trunc i64 %104 to i8
%106 = getelementptr inbounds i8, i8* %66, i64 8
store i8 %105, i8* %106
%107 = lshr i64 %65, 15
%108 = trunc i64 %107 to i8
%109 = getelementptr inbounds i8, i8* %66, i64 9
store i8 %108, i8* %109
%110 = lshr i64 %65, 23
%111 = trunc i64 %110 to i8
%112 = getelementptr inbounds i8, i8* %66, i64 10
store i8 %111, i8* %112
%113 = lshr i64 %65, 31
%114 = trunc i64 %113 to i8
%115 = getelementptr inbounds i8, i8* %66, i64 11
store i8 %114, i8* %115
%116 = tail call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %66, i32 16)
%117 = tail call double @or1ksim_jtag_shift_dr(i8* %66, i32 125)
%118 = tail call i32 @dump_jreg(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %66, i32 16)
%119 = load i8, i8* %115
%120 = lshr i8 %119, 1
%121 = and i8 %120, 15
%122 = lshr i8 %119, 5
%123 = zext i8 %122 to i64
%124 = getelementptr inbounds i8, i8* %66, i64 12
%125 = load i8, i8* %124
%126 = zext i8 %125 to i64
%127 = shl nuw nsw i64 %126, 3
%128 = or i64 %127, %123
%129 = getelementptr inbounds i8, i8* %66, i64 13
%130 = load i8, i8* %129
%131 = zext i8 %130 to i64
%132 = shl nuw nsw i64 %131, 11
%133 = or i64 %128, %132
%134 = getelementptr inbounds i8, i8* %66, i64 14
%135 = load i8, i8* %134
%136 = zext i8 %135 to i64
%137 = shl nuw nsw i64 %136, 19
%138 = or i64 %133, %137
%139 = getelementptr inbounds i8, i8* %66, i64 15
%140 = load i8, i8* %139
%141 = zext i8 %140 to i64
%142 = shl nuw nsw i64 %141, 27
%143 = or i64 %138, %142
%144 = zext i8 %121 to i64
%145 = tail call i8* @reverse_bits(i64 %144, i32 4)
%146 = ptrtoint i8* %145 to i64
%147 = trunc i64 %146 to i8
%148 = tail call i8* @reverse_bits(i64 %143, i32 32)
%149 = ptrtoint i8* %148 to i64
%150 = tail call i64 @crc32(i8 zeroext %147, i32 4, i32 -1)
%151 = trunc i64 %146 to i32
%152 = and i32 %151, 255
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %152)
%154 = icmp eq i64 %150, %149
br i1 %154, label %159, label %155
155: ; preds = %70
%156 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%157 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i64 %149)
%158 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i64 %150)
br label %159
159: ; preds = %155, %70
%160 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), double %117)
%161 = tail call i32 @free(i8* %66)
br label %162
162: ; preds = %29, %33, %38, %42, %159, %68, %7
%163 = phi i32 [ 0, %7 ], [ 0, %29 ], [ 0, %33 ], [ 0, %38 ], [ 0, %42 ], [ 0, %68 ], [ 1, %159 ]
ret i32 %163
}