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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *strtok(char *, char *);
int lex(char *input, char *output) {
  FILE *source = fopen(input, "r");
  FILE *target = fopen(output, "w");
  char string[256];
  char *token;
  while (fgets(string, sizeof(string), source) != NULL) {
    if (string[0] == '.') {
      if (string[1] == 'b' || string[1] == 'o' || string[1] == 'h' ||
          string[1] == 'd' || string[1] == 'i' || string[1] == 'f') {
        token = strtok(string, " ,");
        while (token != NULL) {
          fprintf(target, "%s\n", token);
          token = strtok(NULL, " ,");
        }
      }
      if (string[1] == 'a') {
        token = strtok(string, " ,");
        while (token != NULL) {
          fprintf(target, "%s\n", token);
          token = strtok(NULL, " ,");
        }
        fgets(string, sizeof(string), source);
        fprintf(target, string);
      }
    } else {
      token = strtok(string, " ,");
      while (token != NULL) {
        fprintf(target, "%s\n", token);
        token = strtok(NULL, " ,");
      }
    }
  }
  fclose(source);
  fclose(target);
}


x86 assembly (clang, -O0):
<lex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     137c <lex+0x22c>
movsbl -0x130(%rbp),%eax
cmp    $0x2e,%eax
jne    1315 <lex+0x1c5>
movsbl -0x12f(%rbp),%eax
cmp    $0x62,%eax
je     121a <lex+0xca>
movsbl -0x12f(%rbp),%eax
cmp    $0x6f,%eax
je     121a <lex+0xca>
movsbl -0x12f(%rbp),%eax
cmp    $0x68,%eax
je     121a <lex+0xca>
movsbl -0x12f(%rbp),%eax
cmp    $0x64,%eax
je     121a <lex+0xca>
movsbl -0x12f(%rbp),%eax
cmp    $0x69,%eax
je     121a <lex+0xca>
movsbl -0x12f(%rbp),%eax
cmp    $0x66,%eax
jne    127c <lex+0x12c>
lea    -0x130(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     1277 <lex+0x127>
mov    -0x28(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9e(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
jmp    1234 <lex+0xe4>
jmp    127c <lex+0x12c>
movsbl -0x12f(%rbp),%eax
cmp    $0x61,%eax
jne    1310 <lex+0x1c0>
lea    -0x130(%rbp),%rdi
lea    0xd6a(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     12e9 <lex+0x199>
mov    -0x28(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd2c(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
jmp    12a6 <lex+0x156>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1377 <lex+0x227>
lea    -0x130(%rbp),%rdi
lea    0xce1(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     1372 <lex+0x222>
mov    -0x28(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xcb8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xca3(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
jmp    132f <lex+0x1df>
jmp    1377 <lex+0x227>
jmp    118b <lex+0x3b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     12c5 <lex+0x175>
lea    0xe5f(%rip),%r15
mov    %rsp,%r12
lea    0xe58(%rip),%r13
mov    $0x20d5,%ebp
jmp    11f6 <lex+0xa6>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     12c5 <lex+0x175>
cmpb   $0x2e,(%rsp)
jne    1250 <lex+0x100>
mov    0x1(%rsp),%al
lea    -0x62(%rax),%ecx
cmp    $0xd,%cl
ja     1294 <lex+0x144>
movzbl %cl,%ecx
bt     %rcx,%rbp
jae    1294 <lex+0x144>
mov    %r12,%rdi
nopl   0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     1290 <lex+0x140>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %edi,%edi
jmp    1220 <lex+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11dd <lex+0x8d>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %edi,%edi
jmp    1260 <lex+0x110>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x1(%rsp),%al
cmp    $0x61,%al
jne    11dd <lex+0x8d>
mov    %r12,%rdi
nop
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11c0 <lex+0x70>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %edi,%edi
jmp    12a0 <lex+0x150>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c" ,\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @lex(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %7
br label %14
14: ; preds = %102, %2
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = load i32*, i32** %6
%17 = call i32* @fgets(i8* %15, i32 256, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %103
19: ; preds = %14
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
br i1 %23, label %24, label %90
24: ; preds = %19
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 98
br i1 %28, label %54, label %29
29: ; preds = %24
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 111
br i1 %33, label %54, label %34
34: ; preds = %29
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 104
br i1 %38, label %54, label %39
39: ; preds = %34
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 100
br i1 %43, label %54, label %44
44: ; preds = %39
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 105
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 102
br i1 %53, label %54, label %66
54: ; preds = %49, %44, %39, %34, %29, %24
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%56 = call i8* @strtok(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %56, i8** %9
br label %57
57: ; preds = %60, %54
%58 = load i8*, i8** %9
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32*, i32** %7
%62 = load i8*, i8** %9
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %64, i8** %9
br label %57
65: ; preds = %57
br label %66
66: ; preds = %65, %49
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 1
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 97
br i1 %70, label %71, label %89
71: ; preds = %66
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%73 = call i8* @strtok(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %73, i8** %9
br label %74
74: ; preds = %77, %71
%75 = load i8*, i8** %9
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i32*, i32** %7
%79 = load i8*, i8** %9
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %79)
%81 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %81, i8** %9
br label %74
82: ; preds = %74
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%84 = load i32*, i32** %6
%85 = call i32* @fgets(i8* %83, i32 256, i32* %84)
%86 = load i32*, i32** %7
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* %87)
br label %89
89: ; preds = %82, %66
br label %102
90: ; preds = %19
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%92 = call i8* @strtok(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %92, i8** %9
br label %93
93: ; preds = %96, %90
%94 = load i8*, i8** %9
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %101
96: ; preds = %93
%97 = load i32*, i32** %7
%98 = load i8*, i8** %9
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %98)
%100 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %100, i8** %9
br label %93
101: ; preds = %93
br label %102
102: ; preds = %101, %89
br label %14
103: ; preds = %14
%104 = load i32*, i32** %6
%105 = call i32 @fclose(i32* %104)
%106 = load i32*, i32** %7
%107 = call i32 @fclose(i32* %106)
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c" ,\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @lex(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %51, label %9
9: ; preds = %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
br label %11
11: ; preds = %9, %48
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 46
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = load i8, i8* %10
switch i8 %15, label %26 [
i8 111, label %16
i8 105, label %16
i8 104, label %16
i8 102, label %16
i8 100, label %16
i8 98, label %16
]
16: ; preds = %14, %14, %14, %14, %14, %14
%17 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %24, label %19
19: ; preds = %16, %19
%20 = phi i8* [ %22, %19 ], [ %17, %16 ]
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %19
24: ; preds = %19, %16
%25 = load i8, i8* %10
br label %26
26: ; preds = %24, %14
%27 = phi i8 [ %25, %24 ], [ %15, %14 ]
%28 = icmp eq i8 %27, 97
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %37, label %32
32: ; preds = %29, %32
%33 = phi i8* [ %35, %32 ], [ %30, %29 ]
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %32
37: ; preds = %32, %29
%38 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* %6)
br label %48
40: ; preds = %11
%41 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i8* %41, null
br i1 %42, label %48, label %43
43: ; preds = %40, %43
%44 = phi i8* [ %46, %43 ], [ %41, %40 ]
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %43
48: ; preds = %43, %40, %26, %37
%49 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %11
51: ; preds = %48, %2
%52 = call i32 @fclose(i32* %4)
%53 = call i32 @fclose(i32* %5)
ret i32 undef
}