#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*/ printf(char *);
int sknobs_uncomment(char *lbuffer) {
  enum { NORMAL, SLASH, BLOCK, STAR, LINE } state = NORMAL;
  char c, *p = lbuffer;
  while ((c = *p)) {
    switch (state) {
    case NORMAL:
      if (c == '/')
        state = SLASH;
      break;
    case SLASH:
      if (c == '*') {
        *(p - 1) = ' ';
        *p = ' ';
        state = BLOCK;
      } else if (c == '/') {
        *(p - 1) = ' ';
        *p = ' ';
        state = LINE;
      } else {
        state = NORMAL;
      }
      break;
    case BLOCK:
      if (c == '*')
        state = STAR;
      *p = ' ';
      break;
    case STAR:
      if (c == '/')
        state = NORMAL;
      else if (c != '*')
        state = BLOCK;
      *p = ' ';
      break;
    case LINE:
      if (c == '\n')
        state = NORMAL;
      else
        *p = ' ';
    }
    ++p;
  }
  if (state == BLOCK) {
    printf("error: sknobs: block comment not closed\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sknobs_uncomment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
cmp    $0x0,%al
je     126f <sknobs_uncomment+0x15f>
mov    -0x14(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x4,%rax
ja     125e <sknobs_uncomment+0x14e>
mov    -0x28(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x15(%rbp),%eax
cmp    $0x2f,%eax
jne    1175 <sknobs_uncomment+0x65>
movl   $0x1,-0x14(%rbp)
jmp    125e <sknobs_uncomment+0x14e>
movsbl -0x15(%rbp),%eax
cmp    $0x2a,%eax
jne    11a2 <sknobs_uncomment+0x92>
mov    -0x20(%rbp),%rax
movb   $0x20,-0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x2,-0x14(%rbp)
jmp    11d6 <sknobs_uncomment+0xc6>
movsbl -0x15(%rbp),%eax
cmp    $0x2f,%eax
jne    11ca <sknobs_uncomment+0xba>
mov    -0x20(%rbp),%rax
movb   $0x20,-0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x4,-0x14(%rbp)
jmp    11d1 <sknobs_uncomment+0xc1>
movl   $0x0,-0x14(%rbp)
jmp    11d6 <sknobs_uncomment+0xc6>
jmp    125e <sknobs_uncomment+0x14e>
movsbl -0x15(%rbp),%eax
cmp    $0x2a,%eax
jne    11ef <sknobs_uncomment+0xdf>
movl   $0x3,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
jmp    125e <sknobs_uncomment+0x14e>
movsbl -0x15(%rbp),%eax
cmp    $0x2f,%eax
jne    1214 <sknobs_uncomment+0x104>
movl   $0x0,-0x14(%rbp)
jmp    122d <sknobs_uncomment+0x11d>
movsbl -0x15(%rbp),%eax
cmp    $0x2a,%eax
je     1228 <sknobs_uncomment+0x118>
movl   $0x2,-0x14(%rbp)
jmp    122d <sknobs_uncomment+0x11d>
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
jmp    125e <sknobs_uncomment+0x14e>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    1252 <sknobs_uncomment+0x142>
movl   $0x0,-0x14(%rbp)
jmp    1259 <sknobs_uncomment+0x149>
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
jmp    125e <sknobs_uncomment+0x14e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <sknobs_uncomment+0x1b>
cmpl   $0x2,-0x14(%rbp)
jne    1291 <sknobs_uncomment+0x181>
lea    0xd94(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1298 <sknobs_uncomment+0x188>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sknobs_uncomment>:
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11b4 <sknobs_uncomment+0xa4>
xor    %esi,%esi
lea    0xedc(%rip),%rcx
xor    %edx,%edx
jmp    1146 <sknobs_uncomment+0x36>
xor    %edx,%edx
cmp    $0x2a,%al
sete   %dl
or     $0x2,%edx
cmp    $0x2f,%al
cmove  %esi,%edx
movb   $0x20,(%rdi)
movzbl 0x1(%rdi),%eax
add    $0x1,%rdi
test   %al,%al
je     119a <sknobs_uncomment+0x8a>
cmp    $0x4,%edx
ja     113a <sknobs_uncomment+0x2a>
mov    %edx,%edx
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
xor    %edx,%edx
cmp    $0x2f,%al
sete   %dl
jmp    113a <sknobs_uncomment+0x2a>
cmp    $0x2f,%al
je     118d <sknobs_uncomment+0x7d>
xor    %edx,%edx
cmp    $0x2a,%al
jne    113a <sknobs_uncomment+0x2a>
movw   $0x2020,-0x1(%rdi)
mov    $0x2,%edx
jmp    113a <sknobs_uncomment+0x2a>
xor    %edx,%edx
cmp    $0x2a,%al
sete   %dl
or     $0x2,%edx
jmp    1137 <sknobs_uncomment+0x27>
xor    %edx,%edx
cmp    $0xa,%al
je     113a <sknobs_uncomment+0x2a>
movb   $0x20,(%rdi)
jmp    1193 <sknobs_uncomment+0x83>
movw   $0x2020,-0x1(%rdi)
mov    $0x4,%edx
jmp    113a <sknobs_uncomment+0x2a>
xor    %eax,%eax
cmp    $0x2,%edx
jne    11b2 <sknobs_uncomment+0xa2>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"error: sknobs: block comment not closed\0A\00"
define i32 @sknobs_uncomment(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %6
br label %8
8: ; preds = %67, %1
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
store i8 %10, i8* %5
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %70
12: ; preds = %8
%13 = load i32, i32* %4
switch i32 %13, label %67 [
i32 0, label %14
i32 1, label %20
i32 2, label %39
i32 3, label %46
i32 4, label %59
]
14: ; preds = %12
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %4
br label %19
19: ; preds = %18, %14
br label %67
20: ; preds = %12
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 42
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 -1
store i8 32, i8* %26
%27 = load i8*, i8** %6
store i8 32, i8* %27
store i32 2, i32* %4
br label %38
28: ; preds = %20
%29 = load i8, i8* %5
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 47
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 -1
store i8 32, i8* %34
%35 = load i8*, i8** %6
store i8 32, i8* %35
store i32 4, i32* %4
br label %37
36: ; preds = %28
store i32 0, i32* %4
br label %37
37: ; preds = %36, %32
br label %38
38: ; preds = %37, %24
br label %67
39: ; preds = %12
%40 = load i8, i8* %5
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 42
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 3, i32* %4
br label %44
44: ; preds = %43, %39
%45 = load i8*, i8** %6
store i8 32, i8* %45
br label %67
46: ; preds = %12
%47 = load i8, i8* %5
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 47
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 0, i32* %4
br label %57
51: ; preds = %46
%52 = load i8, i8* %5
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 42
br i1 %54, label %55, label %56
55: ; preds = %51
store i32 2, i32* %4
br label %56
56: ; preds = %55, %51
br label %57
57: ; preds = %56, %50
%58 = load i8*, i8** %6
store i8 32, i8* %58
br label %67
59: ; preds = %12
%60 = load i8, i8* %5
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 10
br i1 %62, label %63, label %64
63: ; preds = %59
store i32 0, i32* %4
br label %66
64: ; preds = %59
%65 = load i8*, i8** %6
store i8 32, i8* %65
br label %66
66: ; preds = %64, %63
br label %67
67: ; preds = %66, %12, %57, %44, %38, %19
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %6
br label %8
70: ; preds = %8
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 2
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %76
75: ; preds = %70
store i32 0, i32* %2
br label %76
76: ; preds = %75, %73
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
@str = [40 x i8] c"error: sknobs: block comment not closed\00"
define i32 @sknobs_uncomment(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %36, label %4
4: ; preds = %1, %27
%5 = phi i8 [ %30, %27 ], [ %2, %1 ]
%6 = phi i8* [ %29, %27 ], [ %0, %1 ]
%7 = phi i32 [ %28, %27 ], [ 0, %1 ]
switch i32 %7, label %27 [
i32 0, label %8
i32 1, label %11
i32 2, label %16
i32 3, label %19
i32 4, label %24
]
8: ; preds = %4
%9 = icmp eq i8 %5, 47
%10 = zext i1 %9 to i32
br label %27
11: ; preds = %4
switch i8 %5, label %27 [
i8 42, label %12
i8 47, label %14
]
12: ; preds = %11
%13 = getelementptr inbounds i8, i8* %6, i64 -1
store i8 32, i8* %13
store i8 32, i8* %6
br label %27
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %6, i64 -1
store i8 32, i8* %15
store i8 32, i8* %6
br label %27
16: ; preds = %4
%17 = icmp eq i8 %5, 42
%18 = select i1 %17, i32 3, i32 2
store i8 32, i8* %6
br label %27
19: ; preds = %4
%20 = icmp eq i8 %5, 42
%21 = select i1 %20, i32 3, i32 2
%22 = icmp eq i8 %5, 47
%23 = select i1 %22, i32 0, i32 %21
store i8 32, i8* %6
br label %27
24: ; preds = %4
%25 = icmp eq i8 %5, 10
br i1 %25, label %27, label %26
26: ; preds = %24
store i8 32, i8* %6
br label %27
27: ; preds = %8, %24, %11, %26, %12, %14, %4, %19, %16
%28 = phi i32 [ %7, %4 ], [ 4, %26 ], [ %23, %19 ], [ %18, %16 ], [ 2, %12 ], [ 4, %14 ], [ %10, %8 ], [ 0, %11 ], [ 0, %24 ]
%29 = getelementptr inbounds i8, i8* %6, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %4
32: ; preds = %27
%33 = icmp eq i32 %28, 2
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %1, %32, %34
%37 = phi i32 [ 1, %34 ], [ 0, %32 ], [ 0, %1 ]
ret i32 %37
}