#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main() {
  system("ls *.log > /tmp/ls_dump.txt");
  system("echo `printf ''` > /tmp/add_line.txt");
  system("cat /tmp/ls_dump.txt /tmp/add_line.txt > /tmp/temp_dump.txt; mv "
         "/tmp/temp_dump.txt /tmp/ls_dump.txt");
  FILE *ls_dump;
  ls_dump = fopen("/tmp/ls_dump.txt", "r");
  char log_file[200];
  while (!feof(ls_dump) && log_file != "") {
    fgets(log_file, 200, ls_dump);
    log_file[strlen(log_file) - 1] = '\0';
    char sys_arg[200] = "grep 'error =' ";
    strcat(sys_arg, log_file);
    strcat(sys_arg, " | wc -l ");
    char sys_echo[200] = "echo ";
    strcat(sys_echo, log_file);
    system(sys_echo);
    system(sys_arg);
  }
  printf("yooyoyoyoyo\n");
  fclose(ls_dump);
  system("rm /tmp/ls_dump.txt; rm /tmp/add_line.txt");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe47(%rip),%rdi
call   1050 <system@plt>
lea    0xe57(%rip),%rdi
call   1050 <system@plt>
lea    0xe70(%rip),%rdi
call   1050 <system@plt>
lea    0xe2e(%rip),%rdi
lea    0xec1(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x281(%rbp)
jne    1223 <main+0x83>
lea    -0xe0(%rbp),%rax
lea    0xea6(%rip),%rcx
cmp    %rcx,%rax
setne  %al
mov    %al,-0x281(%rbp)
mov    -0x281(%rbp),%al
test   $0x1,%al
jne    1236 <main+0x96>
jmp    1308 <main+0x168>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc8,%esi
call   1080 <fgets@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0x1b0(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0xc8,%edx
call   10a0 <memcpy@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   10c0 <strcat@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x280(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1070 <memset@plt>
movb   $0x65,-0x280(%rbp)
movb   $0x63,-0x27f(%rbp)
movb   $0x68,-0x27e(%rbp)
movb   $0x6f,-0x27d(%rbp)
movb   $0x20,-0x27c(%rbp)
lea    -0x280(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   10c0 <strcat@plt>
lea    -0x280(%rbp),%rdi
call   1050 <system@plt>
lea    -0x1b0(%rbp),%rdi
call   1050 <system@plt>
jmp    11ed <main+0x4d>
lea    0xda2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd9a(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x268,%rsp
lea    0xe58(%rip),%rdi
call   1060 <system@plt>
lea    0xe68(%rip),%rdi
call   1060 <system@plt>
lea    0xe81(%rip),%rdi
call   1060 <system@plt>
lea    0xe3f(%rip),%rdi
lea    0xed2(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12e2 <main+0x152>
lea    0x1a0(%rsp),%rbx
lea    0xef6(%rip),%r15
lea    0xd0(%rsp),%r12
lea    0xe9e(%rip),%r13
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    $0xc8,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <memcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10b0 <strcat@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0xc0(%rsp)
movl   $0x6f686365,(%rsp)
movb   $0x20,0x4(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10b0 <strcat@plt>
mov    %rbp,%rdi
call   1060 <system@plt>
mov    %r12,%rdi
call   1060 <system@plt>
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1210 <main+0x80>
lea    0xdf2(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xdb4(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"ls *.log > /tmp/ls_dump.txt\00"
@.str.1 = [37 x i8] c"echo `printf ''` > /tmp/add_line.txt\00"
@.str.2 = [100 x i8] c"cat /tmp/ls_dump.txt /tmp/add_line.txt > /tmp/temp_dump.txt; mv /tmp/temp_dump.txt /tmp/ls_dump.txt\00"
@.str.3 = [17 x i8] c"/tmp/ls_dump.txt\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [1 x i8] zeroinitializer
@__const.main.sys_arg = [200 x i8] c"grep 'error =' \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.6 = [10 x i8] c" | wc -l \00"
@.str.7 = [13 x i8] c"yooyoyoyoyo\0A\00"
@.str.8 = [42 x i8] c"rm /tmp/ls_dump.txt; rm /tmp/add_line.txt\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = alloca [200 x i8]
store i32 0, i32* %1
%6 = call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @system(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @system(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %9, i32** %2
br label %10
10: ; preds = %19, %0
%11 = load i32*, i32** %2
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%16 = icmp ne i8* %15, getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
br label %17
17: ; preds = %14, %10
%18 = phi i1 [ false, %10 ], [ %16, %14 ]
br i1 %18, label %19, label %48
19: ; preds = %17
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%21 = load i32*, i32** %2
%22 = call i32 @fgets(i8* %20, i32 200, i32* %21)
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = bitcast [200 x i8]* %4 to i8*
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%34 = bitcast [200 x i8]* %5 to i8*
%35 = bitcast i8* %34 to [200 x i8]*
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i32 0, i32 0
store i8 101, i8* %36
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i32 0, i32 1
store i8 99, i8* %37
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i32 0, i32 2
store i8 104, i8* %38
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i32 0, i32 3
store i8 111, i8* %39
%40 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i32 0, i32 4
store i8 32, i8* %40
%41 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%45 = call i32 @system(i8* %44)
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%47 = call i32 @system(i8* %46)
br label %10
48: ; preds = %17
%49 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%50 = load i32*, i32** %2
%51 = call i32 @fclose(i32* %50)
%52 = call i32 @system(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"ls *.log > /tmp/ls_dump.txt\00"
@.str.1 = [37 x i8] c"echo `printf ''` > /tmp/add_line.txt\00"
@.str.2 = [100 x i8] c"cat /tmp/ls_dump.txt /tmp/add_line.txt > /tmp/temp_dump.txt; mv /tmp/temp_dump.txt /tmp/ls_dump.txt\00"
@.str.3 = [17 x i8] c"/tmp/ls_dump.txt\00"
@.str.4 = [2 x i8] c"r\00"
@__const.main.sys_arg = [200 x i8] c"grep 'error =' \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.6 = [10 x i8] c" | wc -l \00"
@.str.8 = [42 x i8] c"rm /tmp/ls_dump.txt; rm /tmp/add_line.txt\00"
@str = [12 x i8] c"yooyoyoyoyo\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca [200 x i8]
%3 = alloca [200 x i8]
%4 = tail call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @system(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @system(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%9 = call i32 @feof(i32* %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %0
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 1
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 2
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 3
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 4
br label %18
18: ; preds = %11, %18
%19 = call i32 @fgets(i8* %8, i32 200, i32* %7)
%20 = call i32 @strlen(i8* %8)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @strcat(i8* %12, i8* %8)
%25 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
store i8 101, i8* %13
store i8 99, i8* %14
store i8 104, i8* %15
store i8 111, i8* %16
store i8 32, i8* %17
%26 = call i32 @strcat(i8* %13, i8* %8)
%27 = call i32 @system(i8* %13)
%28 = call i32 @system(i8* %12)
%29 = call i32 @feof(i32* %7)
%30 = icmp eq i32 %29, 0
br i1 %30, label %18, label %31
31: ; preds = %18, %0
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%33 = call i32 @fclose(i32* %7)
%34 = call i32 @system(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}