#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*/ JTAG_DELAY();
char JTAG_GET_TDO();
int /*<<< orphan*/ JTAG_SET(int);
int strlen(char *);
void JTAG_ShiftDRState(char *wrDR, char *rdDR) {
  int size, i, tdi;
  JTAG_SET((1 << 3) | (1 << 1) | 0);
  JTAG_DELAY();
  JTAG_SET((1 << 3) | (1 << 1) | (1 << 2));
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | 0);
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | (1 << 2));
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | 0);
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | (1 << 2));
  JTAG_DELAY();
  size = strlen(wrDR);
  for (i = 0; i < (size - 1); i++) {
    tdi = (wrDR[i] == '1') ? (1 << 3) : 0;
    JTAG_SET(tdi | 0 | 0);
    JTAG_DELAY();
    JTAG_SET(tdi | 0 | (1 << 2));
    JTAG_DELAY();
    rdDR[i] = JTAG_GET_TDO();
  }
  tdi = (wrDR[i] == '1') ? (1 << 3) : 0;
  JTAG_SET(tdi | (1 << 1) | 0);
  JTAG_DELAY();
  JTAG_SET(tdi | (1 << 1) | (1 << 2));
  JTAG_DELAY();
  rdDR[i] = JTAG_GET_TDO();
  JTAG_SET((1 << 3) | (1 << 1) | 0);
  JTAG_DELAY();
  JTAG_SET((1 << 3) | (1 << 1) | (1 << 2));
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | 0);
  JTAG_DELAY();
  JTAG_SET((1 << 3) | 0 | (1 << 2));
  JTAG_DELAY();
}


x86 assembly (clang, -O0):
<JTAG_ShiftDRState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xa,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1242 <JTAG_ShiftDRState+0x102>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x31,%edx
cmove  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
or     $0x0,%edi
or     $0x0,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x1c(%rbp),%edi
or     $0x0,%edi
or     $0x4,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x0,%al
call   1050 <JTAG_GET_TDO@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c9 <JTAG_ShiftDRState+0x89>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x31,%edx
cmove  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
or     $0x2,%edi
or     $0x0,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x1c(%rbp),%edi
or     $0x2,%edi
or     $0x4,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x0,%al
call   1050 <JTAG_GET_TDO@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0xa,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JTAG_ShiftDRState>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0xa,%edi
call   1060 <JTAG_SET@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1218 <JTAG_ShiftDRState+0xd8>
add    $0xffffffff,%eax
mov    %eax,%r15d
xor    %ebx,%ebx
nopl   (%rax)
xor    %r13d,%r13d
cmpb   $0x31,(%r12,%rbx,1)
sete   %r13b
lea    0x0(,%r13,8),%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
lea    0x4(,%r13,8),%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
xor    %eax,%eax
call   1050 <JTAG_GET_TDO@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <JTAG_ShiftDRState+0x90>
xor    %ebx,%ebx
cmpb   $0x31,(%r12,%r15,1)
sete   %bl
lea    0x2(,%rbx,8),%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
lea    0x6(,%rbx,8),%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
xor    %eax,%eax
call   1050 <JTAG_GET_TDO@plt>
mov    %al,(%r14,%r15,1)
mov    $0xa,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1060 <JTAG_SET@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <JTAG_DELAY@plt>

