#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
void uncommentLine() {
  int curchar, idx, matchChar;
  idx = -1;
  char missingCloses[1000];
  bool insideSingleQuote, insideDoubleQuote;
  insideSingleQuote = insideDoubleQuote = false;
  while ((curchar = getchar()) != EOF) {
    if (insideSingleQuote) {
      if (curchar == '\x27')
        insideSingleQuote = false;
      continue;
    }
    if (insideDoubleQuote) {
      if (curchar == '"')
        insideDoubleQuote = false;
      continue;
    }
    switch (curchar) {
    case '"':
      insideDoubleQuote = true;
      continue;
    case '\x27':
      insideSingleQuote = true;
      continue;
    case '[':
    case '(':
    case '{':
      missingCloses[++idx] = curchar;
      continue;
    default:
      break;
    }
    matchChar = ' ';
    switch (curchar) {
    case ']':
      matchChar = '[';
      break;
    case ')':
      matchChar = '(';
      break;
    case '}':
      matchChar = '{';
      break;
    default:
      continue;
    }
    if (missingCloses[idx--] != matchChar) {
      printf("Unmatched '%c' at character %i\n", matchChar, idx);
      return;
    }
  }
  if (idx > -1) {
    missingCloses[++idx] = '\0';
    printf("List of unmatched entries: %s\n", missingCloses);
  }
  if (insideSingleQuote)
    printf("Could not locate end of single quote\n");
  if (insideDoubleQuote)
    printf("Could not locate end of double quote\n");
}


