#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 */
struct stream {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ sclose(struct stream *);
int sgetc(struct stream *);
struct stream *sopen_fd(char *, int);
int /*<<< orphan*/ sputc(struct stream *, int);
int main(void) {
  struct stream *i = sopen_fd("stdin", 0);
  struct stream *o = sopen_fd("stdout", 1);
  int c, d, nl = 1;
  c = sgetc(i);
  for (;;) {
    if (c == '/') {
      if ((d = sgetc(i)) == '/') {
        while ((c = sgetc(i)) >= 0 && c != '\n')
          ;
        if (nl) {
          c = sgetc(i);
          continue;
        }
      } else {
        sputc(o, c);
        c = d;
      }
    }
    if (c < 0)
      break;
    sputc(o, c);
    nl = (c == '\n');
    c = sgetc(i);
  }
  sclose(o);
  sclose(i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %esi,%esi
call   1050 <sopen_fd@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x1,%esi
call   1050 <sopen_fd@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2f,-0x1c(%rbp)
jne    121f <main+0xdf>
mov    -0x10(%rbp),%rdi
call   1060 <sgetc@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x2f,%eax
jne    1208 <main+0xc8>
jmp    11ad <main+0x6d>
mov    -0x10(%rbp),%rdi
call   1060 <sgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
jl     11d3 <main+0x93>
cmpl   $0xa,-0x1c(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11e3 <main+0xa3>
jmp    11e8 <main+0xa8>
jmp    11ad <main+0x6d>
cmpl   $0x0,-0x24(%rbp)
je     1203 <main+0xc3>
mov    -0x10(%rbp),%rdi
call   1060 <sgetc@plt>
mov    %eax,-0x1c(%rbp)
jmp    1189 <main+0x49>
jmp    121a <main+0xda>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <sputc@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    121f <main+0xdf>
cmpl   $0x0,-0x1c(%rbp)
jge    122e <main+0xee>
jmp    125a <main+0x11a>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <sputc@plt>
cmpl   $0xa,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sgetc@plt>
mov    %eax,-0x1c(%rbp)
jmp    1189 <main+0x49>
mov    -0x18(%rbp),%rdi
call   1040 <sclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <sclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
xor    %esi,%esi
call   1050 <sopen_fd@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
mov    $0x1,%r15d
mov    $0x1,%esi
call   1050 <sopen_fd@plt>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <sgetc@plt>
mov    %eax,%ebp
cmp    $0x2f,%eax
jne    11cf <main+0x8f>
mov    %rbx,%rdi
call   1060 <sgetc@plt>
cmp    $0x2f,%eax
jne    11c0 <main+0x80>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <sgetc@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11b3 <main+0x73>
cmp    $0xa,%ebp
jne    11a0 <main+0x60>
test   %r15d,%r15d
mov    $0x1,%r15d
jne    1180 <main+0x40>
jmp    11cf <main+0x8f>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x2f,%esi
call   1030 <sputc@plt>
test   %ebp,%ebp
js     11e9 <main+0xa9>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <sputc@plt>
xor    %r15d,%r15d
cmp    $0xa,%ebp
sete   %r15b
jmp    1180 <main+0x40>
mov    %r14,%rdi
call   1040 <sclose@plt>
mov    %rbx,%rdi
call   1040 <sclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stream = type { i32 }
@.str = [6 x i8] c"stdin\00"
@.str.1 = [7 x i8] c"stdout\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stream*
%3 = alloca %struct.stream*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call %struct.stream* @sopen_fd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 0)
store %struct.stream* %7, %struct.stream** %2
%8 = call %struct.stream* @sopen_fd(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
store %struct.stream* %8, %struct.stream** %3
store i32 1, i32* %6
%9 = load %struct.stream*, %struct.stream** %2
%10 = call i32 @sgetc(%struct.stream* %9)
store i32 %10, i32* %4
br label %11
11: ; preds = %46, %32, %0
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 47
br i1 %13, label %14, label %42
14: ; preds = %11
%15 = load %struct.stream*, %struct.stream** %2
%16 = call i32 @sgetc(%struct.stream* %15)
store i32 %16, i32* %5
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %36
18: ; preds = %14
br label %19
19: ; preds = %28, %18
%20 = load %struct.stream*, %struct.stream** %2
%21 = call i32 @sgetc(%struct.stream* %20)
store i32 %21, i32* %4
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 10
br label %26
26: ; preds = %23, %19
%27 = phi i1 [ false, %19 ], [ %25, %23 ]
br i1 %27, label %28, label %29
28: ; preds = %26
br label %19
29: ; preds = %26
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load %struct.stream*, %struct.stream** %2
%34 = call i32 @sgetc(%struct.stream* %33)
store i32 %34, i32* %4
br label %11
35: ; preds = %29
br label %41
36: ; preds = %14
%37 = load %struct.stream*, %struct.stream** %3
%38 = load i32, i32* %4
%39 = call i32 @sputc(%struct.stream* %37, i32 %38)
%40 = load i32, i32* %5
store i32 %40, i32* %4
br label %41
41: ; preds = %36, %35
br label %42
42: ; preds = %41, %11
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
br label %55
46: ; preds = %42
%47 = load %struct.stream*, %struct.stream** %3
%48 = load i32, i32* %4
%49 = call i32 @sputc(%struct.stream* %47, i32 %48)
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 10
%52 = zext i1 %51 to i32
store i32 %52, i32* %6
%53 = load %struct.stream*, %struct.stream** %2
%54 = call i32 @sgetc(%struct.stream* %53)
store i32 %54, i32* %4
br label %11
55: ; preds = %45
%56 = load %struct.stream*, %struct.stream** %3
%57 = call i32 @sclose(%struct.stream* %56)
%58 = load %struct.stream*, %struct.stream** %2
%59 = call i32 @sclose(%struct.stream* %58)
ret i32 0
}

LLVM IR (-O2):
%struct.stream = type { i32 }
@.str = [6 x i8] c"stdin\00"
@.str.1 = [7 x i8] c"stdout\00"
define i32 @main() {
%1 = tail call %struct.stream* @sopen_fd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call %struct.stream* @sopen_fd(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %3
3: ; preds = %17, %0
%4 = phi i32 [ 1, %0 ], [ %18, %17 ]
%5 = tail call i32 @sgetc(%struct.stream* %1)
%6 = icmp eq i32 %5, 47
br i1 %6, label %7, label %21
7: ; preds = %3
%8 = tail call i32 @sgetc(%struct.stream* %1)
%9 = icmp eq i32 %8, 47
br i1 %9, label %10, label %19
10: ; preds = %7, %10
%11 = tail call i32 @sgetc(%struct.stream* %1)
%12 = icmp sgt i32 %11, -1
%13 = icmp ne i32 %11, 10
%14 = and i1 %12, %13
br i1 %14, label %10, label %15
15: ; preds = %10
%16 = icmp eq i32 %4, 0
br i1 %16, label %21, label %17
17: ; preds = %15, %24
%18 = phi i32 [ %27, %24 ], [ 1, %15 ]
br label %3
19: ; preds = %7
%20 = tail call i32 @sputc(%struct.stream* %2, i32 47)
br label %21
21: ; preds = %19, %15, %3
%22 = phi i32 [ %11, %15 ], [ %8, %19 ], [ %5, %3 ]
%23 = icmp slt i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = tail call i32 @sputc(%struct.stream* %2, i32 %22)
%26 = icmp eq i32 %22, 10
%27 = zext i1 %26 to i32
br label %17
28: ; preds = %21
%29 = tail call i32 @sclose(%struct.stream* %2)
%30 = tail call i32 @sclose(%struct.stream* %1)
ret i32 0
}