#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 change_state(int, int);
int getchar();
int /*<<< orphan*/ putchar(int);
void output_char(int cur_char) {
  extern int state;
  int next_char;
  int cur_state;
  if (state == 0 && cur_char == '/') {
    next_char = getchar();
    cur_state = change_state(next_char, cur_char);
    if (cur_state != 3) {
      putchar(cur_char);
      putchar(next_char);
    }
  } else {
    if (state != 3) {
      putchar(cur_char);
    }
  }
}


x86 assembly (clang, -O0):
<output_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
cmpl   $0x0,(%rax)
jne    118c <output_char+0x5c>
cmpl   $0x2f,-0x4(%rbp)
jne    118c <output_char+0x5c>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <change_state@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
je     1187 <output_char+0x57>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a9 <output_char+0x79>
mov    0x2e4d(%rip),%rax
cmpl   $0x3,(%rax)
je     11a4 <output_char+0x74>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a9 <output_char+0x79>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_char>:
push   %rbx
mov    %edi,%ebx
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
cmp    $0x2f,%edi
jne    116b <output_char+0x3b>
test   %eax,%eax
jne    116b <output_char+0x3b>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x2f,%esi
call   1040 <change_state@plt>
cmp    $0x3,%eax
je     1170 <output_char+0x40>
mov    $0x2f,%edi
call   1030 <putchar@plt>
jmp    1172 <output_char+0x42>
cmp    $0x3,%eax
jne    1172 <output_char+0x42>
pop    %rbx
ret
mov    %ebx,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@state = external global i32
define void @output_char(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* @state
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 47
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = call i32 (...) @getchar()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = call i32 @change_state(i32 %12, i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i32, i32* %2
%19 = call i32 @putchar(i32 %18)
%20 = load i32, i32* %3
%21 = call i32 @putchar(i32 %20)
br label %22
22: ; preds = %17, %10
br label %30
23: ; preds = %7, %1
%24 = load i32, i32* @state
%25 = icmp ne i32 %24, 3
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %2
%28 = call i32 @putchar(i32 %27)
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %22
ret void
}

LLVM IR (-O2):
@state = external global i32
define void @output_char(i32 %0) {
%2 = load i32, i32* @state
%3 = icmp eq i32 %2, 0
%4 = icmp eq i32 %0, 47
%5 = and i1 %4, %3
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = tail call i32 (...) @getchar()
%8 = tail call i32 @change_state(i32 %7, i32 47)
%9 = icmp eq i32 %8, 3
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = tail call i32 @putchar(i32 47)
br label %14
12: ; preds = %1
%13 = icmp eq i32 %2, 3
br i1 %13, label %17, label %14
14: ; preds = %12, %10
%15 = phi i32 [ %7, %10 ], [ %0, %12 ]
%16 = tail call i32 @putchar(i32 %15)
br label %17
17: ; preds = %14, %12, %6
ret void
}