#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*/ addch(char);
void _echo_parseString(char *arg, int eflag, int arglen) {
  int escapeChar = 0;
  for (int i = 0; i < arglen; i++) {
    if (escapeChar) {
      switch (arg[i]) {
      case '\\':
        addch('\\');
        break;
      case 'n':
        addch('\n');
        break;
      case 't':
        addch('\t');
        break;
      case 'v':
        addch('\v');
        break;
      default:
        addch('\\');
        addch(arg[i]);
        break;
      }
      escapeChar = 0;
    } else {
      if (arg[i] == '\\' && eflag)
        escapeChar = 1;
      else
        addch(arg[i]);
    }
  }
}


x86 assembly (clang, -O0):
<_echo_parseString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    122f <_echo_parseString+0x11f>
cmpl   $0x0,-0x14(%rbp)
je     11db <_echo_parseString+0xcb>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffa4,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1a,%eax
ja     11b4 <_echo_parseString+0xa4>
mov    -0x20(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x5c,%edi
call   1030 <addch@plt>
jmp    11cf <_echo_parseString+0xbf>
mov    $0xa,%edi
call   1030 <addch@plt>
jmp    11cf <_echo_parseString+0xbf>
mov    $0x9,%edi
call   1030 <addch@plt>
jmp    11cf <_echo_parseString+0xbf>
mov    $0xb,%edi
call   1030 <addch@plt>
jmp    11cf <_echo_parseString+0xbf>
mov    $0x5c,%edi
call   1030 <addch@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <addch@plt>
movl   $0x0,-0x14(%rbp)
jmp    121c <_echo_parseString+0x10c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1206 <_echo_parseString+0xf6>
cmpl   $0x0,-0xc(%rbp)
je     1206 <_echo_parseString+0xf6>
movl   $0x1,-0x14(%rbp)
jmp    1217 <_echo_parseString+0x107>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <addch@plt>
jmp    121c <_echo_parseString+0x10c>
jmp    1221 <_echo_parseString+0x111>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <_echo_parseString+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_echo_parseString>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    11a4 <_echo_parseString+0x94>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%r15d
xor    %ebp,%ebp
lea    0xece(%rip),%r12
xor    %ecx,%ecx
jmp    1153 <_echo_parseString+0x43>
mov    $0xb,%al
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <addch@plt>
xor    %ecx,%ecx
add    $0x1,%rbp
cmp    %rbp,%r15
je     11a4 <_echo_parseString+0x94>
movzbl (%rbx,%rbp,1),%eax
test   %ecx,%ecx
je     1180 <_echo_parseString+0x70>
movsbl %al,%ecx
add    $0xffffffa4,%ecx
cmp    $0x1a,%ecx
ja     1190 <_echo_parseString+0x80>
mov    $0x5c,%al
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    $0xa,%al
jmp    1140 <_echo_parseString+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
test   %r14d,%r14d
je     1140 <_echo_parseString+0x30>
mov    $0x1,%ecx
cmp    $0x5c,%al
je     114a <_echo_parseString+0x3a>
jmp    1140 <_echo_parseString+0x30>
mov    $0x5c,%edi
call   1030 <addch@plt>
movzbl (%rbx,%rbp,1),%eax
jmp    1140 <_echo_parseString+0x30>
mov    $0x9,%al
jmp    1140 <_echo_parseString+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_echo_parseString(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %61, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %64
13: ; preds = %9
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %31 [
i32 92, label %23
i32 110, label %25
i32 116, label %27
i32 118, label %29
]
23: ; preds = %16
%24 = call i32 @addch(i8 signext 92)
br label %39
25: ; preds = %16
%26 = call i32 @addch(i8 signext 10)
br label %39
27: ; preds = %16
%28 = call i32 @addch(i8 signext 9)
br label %39
29: ; preds = %16
%30 = call i32 @addch(i8 signext 11)
br label %39
31: ; preds = %16
%32 = call i32 @addch(i8 signext 92)
%33 = load i8*, i8** %4
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @addch(i8 signext %37)
br label %39
39: ; preds = %31, %29, %27, %25, %23
store i32 0, i32* %7
br label %60
40: ; preds = %13
%41 = load i8*, i8** %4
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 92
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load i32, i32* %5
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 1, i32* %7
br label %59
52: ; preds = %48, %40
%53 = load i8*, i8** %4
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = call i32 @addch(i8 signext %57)
br label %59
59: ; preds = %52, %51
br label %60
60: ; preds = %59, %39
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %9
64: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @_echo_parseString(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = icmp ne i32 %1, 0
%7 = zext i32 %2 to i64
br label %9
8: ; preds = %29, %3
ret void
9: ; preds = %5, %29
%10 = phi i64 [ 0, %5 ], [ %31, %29 ]
%11 = phi i32 [ 0, %5 ], [ %30, %29 ]
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = load i8, i8* %13
br i1 %12, label %23, label %15
15: ; preds = %9
%16 = sext i8 %14 to i32
switch i32 %16, label %20 [
i32 92, label %26
i32 110, label %17
i32 116, label %18
i32 118, label %19
]
17: ; preds = %15
br label %26
18: ; preds = %15
br label %26
19: ; preds = %15
br label %26
20: ; preds = %15
%21 = tail call i32 @addch(i8 signext 92)
%22 = load i8, i8* %13
br label %26
23: ; preds = %9
%24 = icmp eq i8 %14, 92
%25 = and i1 %6, %24
br i1 %25, label %29, label %26
26: ; preds = %23, %15, %20, %19, %18, %17
%27 = phi i8 [ 10, %17 ], [ 9, %18 ], [ 11, %19 ], [ %22, %20 ], [ 92, %15 ], [ %14, %23 ]
%28 = tail call i32 @addch(i8 signext %27)
br label %29
29: ; preds = %26, %23
%30 = phi i32 [ 1, %23 ], [ 0, %26 ]
%31 = add nuw nsw i64 %10, 1
%32 = icmp eq i64 %31, %7
br i1 %32, label %8, label %9
}