#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*/ *);
int process_line(int /*<<< orphan*/ *, int, char *, char *);
int transition(int /*<<< orphan*/ *, int, int);
void process_f(FILE *in, FILE *out) {
  char buf[512];
  int state = 3;
  while (fgets(buf, sizeof(buf), in) != NULL) {
    int offset = 0;
    while (buf[offset] == '\t' || buf[offset] == ' ' ||
           (offset < 6 && buf[offset] != '\0' && buf[offset] != '\r' &&
            buf[offset] != '\n'))
      ++offset;
    state = process_line(out, state, buf + offset, buf);
  }
  state = transition(out, state, 3);
}


x86 assembly (clang, -O0):
<process_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     128b <process_f+0x15b>
movl   $0x0,-0x218(%rbp)
movslq -0x218(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x219(%rbp)
je     1232 <process_f+0x102>
movslq -0x218(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x219(%rbp)
je     1232 <process_f+0x102>
xor    %eax,%eax
cmpl   $0x6,-0x218(%rbp)
mov    %al,-0x21a(%rbp)
jge    1226 <process_f+0xf6>
movslq -0x218(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21a(%rbp)
je     1226 <process_f+0xf6>
movslq -0x218(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x21a(%rbp)
je     1226 <process_f+0xf6>
movslq -0x218(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
setne  %al
mov    %al,-0x21a(%rbp)
mov    -0x21a(%rbp),%al
mov    %al,-0x219(%rbp)
mov    -0x219(%rbp),%al
test   $0x1,%al
jne    1245 <process_f+0x115>
jmp    1259 <process_f+0x129>
mov    -0x218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x218(%rbp)
jmp    1176 <process_f+0x46>
mov    -0x10(%rbp),%rdi
mov    -0x214(%rbp),%esi
lea    -0x210(%rbp),%rdx
movslq -0x218(%rbp),%rax
add    %rax,%rdx
lea    -0x210(%rbp),%rcx
call   1050 <process_line@plt>
mov    %eax,-0x214(%rbp)
jmp    114d <process_f+0x1d>
mov    -0x10(%rbp),%rdi
mov    -0x214(%rbp),%esi
mov    $0x3,%edx
call   1040 <transition@plt>
mov    %eax,-0x214(%rbp)
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_f>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     11c7 <process_f+0x97>
mov    %rsp,%r12
mov    $0x2401,%ebx
jmp    119a <process_f+0x6a>
nopl   0x0(%rax)
mov    %eax,%eax
lea    (%rsp,%rax,1),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
call   1050 <process_line@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     11c7 <process_f+0x97>
xor    %eax,%eax
jmp    11a4 <process_f+0x74>
xchg   %ax,%ax
add    $0x1,%rax
movzbl (%rsp,%rax,1),%ecx
cmp    $0x9,%cl
je     11a0 <process_f+0x70>
cmp    $0x20,%cl
je     11a0 <process_f+0x70>
cmp    $0x5,%eax
ja     1170 <process_f+0x40>
cmp    $0xd,%cl
ja     11a0 <process_f+0x70>
movzbl %cl,%ecx
bt     %rcx,%rbx
jae    11a0 <process_f+0x70>
jmp    1170 <process_f+0x40>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1040 <transition@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @process_f(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [512 x i8]
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 3, i32* %6
br label %8
8: ; preds = %59, %2
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%10 = load i32*, i32** %3
%11 = call i32* @fgets(i8* %9, i32 512, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %68
13: ; preds = %8
store i32 0, i32* %7
br label %14
14: ; preds = %56, %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 9
br i1 %20, label %54, label %21
21: ; preds = %14
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %54, label %28
28: ; preds = %21
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 6
br i1 %30, label %31, label %52
31: ; preds = %28
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %52
38: ; preds = %31
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 13
br i1 %44, label %45, label %52
45: ; preds = %38
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 10
br label %52
52: ; preds = %45, %38, %31, %28
%53 = phi i1 [ false, %38 ], [ false, %31 ], [ false, %28 ], [ %51, %45 ]
br label %54
54: ; preds = %52, %21, %14
%55 = phi i1 [ true, %21 ], [ true, %14 ], [ %53, %52 ]
br i1 %55, label %56, label %59
56: ; preds = %54
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %14
59: ; preds = %54
%60 = load i32*, i32** %4
%61 = load i32, i32* %6
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%67 = call i32 @process_line(i32* %60, i32 %61, i8* %65, i8* %66)
store i32 %67, i32* %6
br label %8
68: ; preds = %8
%69 = load i32*, i32** %4
%70 = load i32, i32* %6
%71 = call i32 @transition(i32* %69, i32 %70, i32 3)
store i32 %71, i32* %6
ret void
}

LLVM IR (-O2):
define void @process_f(i32* nocapture %0, i32* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 512, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %27, label %7
7: ; preds = %2, %20
%8 = phi i32 [ %24, %20 ], [ 3, %2 ]
br label %9
9: ; preds = %7, %18
%10 = phi i64 [ 0, %7 ], [ %19, %18 ]
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 9, label %18
i8 32, label %18
]
13: ; preds = %9
%14 = freeze i64 %10
%15 = trunc i64 %14 to i32
%16 = icmp ugt i32 %15, 5
br i1 %16, label %20, label %17
17: ; preds = %13
switch i8 %12, label %18 [
i8 13, label %20
i8 10, label %20
i8 0, label %20
]
18: ; preds = %17, %9, %9
%19 = add nuw i64 %10, 1
br label %9
20: ; preds = %17, %17, %17, %13
%21 = freeze i64 %10
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %22
%24 = call i32 @process_line(i32* %1, i32 %8, i8* %23, i8* %4)
%25 = call i32* @fgets(i8* %4, i32 512, i32* %0)
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %7
27: ; preds = %20, %2
%28 = phi i32 [ 3, %2 ], [ %24, %20 ]
%29 = call i32 @transition(i32* %1, i32 %28, i32 3)
ret void
}