#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 strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *uncomment(char *sDest, const char *sSource) {
  char *cPos;
  int bInTxt, bSpecial, bFound, iPos;
  bInTxt = 0;
  bFound = 0;
  bSpecial = 0;
  iPos = 0;
  while (!bFound && (iPos < strlen(sSource))) {
    switch (sSource[iPos]) {
    case '\\':
      bSpecial = !bSpecial;
      iPos++;
      break;
    case '"':
      if (!bSpecial)
        bInTxt = !bInTxt;
      bSpecial = 0;
      iPos++;
      break;
    case ';':
      if (!bInTxt)
        bFound = 1;
      else
        iPos++;
      break;
    default:
      bSpecial = 0;
      iPos++;
    }
  }
  strncpy(sDest, sSource, iPos);
  sDest[iPos] = 0;
  return sDest;
}


x86 assembly (clang, -O0):
<uncomment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x29(%rbp)
jne    1177 <uncomment+0x57>
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1187 <uncomment+0x67>
jmp    124e <uncomment+0x12e>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
sub    $0x22,%eax
je     11e5 <uncomment+0xc5>
jmp    11a4 <uncomment+0x84>
mov    -0x34(%rbp),%eax
sub    $0x3b,%eax
je     1215 <uncomment+0xf5>
jmp    11b5 <uncomment+0x95>
mov    -0x34(%rbp),%eax
sub    $0x5c,%eax
jne    1239 <uncomment+0x119>
jmp    11c6 <uncomment+0xa6>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1249 <uncomment+0x129>
cmpl   $0x0,-0x20(%rbp)
jne    1200 <uncomment+0xe0>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1249 <uncomment+0x129>
cmpl   $0x0,-0x1c(%rbp)
jne    122b <uncomment+0x10b>
movl   $0x1,-0x24(%rbp)
jmp    1234 <uncomment+0x114>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1249 <uncomment+0x129>
movl   $0x0,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <uncomment+0x2c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uncomment>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    11a9 <uncomment+0x89>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1170 <uncomment+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
test   %r12d,%r12d
cmove  %eax,%ebp
xor    %r12d,%r12d
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0x1,%rbx
cmp    %eax,%ebx
jge    11a9 <uncomment+0x89>
movsbl (%r15,%rbx,1),%eax
cmp    $0x22,%eax
je     1150 <uncomment+0x30>
cmp    $0x3b,%eax
je     11a0 <uncomment+0x80>
cmp    $0x5c,%eax
jne    115d <uncomment+0x3d>
xor    %eax,%eax
test   %r12d,%r12d
sete   %al
mov    %eax,%r12d
jmp    1160 <uncomment+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
mov    $0x1,%ebp
jne    1160 <uncomment+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @uncomment(i8* returned %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %29
5: ; preds = %2, %23
%6 = phi i32 [ %24, %23 ], [ 0, %2 ]
%7 = phi i32 [ %25, %23 ], [ 0, %2 ]
%8 = phi i32 [ %26, %23 ], [ 0, %2 ]
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %23 [
i32 92, label %13
i32 34, label %16
i32 59, label %21
]
13: ; preds = %5
%14 = icmp eq i32 %7, 0
%15 = zext i1 %14 to i32
br label %23
16: ; preds = %5
%17 = icmp eq i32 %7, 0
%18 = icmp eq i32 %6, 0
%19 = zext i1 %18 to i32
%20 = select i1 %17, i32 %19, i32 %6
br label %23
21: ; preds = %5
%22 = icmp eq i32 %6, 0
br i1 %22, label %29, label %23
23: ; preds = %5, %21, %16, %13
%24 = phi i32 [ %20, %16 ], [ %6, %13 ], [ 1, %21 ], [ %6, %5 ]
%25 = phi i32 [ 0, %16 ], [ %15, %13 ], [ %7, %21 ], [ 0, %5 ]
%26 = add nuw nsw i32 %8, 1
%27 = tail call i32 @strlen(i8* %1)
%28 = icmp slt i32 %26, %27
br i1 %28, label %5, label %29
29: ; preds = %23, %21, %2
%30 = phi i32 [ 0, %2 ], [ %26, %23 ], [ %8, %21 ]
%31 = tail call i32 @strncpy(i8* %0, i8* %1, i32 %30)
%32 = zext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
ret i8* %0
}