#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int main() {
  FILE *imageFile;
  FILE *imageInfoFile;
  FILE *allTagsFile;
  char tagsReader[1000];
  char htmlReader[1000];
  char infoReader[1000];
  char titleWriter[1000];
  char imagePath[500];
  allTagsFile = fopen("/home/jungtaek/workspace/"
                      "PageGenerator-for-ValualizeGraphic/"
                      "tags/"
                      "all.list",
                      "r");
  imageInfoFile = fopen("/home/jungtaek/workspace/"
                        "PageGenerator-for-ValualizeGraphic/"
                        "info/"
                        "all.info",
                        "r");
  while (fscanf(allTagsFile, "%s", tagsReader) != EOF) {
    fgets(infoReader, 1000, imageInfoFile);
    strcpy(imagePath, "/var/www/"
                      "graphic/"
                      "images/");
    strcat(imagePath, tagsReader);
    strcat(imagePath, ".html");
    imageFile = fopen(imagePath, "rb+");
    while (fgets(htmlReader, 1000, imageFile) != NULL) {
      if (strstr(htmlReader, "<title>") != NULL) {
        int i;
        i = strlen(infoReader);
        infoReader[i - 1] = '\0';
        strcpy(titleWriter, infoReader);
        strcat(titleWriter, " | Valualize Graphic\n</title>");
        fprintf(imageFile, "%s", titleWriter);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x11f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xec4(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%rax
je     12f4 <main+0x174>
lea    -0xbf0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
lea    -0x11e0(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x11e0(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x11e0(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x11e0(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x800(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12ef <main+0x16f>
lea    -0x800(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     12ea <main+0x16a>
lea    -0xbf0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x11e4(%rbp)
mov    -0x11e4(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0xbf0(%rbp,%rax,1)
lea    -0xfe0(%rbp),%rdi
lea    -0xbf0(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xfe0(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0xfe0(%rbp),%rdx
lea    0xdb1(%rip),%rsi
call   1070 <fprintf@plt>
jmp    124c <main+0xcc>
jmp    11c0 <main+0x40>
xor    %eax,%eax
add    $0x11f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x11c8,%rsp
lea    0xe68(%rip),%rdi
lea    0xeab(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,(%rsp)
lea    0xed2(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbp,0x8(%rsp)
mov    %rbp,%rdi
call   1060 <fscanf@plt>
mov    0x2e0b(%rip),%rcx
cmp    (%rcx),%rax
jne    11f6 <main+0x76>
xor    %eax,%eax
add    $0x11c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9f0(%rsp),%rbx
lea    0x10(%rsp),%r13
lea    0xde0(%rsp),%r12
lea    0xeaa(%rip),%r14
lea    0x600(%rsp),%r15
jmp    1245 <main+0xc5>
nopl   0x0(%rax)
mov    0x8(%rsp),%rdi
lea    0xe6a(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdx
call   1060 <fscanf@plt>
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%rax
je     11e2 <main+0x62>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    (%rsp),%rdx
call   1070 <fgets@plt>
lea    0x400(%rsp),%rbp
mov    %rbp,%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    %rbp,%rdi
lea    0xe30(%rip),%rsi
call   1090 <strcat@plt>
mov    %rbp,%rdi
lea    0xe33(%rip),%rbp
lea    0xe20(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
jmp    12bb <main+0x13b>
nopl   (%rax)
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r13,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1220 <main+0xa0>
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <strstr@plt>
test   %rax,%rax
je     12b0 <main+0x130>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <fputs@plt>
jmp    12b0 <main+0x130>

LLVM IR (-O0):
@.str = [74 x i8] c"/home/jungtaek/workspace/PageGenerator-for-ValualizeGraphic/tags/all.list\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [74 x i8] c"/home/jungtaek/workspace/PageGenerator-for-ValualizeGraphic/info/all.info\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.4 = [25 x i8] c"/var/www/graphic/images/\00"
@.str.5 = [6 x i8] c".html\00"
@.str.6 = [4 x i8] c"rb+\00"
@.str.7 = [8 x i8] c"<title>\00"
@.str.8 = [30 x i8] c" | Valualize Graphic\0A</title>\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
%8 = alloca [1000 x i8]
%9 = alloca [500 x i8]
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
%12 = call i32* @fopen(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
br label %13
13: ; preds = %57, %0
%14 = load i32*, i32** %4
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%16 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i64, i64* @EOF
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %58
19: ; preds = %13
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%21 = load i32*, i32** %3
%22 = call i32* @fgets(i8* %20, i32 1000, i32* %21)
%23 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
store i32* %31, i32** %2
br label %32
32: ; preds = %56, %19
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%34 = load i32*, i32** %2
%35 = call i32* @fgets(i8* %33, i32 1000, i32* %34)
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %57
37: ; preds = %32
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%39 = call i32* @strstr(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp ne i32* %39, null
br i1 %40, label %41, label %56
41: ; preds = %37
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %10
%44 = load i32, i32* %10
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %46
store i8 0, i8* %47
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%50 = call i32 @strcpy(i8* %48, i8* %49)
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%53 = load i32*, i32** %2
%54 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%55 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %41, %37
br label %32
57: ; preds = %32
br label %13
58: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [74 x i8] c"/home/jungtaek/workspace/PageGenerator-for-ValualizeGraphic/tags/all.list\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [74 x i8] c"/home/jungtaek/workspace/PageGenerator-for-ValualizeGraphic/info/all.info\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.4 = [25 x i8] c"/var/www/graphic/images/\00"
@.str.5 = [6 x i8] c".html\00"
@.str.6 = [4 x i8] c"rb+\00"
@.str.7 = [8 x i8] c"<title>\00"
@.str.8 = [30 x i8] c" | Valualize Graphic\0A</title>\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [500 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %42, label %20
16: ; preds = %39, %20
%17 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %42, label %20
20: ; preds = %0, %16
%21 = call i32* @fgets(i8* %8, i32 1000, i32* %12)
%22 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @strcat(i8* %10, i8* %6)
%24 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32* @fgets(i8* %7, i32 1000, i32* %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %16, label %28
28: ; preds = %20, %39
%29 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %39, label %31
31: ; preds = %28
%32 = call i32 @strlen(i8* %8)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %34
store i8 0, i8* %35
%36 = call i32 @strcpy(i8* %9, i8* %8)
%37 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @fputs(i8* %9, i32* %25)
br label %39
39: ; preds = %31, %28
%40 = call i32* @fgets(i8* %7, i32 1000, i32* %25)
%41 = icmp eq i32* %40, null
br i1 %41, label %16, label %28
42: ; preds = %16, %0
ret i32 0
}