#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *gettitle(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strtok(char *, char *);
main() {
  FILE *fp, *tmp;
  char buf[256], name[256];
  char *ptr;
  fp = fopen(".Names", "r");
  if (!fp)
    return -1;
  while (fgets(buf, sizeof(buf), fp)) {
    if (strncmp(buf, "Name=M.", 7)) {
      printf("%s", buf);
      continue;
    }
    ptr = strchr(buf + 7, '.');
    if (!ptr) {
      printf("%s", buf);
      continue;
    }
    strcpy(name, buf + 5);
    strtok(name, "\n");
    strtok(name, " ");
    tmp = fopen(name, "r");
    if (!tmp) {
      printf("%s", buf);
      continue;
    }
    if ((ptr = gettitle(tmp))) {
      fclose(tmp);
      printf("Name=%s", ptr);
      continue;
    } else {
      printf("%s", buf);
      continue;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe57(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d0 <main+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1b1>
jmp    11d5 <main+0x45>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     133a <main+0x1aa>
lea    -0x120(%rbp),%rdi
lea    0xe07(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     122e <main+0x9e>
lea    -0x120(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1070 <printf@plt>
jmp    11d5 <main+0x45>
lea    -0x120(%rbp),%rdi
add    $0x7,%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
mov    %rax,-0x228(%rbp)
cmpq   $0x0,-0x228(%rbp)
jne    1270 <main+0xe0>
lea    -0x120(%rbp),%rsi
lea    0xdb4(%rip),%rdi
call   1070 <printf@plt>
jmp    11d5 <main+0x45>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
add    $0x5,%rsi
call   1040 <strcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xd7c(%rip),%rsi
call   10b0 <strtok@plt>
lea    -0x220(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   10b0 <strtok@plt>
lea    -0x220(%rbp),%rdi
lea    0xd4c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12e7 <main+0x157>
lea    -0x120(%rbp),%rsi
lea    0xd3d(%rip),%rdi
call   1070 <printf@plt>
jmp    11d5 <main+0x45>
mov    -0x18(%rbp),%rdi
call   1090 <gettitle@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
je     1322 <main+0x192>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x228(%rbp),%rsi
lea    0xcfd(%rip),%rdi
call   1070 <printf@plt>
jmp    11d5 <main+0x45>
lea    -0x120(%rbp),%rsi
lea    0xcea(%rip),%rdi
call   1070 <printf@plt>
jmp    11d5 <main+0x45>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe58(%rip),%rdi
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12de <main+0x14e>
mov    %rax,%r13
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     12e7 <main+0x157>
lea    0xe27(%rip),%rbp
mov    %rsp,%r14
lea    0xe2e(%rip),%r15
jmp    1214 <main+0x84>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12e5 <main+0x155>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11f0 <main+0x60>
lea    0x7(%rsp),%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11f0 <main+0x60>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
lea    0x5(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
lea    0xdb5(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rbx,%rdi
lea    0xda8(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rbx,%rdi
lea    0xd8d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %rax,%r12
mov    %r15,%rbx
mov    %rax,%rdi
call   1090 <gettitle@plt>
test   %rax,%rax
je     12c4 <main+0x134>
mov    %rax,%r15
mov    %r12,%rdi
call   1050 <fclose@plt>
lea    0xd68(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
mov    %rbx,%r15
lea    0xd4a(%rip),%rbp
jmp    11fb <main+0x6b>
mov    %rbx,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
lea    0xd30(%rip),%rbp
jmp    11fb <main+0x6b>
mov    $0xffffffff,%ecx
jmp    12e7 <main+0x157>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c".Names\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"Name=M.\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [8 x i8] c"Name=%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca i8*
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %0
store i32 -1, i32* %1
br label %62
11: ; preds = %0
br label %12
12: ; preds = %58, %53, %46, %30, %21, %11
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i64 @fgets(i8* %13, i32 256, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %61
17: ; preds = %12
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %12
24: ; preds = %17
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%26 = getelementptr inbounds i8, i8* %25, i64 7
%27 = call i8* @strchr(i8* %26, i8 signext 46)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = icmp ne i8* %28, null
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %12
33: ; preds = %24
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 5
%37 = call i32 @strcpy(i8* %34, i8* %36)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%39 = call i32 @strtok(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%41 = call i32 @strtok(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %43, i32** %3
%44 = load i32*, i32** %3
%45 = icmp ne i32* %44, null
br i1 %45, label %49, label %46
46: ; preds = %33
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %47)
br label %12
49: ; preds = %33
%50 = load i32*, i32** %3
%51 = call i8* @gettitle(i32* %50)
store i8* %51, i8** %6
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32*, i32** %3
%55 = call i32 @fclose(i32* %54)
%56 = load i8*, i8** %6
%57 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %56)
br label %12
58: ; preds = %49
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%60 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %59)
br label %12
61: ; preds = %12
store i32 0, i32* %1
br label %62
62: ; preds = %61, %10
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [7 x i8] c".Names\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"Name=M.\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [8 x i8] c"Name=%s\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %42, label %7
7: ; preds = %0
%8 = call i64 @fgets(i8* %3, i32 256, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %42, label %10
10: ; preds = %7
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 7
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 5
br label %13
13: ; preds = %10, %18
%14 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %16, %24, %32, %37, %40
%19 = call i64 @fgets(i8* %3, i32 256, i32* %5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %42, label %13
21: ; preds = %13
%22 = call i8* @strchr(i8* %11, i8 signext 46)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
26: ; preds = %21
%27 = call i32 @strcpy(i8* %4, i8* %12)
%28 = call i32 @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
34: ; preds = %26
%35 = call i8* @gettitle(i32* %30)
%36 = icmp eq i8* %35, null
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = call i32 @fclose(i32* %30)
%39 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %35)
br label %18
40: ; preds = %34
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
42: ; preds = %18, %7, %0
%43 = phi i32 [ -1, %0 ], [ 0, %7 ], [ 0, %18 ]
ret i32 %43
}