#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ is_skippable(char, char *);
int process_line(int /*<<< orphan*/ *, int, char *, char *);
int transition(int /*<<< orphan*/ *, int, int);
void process_simple(FILE *in, FILE *out, char *skips) {
  char buf[512];
  int state = 3;
  while (fgets(buf, sizeof(buf), in) != NULL) {
    char *p;
    for (p = buf; is_skippable(*p, skips); ++p)
      ;
    state = process_line(out, state, p, buf);
  }
  state = transition(out, state, 3);
}


x86 assembly (clang, -O0):
<process_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x3,-0x224(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11f1 <process_simple+0xb1>
lea    -0x220(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1050 <is_skippable@plt>
cmp    $0x0,%rax
je     11c9 <process_simple+0x89>
jmp    11b2 <process_simple+0x72>
mov    -0x230(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x230(%rbp)
jmp    118e <process_simple+0x4e>
mov    -0x10(%rbp),%rdi
mov    -0x224(%rbp),%esi
mov    -0x230(%rbp),%rdx
lea    -0x220(%rbp),%rcx
call   1060 <process_line@plt>
mov    %eax,-0x224(%rbp)
jmp    1161 <process_simple+0x21>
mov    -0x10(%rbp),%rdi
mov    -0x224(%rbp),%esi
mov    $0x3,%edx
call   1040 <transition@plt>
mov    %eax,-0x224(%rbp)
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_simple>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
mov    $0x3,%r13d
test   %rax,%rax
je     11ce <process_simple+0x8e>
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x1(%rbp),%edi
add    $0x1,%rbp
mov    %rbx,%rsi
call   1050 <is_skippable@plt>
test   %rax,%rax
jne    1190 <process_simple+0x50>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1060 <process_line@plt>
mov    %eax,%r13d
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    1180 <process_simple+0x40>
mov    %r14,%rdi
mov    %r13d,%esi
mov    $0x3,%edx
call   1040 <transition@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @process_simple(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca [512 x i8]
%8 = alloca i32
%9 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 3, i32* %8
br label %10
10: ; preds = %27, %3
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i32* @fgets(i8* %11, i32 512, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %33
15: ; preds = %10
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8* %16, i8** %9
br label %17
17: ; preds = %24, %15
%18 = load i8*, i8** %9
%19 = load i8, i8* %18
%20 = load i8*, i8** %6
%21 = call i64 @is_skippable(i8 signext %19, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %17
br label %24
24: ; preds = %23
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %9
br label %17
27: ; preds = %17
%28 = load i32*, i32** %5
%29 = load i32, i32* %8
%30 = load i8*, i8** %9
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%32 = call i32 @process_line(i32* %28, i32 %29, i8* %30, i8* %31)
store i32 %32, i32* %8
br label %10
33: ; preds = %10
%34 = load i32*, i32** %5
%35 = load i32, i32* %8
%36 = call i32 @transition(i32* %34, i32 %35, i32 3)
store i32 %36, i32* %8
ret void
}

LLVM IR (-O2):
define void @process_simple(i32* nocapture %0, i32* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32* @fgets(i8* %5, i32 512, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %20, label %8
8: ; preds = %3, %16
%9 = phi i32 [ %17, %16 ], [ 3, %3 ]
br label %10
10: ; preds = %10, %8
%11 = phi i8* [ %15, %10 ], [ %5, %8 ]
%12 = load i8, i8* %11
%13 = call i64 @is_skippable(i8 signext %12, i8* %2)
%14 = icmp eq i64 %13, 0
%15 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %14, label %16, label %10
16: ; preds = %10
%17 = call i32 @process_line(i32* %1, i32 %9, i8* %11, i8* %5)
%18 = call i32* @fgets(i8* %5, i32 512, i32* %0)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %8
20: ; preds = %16, %3
%21 = phi i32 [ 3, %3 ], [ %17, %16 ]
%22 = call i32 @transition(i32* %1, i32 %21, i32 3)
ret void
}