#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 getchar();
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strchr(char *, int);
int PutComment(int c) {
  int n = 0, i = 0, lf = 0;
  puts("/*");
  putchar(c);
  c = getchar();
  while (c >= 0 && !strchr("<>[]+-,.", c)) {
    if (c == 10 || c == 13) {
      if (c == 10)
        ++lf;
    } else if (c != ' ') {
      if (lf) {
        if (lf > 2)
          lf = 2;
        for (i = 0; i < lf; ++i)
          puts("");
        lf = 0;
      } else {
        if (n > 2)
          n = 2;
        for (i = 0; i < n; ++i)
          putchar(' ');
      }
      n = 0;
      putchar(c);
    } else
      ++n;
    c = getchar();
  }
  puts("\n*/");
  return c;
}


x86 assembly (clang, -O0):
<PutComment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x11(%rbp)
jl     11a7 <PutComment+0x67>
mov    -0x4(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1050 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11b7 <PutComment+0x77>
jmp    12b3 <PutComment+0x173>
cmpl   $0xa,-0x4(%rbp)
je     11cb <PutComment+0x8b>
cmpl   $0xd,-0x4(%rbp)
jne    11e3 <PutComment+0xa3>
cmpl   $0xa,-0x4(%rbp)
jne    11de <PutComment+0x9e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12a4 <PutComment+0x164>
cmpl   $0x20,-0x4(%rbp)
je     1296 <PutComment+0x156>
cmpl   $0x0,-0x10(%rbp)
je     1241 <PutComment+0x101>
cmpl   $0x2,-0x10(%rbp)
jle    1208 <PutComment+0xc8>
movl   $0x2,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1235 <PutComment+0xf5>
lea    0xde0(%rip),%rdi
call   1040 <puts@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120f <PutComment+0xcf>
movl   $0x0,-0x10(%rbp)
jmp    1282 <PutComment+0x142>
cmpl   $0x2,-0x8(%rbp)
jle    1252 <PutComment+0x112>
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127d <PutComment+0x13d>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1259 <PutComment+0x119>
jmp    1282 <PutComment+0x142>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    129f <PutComment+0x15f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12a4 <PutComment+0x164>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x4(%rbp)
jmp    117e <PutComment+0x3e>
lea    0xd52(%rip),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutComment>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1230 <PutComment+0xf0>
lea    0xe8f(%rip),%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1195 <PutComment+0x55>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1230 <PutComment+0xf0>
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <strchr@plt>
test   %eax,%eax
jne    1230 <PutComment+0xf0>
cmp    $0x20,%ebp
je     1180 <PutComment+0x40>
cmp    $0xd,%ebp
je     1184 <PutComment+0x44>
cmp    $0xa,%ebp
jne    11c0 <PutComment+0x80>
add    $0x1,%ebx
jmp    1184 <PutComment+0x44>
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
je     11f1 <PutComment+0xb1>
jle    121f <PutComment+0xdf>
xor    %eax,%eax
cmp    $0x1,%ebx
sete   %al
mov    $0x2,%ebx
sub    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <PutComment+0xa0>
jmp    121f <PutComment+0xdf>
test   %r15d,%r15d
jle    121f <PutComment+0xdf>
xor    %eax,%eax
cmp    $0x1,%r15d
sete   %al
mov    $0x2,%ebx
sub    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1210 <PutComment+0xd0>
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1184 <PutComment+0x44>
lea    0xdd5(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"/*\00"
@.str.1 = [9 x i8] c"<>[]+-,.\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"\0A*/\00"
define i32 @PutComment(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = call i32 @putchar(i32 %7)
%9 = call i32 (...) @getchar()
store i32 %9, i32* %2
br label %10
10: ; preds = %76, %1
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @strchr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br label %18
18: ; preds = %13, %10
%19 = phi i1 [ false, %10 ], [ %17, %13 ]
br i1 %19, label %20, label %78
20: ; preds = %18
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 10
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 13
br i1 %25, label %26, label %33
26: ; preds = %23, %20
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %26
br label %76
33: ; preds = %23
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 32
br i1 %35, label %36, label %72
36: ; preds = %33
%37 = load i32, i32* %5
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = load i32, i32* %5
%41 = icmp sgt i32 %40, 2
br i1 %41, label %42, label %43
42: ; preds = %39
store i32 2, i32* %5
br label %43
43: ; preds = %42, %39
store i32 0, i32* %4
br label %44
44: ; preds = %50, %43
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %44
53: ; preds = %44
store i32 0, i32* %5
br label %69
54: ; preds = %36
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 2
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 2, i32* %3
br label %58
58: ; preds = %57, %54
store i32 0, i32* %4
br label %59
59: ; preds = %65, %58
%60 = load i32, i32* %4
%61 = load i32, i32* %3
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %68
63: ; preds = %59
%64 = call i32 @putchar(i32 32)
br label %65
65: ; preds = %63
%66 = load i32, i32* %4
%67 = add nsw i32 %66, 1
store i32 %67, i32* %4
br label %59
68: ; preds = %59
br label %69
69: ; preds = %68, %53
store i32 0, i32* %3
%70 = load i32, i32* %2
%71 = call i32 @putchar(i32 %70)
br label %75
72: ; preds = %33
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
store i32 %74, i32* %3
br label %75
75: ; preds = %72, %69
br label %76
76: ; preds = %75, %32
%77 = call i32 (...) @getchar()
store i32 %77, i32* %2
br label %10
78: ; preds = %18
%79 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%80 = load i32, i32* %2
ret i32 %80
}

LLVM IR (-O2):
@.str = [3 x i8] c"/*\00"
@.str.1 = [9 x i8] c"<>[]+-,.\00"
@.str.3 = [4 x i8] c"\0A*/\00"
define i32 @PutComment(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @putchar(i32 %0)
%4 = tail call i32 (...) @getchar()
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %46
6: ; preds = %1, %41
%7 = phi i32 [ %43, %41 ], [ 0, %1 ]
%8 = phi i32 [ %42, %41 ], [ 0, %1 ]
%9 = phi i32 [ %44, %41 ], [ %4, %1 ]
%10 = tail call i32 @strchr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %46
12: ; preds = %6
switch i32 %9, label %15 [
i32 10, label %13
i32 13, label %41
i32 32, label %39
]
13: ; preds = %12
%14 = add nsw i32 %7, 1
br label %41
15: ; preds = %12
%16 = icmp eq i32 %7, 0
br i1 %16, label %27, label %17
17: ; preds = %15
%18 = icmp sgt i32 %7, 0
br i1 %18, label %19, label %37
19: ; preds = %17
%20 = icmp eq i32 %7, 1
%21 = select i1 %20, i32 1, i32 2
br label %22
22: ; preds = %19, %22
%23 = phi i32 [ %25, %22 ], [ 0, %19 ]
%24 = tail call i32 @putchar(i32 10)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %21
br i1 %26, label %37, label %22
27: ; preds = %15
%28 = icmp sgt i32 %8, 0
br i1 %28, label %29, label %37
29: ; preds = %27
%30 = icmp eq i32 %8, 1
%31 = select i1 %30, i32 1, i32 2
br label %32
32: ; preds = %29, %32
%33 = phi i32 [ %35, %32 ], [ 0, %29 ]
%34 = tail call i32 @putchar(i32 32)
%35 = add nuw nsw i32 %33, 1
%36 = icmp eq i32 %35, %31
br i1 %36, label %37, label %32
37: ; preds = %22, %32, %17, %27
%38 = tail call i32 @putchar(i32 %9)
br label %41
39: ; preds = %12
%40 = add nsw i32 %8, 1
br label %41
41: ; preds = %12, %37, %39, %13
%42 = phi i32 [ %8, %13 ], [ 0, %37 ], [ %40, %39 ], [ %8, %12 ]
%43 = phi i32 [ %14, %13 ], [ 0, %37 ], [ %7, %39 ], [ %7, %12 ]
%44 = tail call i32 (...) @getchar()
%45 = icmp sgt i32 %44, -1
br i1 %45, label %6, label %46
46: ; preds = %6, %41, %1
%47 = phi i32 [ %4, %1 ], [ %44, %41 ], [ %9, %6 ]
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 %47
}