LLVM IR (-O0):
define void @JTAG_ShiftDRState(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 @JTAG_SET(i32 10)
%9 = call i32 (...) @JTAG_DELAY()
%10 = call i32 @JTAG_SET(i32 14)
%11 = call i32 (...) @JTAG_DELAY()
%12 = call i32 @JTAG_SET(i32 8)
%13 = call i32 (...) @JTAG_DELAY()
%14 = call i32 @JTAG_SET(i32 12)
%15 = call i32 (...) @JTAG_DELAY()
%16 = call i32 @JTAG_SET(i32 8)
%17 = call i32 (...) @JTAG_DELAY()
%18 = call i32 @JTAG_SET(i32 12)
%19 = call i32 (...) @JTAG_DELAY()
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %5
store i32 0, i32* %6
br label %22
22: ; preds = %52, %2
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %55
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 49
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 8, i32 0
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = or i32 %37, 0
%39 = or i32 %38, 0
%40 = call i32 @JTAG_SET(i32 %39)
%41 = call i32 (...) @JTAG_DELAY()
%42 = load i32, i32* %7
%43 = or i32 %42, 0
%44 = or i32 %43, 4
%45 = call i32 @JTAG_SET(i32 %44)
%46 = call i32 (...) @JTAG_DELAY()
%47 = call signext i8 (...) @JTAG_GET_TDO()
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 %47, i8* %51
br label %52
52: ; preds = %27
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %22
55: ; preds = %22
%56 = load i8*, i8** %3
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 49
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 8, i32 0
store i32 %64, i32* %7
%65 = load i32, i32* %7
%66 = or i32 %65, 2
%67 = or i32 %66, 0
%68 = call i32 @JTAG_SET(i32 %67)
%69 = call i32 (...) @JTAG_DELAY()
%70 = load i32, i32* %7
%71 = or i32 %70, 2
%72 = or i32 %71, 4
%73 = call i32 @JTAG_SET(i32 %72)
%74 = call i32 (...) @JTAG_DELAY()
%75 = call signext i8 (...) @JTAG_GET_TDO()
%76 = load i8*, i8** %4
%77 = load i32, i32* %6
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
store i8 %75, i8* %79
%80 = call i32 @JTAG_SET(i32 10)
%81 = call i32 (...) @JTAG_DELAY()
%82 = call i32 @JTAG_SET(i32 14)
%83 = call i32 (...) @JTAG_DELAY()
%84 = call i32 @JTAG_SET(i32 8)
%85 = call i32 (...) @JTAG_DELAY()
%86 = call i32 @JTAG_SET(i32 12)
%87 = call i32 (...) @JTAG_DELAY()
ret void
}

LLVM IR (-O2):
define void @JTAG_ShiftDRState(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @JTAG_SET(i32 10)
%4 = tail call i32 (...) @JTAG_DELAY()
%5 = tail call i32 @JTAG_SET(i32 14)
%6 = tail call i32 (...) @JTAG_DELAY()
%7 = tail call i32 @JTAG_SET(i32 8)
%8 = tail call i32 (...) @JTAG_DELAY()
%9 = tail call i32 @JTAG_SET(i32 12)
%10 = tail call i32 (...) @JTAG_DELAY()
%11 = tail call i32 @JTAG_SET(i32 8)
%12 = tail call i32 (...) @JTAG_DELAY()
%13 = tail call i32 @JTAG_SET(i32 12)
%14 = tail call i32 (...) @JTAG_DELAY()
%15 = tail call i32 @strlen(i8* %0)
%16 = add i32 %15, -1
%17 = icmp sgt i32 %15, 1
br i1 %17, label %18, label %37
18: ; preds = %2
%19 = zext i32 %16 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %33, %20 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 49
%25 = select i1 %24, i32 8, i32 0
%26 = tail call i32 @JTAG_SET(i32 %25)
%27 = tail call i32 (...) @JTAG_DELAY()
%28 = or i32 %25, 4
%29 = tail call i32 @JTAG_SET(i32 %28)
%30 = tail call i32 (...) @JTAG_DELAY()
%31 = tail call signext i8 (...) @JTAG_GET_TDO()
%32 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 %31, i8* %32
%33 = add nuw nsw i64 %21, 1
%34 = icmp eq i64 %33, %19
br i1 %34, label %35, label %20
35: ; preds = %20
%36 = zext i32 %16 to i64
br label %37
37: ; preds = %2, %35
%38 = phi i64 [ %36, %35 ], [ 0, %2 ]
%39 = getelementptr inbounds i8, i8* %0, i64 %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 49
%42 = select i1 %41, i32 10, i32 2
%43 = tail call i32 @JTAG_SET(i32 %42)
%44 = tail call i32 (...) @JTAG_DELAY()
%45 = or i32 %42, 4
%46 = tail call i32 @JTAG_SET(i32 %45)
%47 = tail call i32 (...) @JTAG_DELAY()
%48 = tail call signext i8 (...) @JTAG_GET_TDO()
%49 = getelementptr inbounds i8, i8* %1, i64 %38
store i8 %48, i8* %49
%50 = tail call i32 @JTAG_SET(i32 10)
%51 = tail call i32 (...) @JTAG_DELAY()
%52 = tail call i32 @JTAG_SET(i32 14)
%53 = tail call i32 (...) @JTAG_DELAY()
%54 = tail call i32 @JTAG_SET(i32 8)
%55 = tail call i32 (...) @JTAG_DELAY()
%56 = tail call i32 @JTAG_SET(i32 12)
%57 = tail call i32 (...) @JTAG_DELAY()
ret void
}