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

/* Variables and functions */
int /*<<< orphan*/ do_file(char *);
int /*<<< orphan*/ do_trailer();
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char **argv) {
  char filename[255];
  char *new_filename;
  while (fgets(filename, sizeof(filename), stdin)) {
    filename[strlen(filename) - 1] = '\0';
    if ((strlen(filename) > 2) && (filename[0] == '.') &&
        (filename[1] == '/')) {
      new_filename = filename + 2;
    } else {
      new_filename = filename;
    }
    do_file(new_filename);
  }
  do_trailer();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1201 <main+0xc1>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jle    11e2 <main+0xa2>
movsbl -0x110(%rbp),%eax
cmp    $0x2e,%eax
jne    11e2 <main+0xa2>
movsbl -0x10f(%rbp),%eax
cmp    $0x2f,%eax
jne    11e2 <main+0xa2>
lea    -0x110(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x118(%rbp)
jmp    11f0 <main+0xb0>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <do_file@plt>
jmp    1159 <main+0x19>
mov    $0x0,%al
call   1060 <do_trailer@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    0x2e95(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11c0 <main+0x80>
lea    0x2(%rsp),%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
movzbl (%rsp),%ecx
movzbl 0x1(%rsp),%edx
xor    $0x2e,%cl
xor    $0x2f,%dl
or     %cl,%dl
mov    %rbx,%rdi
cmove  %r15,%rdi
cmp    $0x3,%eax
cmovl  %rbx,%rdi
call   1030 <do_file@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    1170 <main+0x30>
xor    %eax,%eax
call   1060 <do_trailer@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %37, %2
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i64 @fgets(i8* %9, i32 255, i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %8
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp sgt i32 %20, 2
br i1 %21, label %22, label %35
22: ; preds = %13
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 46
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 47
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 2
store i8* %34, i8** %7
br label %37
35: ; preds = %27, %22, %13
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
store i8* %36, i8** %7
br label %37
37: ; preds = %35, %32
%38 = load i8*, i8** %7
%39 = call i32 @do_file(i8* %38)
br label %8
40: ; preds = %8
%41 = call i32 (...) @do_trailer()
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 255, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %29, label %8
8: ; preds = %2
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 1
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 2
br label %11
11: ; preds = %8, %11
%12 = call i32 @strlen(i8* %4)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @strlen(i8* %4)
%17 = icmp sgt i32 %16, 2
%18 = load i8, i8* %4
%19 = icmp eq i8 %18, 46
%20 = select i1 %17, i1 %19, i1 false
%21 = load i8, i8* %9
%22 = icmp eq i8 %21, 47
%23 = select i1 %20, i1 %22, i1 false
%24 = select i1 %23, i8* %10, i8* %4
%25 = call i32 @do_file(i8* %24)
%26 = load i32, i32* @stdin
%27 = call i64 @fgets(i8* %4, i32 255, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %11
29: ; preds = %11, %2
%30 = call i32 (...) @do_trailer()
ret i32 0
}