x86 assembly (clang, -O0):
<uncommentLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0x408(%rbp)
movl   $0x0,-0x404(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     12fc <uncommentLine+0x1dc>
cmpl   $0x0,-0x404(%rbp)
je     1185 <uncommentLine+0x65>
cmpl   $0x27,-0x4(%rbp)
jne    1180 <uncommentLine+0x60>
movl   $0x0,-0x404(%rbp)
jmp    1146 <uncommentLine+0x26>
cmpl   $0x0,-0x408(%rbp)
je     11ab <uncommentLine+0x8b>
cmpl   $0x22,-0x4(%rbp)
jne    11a6 <uncommentLine+0x86>
movl   $0x0,-0x408(%rbp)
jmp    1146 <uncommentLine+0x26>
mov    -0x4(%rbp),%eax
mov    %eax,-0x40c(%rbp)
sub    $0x22,%eax
je     1212 <uncommentLine+0xf2>
jmp    11c2 <uncommentLine+0xa2>
mov    -0x40c(%rbp),%eax
sub    $0x27,%eax
je     1221 <uncommentLine+0x101>
jmp    11d6 <uncommentLine+0xb6>
mov    -0x40c(%rbp),%eax
sub    $0x28,%eax
je     1230 <uncommentLine+0x110>
jmp    11ea <uncommentLine+0xca>
mov    -0x40c(%rbp),%eax
sub    $0x5b,%eax
je     1230 <uncommentLine+0x110>
jmp    11fe <uncommentLine+0xde>
mov    -0x40c(%rbp),%eax
sub    $0x7b,%eax
je     1230 <uncommentLine+0x110>
jmp    124c <uncommentLine+0x12c>
movl   $0x1,-0x408(%rbp)
jmp    1146 <uncommentLine+0x26>
movl   $0x1,-0x404(%rbp)
jmp    1146 <uncommentLine+0x26>
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
jmp    1146 <uncommentLine+0x26>
jmp    1251 <uncommentLine+0x131>
movl   $0x20,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x410(%rbp)
sub    $0x29,%eax
je     12a3 <uncommentLine+0x183>
jmp    126f <uncommentLine+0x14f>
mov    -0x410(%rbp),%eax
sub    $0x5d,%eax
je     1297 <uncommentLine+0x177>
jmp    1283 <uncommentLine+0x163>
mov    -0x410(%rbp),%eax
sub    $0x7d,%eax
je     12af <uncommentLine+0x18f>
jmp    12bb <uncommentLine+0x19b>
movl   $0x5b,-0xc(%rbp)
jmp    12c0 <uncommentLine+0x1a0>
movl   $0x28,-0xc(%rbp)
jmp    12c0 <uncommentLine+0x1a0>
movl   $0x7b,-0xc(%rbp)
jmp    12c0 <uncommentLine+0x1a0>
jmp    1146 <uncommentLine+0x26>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cltq
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    -0xc(%rbp),%eax
je     12f7 <uncommentLine+0x1d7>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1364 <uncommentLine+0x244>
jmp    1146 <uncommentLine+0x26>
cmpl   $0xffffffff,-0x8(%rbp)
jle    132e <uncommentLine+0x20e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cltq
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rsi
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x404(%rbp)
je     1349 <uncommentLine+0x229>
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x408(%rbp)
je     1364 <uncommentLine+0x244>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uncommentLine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9b(%rip),%rbx
cmp    (%rbx),%eax
je     125a <uncommentLine+0x12a>
mov    $0xffffffff,%r14d
lea    0xe9e(%rip),%r15
xor    %r12d,%r12d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
test   %ebp,%ebp
je     118d <uncommentLine+0x5d>
xor    %ebp,%ebp
cmp    $0x27,%eax
setne  %bpl
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%eax
jne    1170 <uncommentLine+0x40>
jmp    121b <uncommentLine+0xeb>
test   %r12d,%r12d
je     11a0 <uncommentLine+0x70>
xor    %r12d,%r12d
cmp    $0x22,%eax
setne  %r12b
xor    %ebp,%ebp
jmp    117d <uncommentLine+0x4d>
lea    -0x22(%rax),%ecx
cmp    $0x3b,%ecx
ja     11c3 <uncommentLine+0x93>
mov    $0x1,%r12d
xor    %ebp,%ebp
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
xor    %r12d,%r12d
mov    $0x1,%ebp
jmp    117d <uncommentLine+0x4d>
cmp    $0x7b,%eax
je     11d4 <uncommentLine+0xa4>
cmp    $0x7d,%eax
je     11f0 <uncommentLine+0xc0>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    117d <uncommentLine+0x4d>
movslq %r14d,%r14
mov    %al,0x1(%rsp,%r14,1)
add    $0x1,%r14
jmp    1204 <uncommentLine+0xd4>
mov    $0x28,%esi
jmp    11f5 <uncommentLine+0xc5>
mov    $0x5b,%esi
jmp    11f5 <uncommentLine+0xc5>
mov    $0x7b,%esi
movslq %r14d,%rax
add    $0xffffffff,%r14d
movsbl (%rsp,%rax,1),%eax
cmp    %eax,%esi
jne    126a <uncommentLine+0x13a>
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x0,%ebp
cmp    (%rbx),%eax
jne    1162 <uncommentLine+0x32>
test   %r14d,%r14d
js     1239 <uncommentLine+0x109>
mov    %r14d,%eax
mov    %rsp,%rsi
movb   $0x0,0x1(%rax,%rsi,1)
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     1249 <uncommentLine+0x119>
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
test   %r12d,%r12d
je     125a <uncommentLine+0x12a>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe7f(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [32 x i8] c"Unmatched '%c' at character %i\0A\00"
@.str.1 = [31 x i8] c"List of unmatched entries: %s\0A\00"
@.str.2 = [38 x i8] c"Could not locate end of single quote\0A\00"
@.str.3 = [38 x i8] c"Could not locate end of double quote\0A\00"
define void @uncommentLine() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 -1, i32* %2
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %58, %44, %31, %30, %29, %26, %18, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %1
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %59
11: ; preds = %7
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 39
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 0, i32* %5
br label %18
18: ; preds = %17, %14
br label %7
19: ; preds = %11
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 34
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 0, i32* %6
br label %26
26: ; preds = %25, %22
br label %7
27: ; preds = %19
%28 = load i32, i32* %1
switch i32 %28, label %38 [
i32 34, label %29
i32 39, label %30
i32 91, label %31
i32 40, label %31
i32 123, label %31
]
29: ; preds = %27
store i32 1, i32* %6
br label %7
30: ; preds = %27
store i32 1, i32* %5
br label %7
31: ; preds = %27, %27, %27
%32 = load i32, i32* %1
%33 = trunc i32 %32 to i8
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %36
store i8 %33, i8* %37
br label %7
38: ; preds = %27
br label %39
39: ; preds = %38
store i32 32, i32* %3
%40 = load i32, i32* %1
switch i32 %40, label %44 [
i32 93, label %41
i32 41, label %42
i32 125, label %43
]
41: ; preds = %39
store i32 91, i32* %3
br label %45
42: ; preds = %39
store i32 40, i32* %3
br label %45
43: ; preds = %39
store i32 123, i32* %3
br label %45
44: ; preds = %39
br label %7
45: ; preds = %43, %42, %41
%46 = load i32, i32* %2
%47 = add nsw i32 %46, -1
store i32 %47, i32* %2
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = load i32, i32* %3
%53 = icmp ne i32 %51, %52
br i1 %53, label %54, label %58
54: ; preds = %45
%55 = load i32, i32* %3
%56 = load i32, i32* %2
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %55, i32 %56)
br label %79
58: ; preds = %45
br label %7
59: ; preds = %7
%60 = load i32, i32* %2
%61 = icmp sgt i32 %60, -1
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* %2
%64 = add nsw i32 %63, 1
store i32 %64, i32* %2
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %65
store i8 0, i8* %66
%67 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %62, %59
%70 = load i32, i32* %5
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %74
74: ; preds = %72, %69
%75 = load i32, i32* %6
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %54, %77, %74
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [32 x i8] c"Unmatched '%c' at character %i\0A\00"
@.str.1 = [31 x i8] c"List of unmatched entries: %s\0A\00"
@str = [37 x i8] c"Could not locate end of double quote\00"
@str.4 = [37 x i8] c"Could not locate end of single quote\00"
define void @uncommentLine() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %77, label %6
6: ; preds = %0, %52
%7 = phi i32 [ %54, %52 ], [ %3, %0 ]
%8 = phi i32 [ %53, %52 ], [ -1, %0 ]
br label %10
9: ; preds = %35
br label %29
10: ; preds = %6, %29
%11 = phi i32 [ %7, %6 ], [ %32, %29 ]
%12 = phi i32 [ 0, %6 ], [ %31, %29 ]
%13 = phi i32 [ 0, %6 ], [ %30, %29 ]
br label %14
14: ; preds = %10, %18
%15 = phi i32 [ %11, %10 ], [ %21, %18 ]
%16 = phi i32 [ %13, %10 ], [ %20, %18 ]
%17 = icmp eq i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %14
%19 = icmp ne i32 %15, 39
%20 = zext i1 %19 to i32
%21 = tail call i32 (...) @getchar()
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %59, label %14
24: ; preds = %14
%25 = icmp eq i32 %12, 0
br i1 %25, label %35, label %26
26: ; preds = %24
%27 = icmp ne i32 %15, 34
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %26, %36, %35, %9
%30 = phi i32 [ 0, %9 ], [ 0, %35 ], [ 1, %36 ], [ 0, %26 ]
%31 = phi i32 [ 0, %9 ], [ 1, %35 ], [ 0, %36 ], [ %28, %26 ]
%32 = tail call i32 (...) @getchar()
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
br i1 %34, label %59, label %10
35: ; preds = %24
switch i32 %15, label %9 [
i32 34, label %29
i32 39, label %36
i32 91, label %37
i32 40, label %37
i32 123, label %37
i32 93, label %42
i32 41, label %43
i32 125, label %44
]
36: ; preds = %35
br label %29
37: ; preds = %35, %35, %35
%38 = trunc i32 %15 to i8
%39 = add nsw i32 %8, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %40
store i8 %38, i8* %41
br label %52
42: ; preds = %35
br label %44
43: ; preds = %35
br label %44
44: ; preds = %35, %43, %42
%45 = phi i32 [ 91, %42 ], [ 40, %43 ], [ 123, %35 ]
%46 = add nsw i32 %8, -1
%47 = sext i32 %8 to i64
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %45, %50
br i1 %51, label %52, label %57
52: ; preds = %44, %37
%53 = phi i32 [ %39, %37 ], [ %46, %44 ]
%54 = tail call i32 (...) @getchar()
%55 = load i32, i32* @EOF
%56 = icmp eq i32 %54, %55
br i1 %56, label %59, label %6
57: ; preds = %44
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %45, i32 %46)
br label %77
59: ; preds = %52, %29, %18
%60 = phi i32 [ %8, %18 ], [ %8, %29 ], [ %53, %52 ]
%61 = phi i32 [ %12, %18 ], [ %31, %29 ], [ 0, %52 ]
%62 = phi i32 [ %20, %18 ], [ %30, %29 ], [ 0, %52 ]
%63 = icmp sgt i32 %60, -1
br i1 %63, label %64, label %69
64: ; preds = %59
%65 = add nuw nsw i32 %60, 1
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %66
store i8 0, i8* %67
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %69
69: ; preds = %64, %59
%70 = icmp eq i32 %62, 0
br i1 %70, label %73, label %71
71: ; preds = %69
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
br label %73
73: ; preds = %71, %69
%74 = icmp eq i32 %61, 0
br i1 %74, label %77, label %75
75: ; preds = %73
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %77
77: ; preds = %0, %73, %75, %57
ret void
}