#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*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ *OPEN(char *);
int /*<<< orphan*/ copy(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
char *modify_file(char *);
int /*<<< orphan*/ printf(char *, ...);
filelist() {
  FILE *LISTFILE;
  FILE *INFILE;
  LISTFILE = OPEN(modify_file("gen.tkn"));
  if (LISTFILE == NULL) {
    printf("cannot open gen.tkn\n");
    exit(1);
  }
  for (;;) {
    char name[500];
    char *p;
    int ch;
    ch = fgetc(LISTFILE);
    while (ch == '\n' || ch == ' ')
      ch = fgetc(LISTFILE);
    if (ch == EOF)
      break;
    p = &name[0];
    while (('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') ||
           ('0' <= ch && ch <= '9') || ch == '_') {
      *p++ = ch;
      ch = fgetc(LISTFILE);
    }
    *p++ = '.';
    *p++ = 't';
    *p = '\0';
    INFILE = OPEN(name);
    if (INFILE == NULL) {
      printf("cannot open %s\n", name);
      exit(1);
    } else {
      copy(INFILE);
      fclose(INFILE);
    }
  }
  fclose(LISTFILE);
}


x86 assembly (clang, -O0):
<filelist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    0xe7e(%rip),%rdi
call   1070 <modify_file@plt>
mov    %rax,%rdi
call   1030 <OPEN@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b6 <filelist+0x46>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11bb <filelist+0x4b>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x21c(%rbp)
mov    $0x1,%al
cmpl   $0xa,-0x21c(%rbp)
mov    %al,-0x21d(%rbp)
je     11ef <filelist+0x7f>
cmpl   $0x20,-0x21c(%rbp)
sete   %al
mov    %al,-0x21d(%rbp)
mov    -0x21d(%rbp),%al
test   $0x1,%al
jne    1202 <filelist+0x92>
jmp    1216 <filelist+0xa6>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x21c(%rbp)
jmp    11ca <filelist+0x5a>
mov    -0x21c(%rbp),%eax
mov    0x2dc5(%rip),%rcx
cmp    (%rcx),%eax
jne    1230 <filelist+0xc0>
jmp    1391 <filelist+0x221>
lea    -0x210(%rbp),%rax
mov    %rax,-0x218(%rbp)
mov    $0x41,%eax
cmp    -0x21c(%rbp),%eax
jg     1264 <filelist+0xf4>
mov    $0x1,%al
cmpl   $0x5a,-0x21c(%rbp)
mov    %al,-0x21e(%rbp)
jle    12c0 <filelist+0x150>
mov    $0x61,%eax
cmp    -0x21c(%rbp),%eax
jg     128a <filelist+0x11a>
mov    $0x1,%al
cmpl   $0x7a,-0x21c(%rbp)
mov    %al,-0x21e(%rbp)
jle    12c0 <filelist+0x150>
mov    $0x30,%eax
cmp    -0x21c(%rbp),%eax
jg     12b0 <filelist+0x140>
mov    $0x1,%al
cmpl   $0x39,-0x21c(%rbp)
mov    %al,-0x21e(%rbp)
jle    12c0 <filelist+0x150>
cmpl   $0x5f,-0x21c(%rbp)
sete   %al
mov    %al,-0x21e(%rbp)
mov    -0x21e(%rbp),%al
test   $0x1,%al
jne    12d3 <filelist+0x163>
jmp    1306 <filelist+0x196>
mov    -0x21c(%rbp),%eax
mov    %al,%cl
mov    -0x218(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x218(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x21c(%rbp)
jmp    123e <filelist+0xce>
mov    -0x218(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x218(%rbp)
movb   $0x2e,(%rax)
mov    -0x218(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x218(%rbp)
movb   $0x74,(%rax)
mov    -0x218(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x210(%rbp),%rdi
call   1030 <OPEN@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    137a <filelist+0x20a>
lea    -0x210(%rbp),%rsi
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1080 <copy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11bb <filelist+0x4b>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filelist>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0xe85(%rip),%rdi
call   1080 <modify_file@plt>
mov    %rax,%rdi
call   1030 <OPEN@plt>
test   %rax,%rax
je     1267 <filelist+0xe7>
mov    %rax,%r13
mov    0x2e31(%rip),%r12
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1070 <fgetc@plt>
cmp    $0xa,%eax
je     11c0 <filelist+0x40>
cmp    $0x20,%eax
je     11c0 <filelist+0x40>
cmp    (%r12),%eax
je     1233 <filelist+0xb3>
mov    %r14,%rbx
jmp    11ee <filelist+0x6e>
nopl   (%rax)
mov    %al,(%rbx)
add    $0x1,%rbx
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ecx
and    $0xffffffdf,%ecx
add    $0xffffffbf,%ecx
cmp    $0x1a,%ecx
jb     11e0 <filelist+0x60>
lea    -0x30(%rax),%ecx
cmp    $0x5f,%eax
je     11e0 <filelist+0x60>
cmp    $0x9,%ecx
jbe    11e0 <filelist+0x60>
movw   $0x742e,(%rbx)
movb   $0x0,0x2(%rbx)
mov    %r14,%rdi
call   1030 <OPEN@plt>
test   %rax,%rax
je     124c <filelist+0xcc>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <copy@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
jmp    11c0 <filelist+0x40>
mov    %r13,%rdi
call   1050 <fclose@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xdad(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xda2(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"gen.tkn\00"
@.str.1 = [21 x i8] c"cannot open gen.tkn\0A\00"
@EOF = global i32 0
@.str.2 = [16 x i8] c"cannot open %s\0A\00"
define i32 @filelist() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [500 x i8]
%5 = alloca i8*
%6 = alloca i32
%7 = call i8* @modify_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = call i32* @OPEN(i8* %7)
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
br label %15
15: ; preds = %85, %14
%16 = load i32*, i32** %2
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %6
br label %18
18: ; preds = %26, %15
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 10
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 32
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ true, %18 ], [ %23, %21 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32*, i32** %2
%28 = call i32 @fgetc(i32* %27)
store i32 %28, i32* %6
br label %18
29: ; preds = %24
%30 = load i32, i32* %6
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %86
34: ; preds = %29
%35 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
store i8* %35, i8** %5
br label %36
36: ; preds = %59, %34
%37 = load i32, i32* %6
%38 = icmp sle i32 65, %37
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %6
%41 = icmp sle i32 %40, 90
br i1 %41, label %57, label %42
42: ; preds = %39, %36
%43 = load i32, i32* %6
%44 = icmp sle i32 97, %43
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %6
%47 = icmp sle i32 %46, 122
br i1 %47, label %57, label %48
48: ; preds = %45, %42
%49 = load i32, i32* %6
%50 = icmp sle i32 48, %49
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp sle i32 %52, 57
br i1 %53, label %57, label %54
54: ; preds = %51, %48
%55 = load i32, i32* %6
%56 = icmp eq i32 %55, 95
br label %57
57: ; preds = %54, %51, %45, %39
%58 = phi i1 [ true, %51 ], [ true, %45 ], [ true, %39 ], [ %56, %54 ]
br i1 %58, label %59, label %66
59: ; preds = %57
%60 = load i32, i32* %6
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %5
store i8 %61, i8* %62
%64 = load i32*, i32** %2
%65 = call i32 @fgetc(i32* %64)
store i32 %65, i32* %6
br label %36
66: ; preds = %57
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %5
store i8 46, i8* %67
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %5
store i8 116, i8* %69
%71 = load i8*, i8** %5
store i8 0, i8* %71
%72 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%73 = call i32* @OPEN(i8* %72)
store i32* %73, i32** %3
%74 = load i32*, i32** %3
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %80
76: ; preds = %66
%77 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %66
%81 = load i32*, i32** %3
%82 = call i32 @copy(i32* %81)
%83 = load i32*, i32** %3
%84 = call i32 @fclose(i32* %83)
br label %85
85: ; preds = %80
br label %15
86: ; preds = %33
%87 = load i32*, i32** %2
%88 = call i32 @fclose(i32* %87)
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@.str = [8 x i8] c"gen.tkn\00"
@EOF = global i32 0
@.str.2 = [16 x i8] c"cannot open %s\0A\00"
@str = [20 x i8] c"cannot open gen.tkn\00"
define i32 @filelist() {
%1 = alloca [500 x i8]
%2 = tail call i8* @modify_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32* @OPEN(i8* %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
br label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5, %40
br label %11
11: ; preds = %13, %10
%12 = call i32 @fgetc(i32* %3)
switch i32 %12, label %14 [
i32 32, label %13
i32 10, label %13
]
13: ; preds = %11, %11
br label %11
14: ; preds = %11
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %12, %15
br i1 %16, label %43, label %17
17: ; preds = %14, %28
%18 = phi i8* [ %30, %28 ], [ %6, %14 ]
%19 = phi i32 [ %31, %28 ], [ %12, %14 ]
%20 = and i32 %19, -33
%21 = add i32 %20, -65
%22 = icmp ult i32 %21, 26
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = add i32 %19, -48
%25 = icmp ult i32 %24, 10
%26 = icmp eq i32 %19, 95
%27 = or i1 %26, %25
br i1 %27, label %28, label %32
28: ; preds = %23, %17
%29 = trunc i32 %19 to i8
%30 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %29, i8* %18
%31 = call i32 @fgetc(i32* %3)
br label %17
32: ; preds = %23
%33 = getelementptr inbounds i8, i8* %18, i64 1
store i8 46, i8* %18
%34 = getelementptr inbounds i8, i8* %18, i64 2
store i8 116, i8* %33
store i8 0, i8* %34
%35 = call i32* @OPEN(i8* %6)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = call i32 @copy(i32* %35)
%42 = call i32 @fclose(i32* %35)
br label %10
43: ; preds = %14
%44 = call i32 @fclose(i32* %3)
ret i32 undef
}