#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();
int /*<<< orphan*/ JTAG_SET(int);
int strlen(char *);
void JTAG_ShiftIRState(char *wrIR) {
  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) | (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(wrIR);
  for (i = 0; i < (size - 1); i++) {
    tdi = (wrIR[i] == '1') ? (1 << 3) : 0;
    JTAG_SET(tdi | 0 | 0);
    JTAG_DELAY();
    JTAG_SET(tdi | 0 | (1 << 2));
    JTAG_DELAY();
  }
  tdi = (wrIR[i] == '1') ? (1 << 3) : 0;
  JTAG_SET(tdi | (1 << 1) | 0);
  JTAG_DELAY();
  JTAG_SET(tdi | (1 << 1) | (1 << 2));
  JTAG_DELAY();
  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_ShiftIRState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    123c <JTAG_ShiftIRState+0x10c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x31,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
or     $0x0,%edi
or     $0x0,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x14(%rbp),%edi
or     $0x0,%edi
or     $0x4,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d7 <JTAG_ShiftIRState+0xa7>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x31,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
or     $0x2,%edi
or     $0x0,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    -0x14(%rbp),%edi
or     $0x2,%edi
or     $0x4,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
mov    $0x0,%al
call   1040 <JTAG_DELAY@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JTAG_ShiftIRState>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     121d <JTAG_ShiftIRState+0xed>
add    $0xffffffff,%eax
mov    %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %r12d,%r12d
cmpb   $0x31,(%r14,%rbx,1)
sete   %r12b
lea    0x0(,%r12,8),%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
lea    0x4(,%r12,8),%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11e0 <JTAG_ShiftIRState+0xb0>
xor    %ebx,%ebx
cmpb   $0x31,(%r14,%r15,1)
sete   %bl
lea    0x2(,%rbx,8),%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
lea    0x6(,%rbx,8),%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xa,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xe,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0x8,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
call   1040 <JTAG_DELAY@plt>
mov    $0xc,%edi
call   1050 <JTAG_SET@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <JTAG_DELAY@plt>

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

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