#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int dosya_cek(char *dir) {
  char b[50000];
  FILE *file1;
  file1 = fopen(dir, "r");
  int i = 0;
  while (fgets(b, 50000, file1) != NULL) {
    b[strlen(b) - 1] = 0;
    char kom1[1100] = "";
    strcpy(kom1, "cp -pf ");
    strcat(kom1, b);
    strcat(kom1, " ~/.repack");
    strcat(kom1, b);
    strcat(kom1, " 2> /dev/null");
    char kom2[1100] = "";
    char *bolu = "/";
    while (b[strlen(b) - 1] != bolu[0]) {
      b[strlen(b) - 1] = 0;
    }
    strcpy(kom2, "mkdir -p");
    strcat(kom2, " ~/.repack");
    strcat(kom2, b);
    system(kom2);
    system(kom1);
    i++;
  }
  return i;
}


x86 assembly (clang, -O0):
<dosya_cek>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcc20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xc368(%rbp)
movl   $0x0,-0xc36c(%rbp)
lea    -0xc360(%rbp),%rdi
mov    -0xc368(%rbp),%rdx
mov    $0xc350,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     131c <dosya_cek+0x1ac>
lea    -0xc360(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xc360(%rbp,%rax,1)
lea    -0xc7c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x44c,%edx
call   1060 <memset@plt>
lea    -0xc7c0(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xc7c0(%rbp),%rdi
lea    -0xc360(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0xc7c0(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xc7c0(%rbp),%rdi
lea    -0xc360(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0xc7c0(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xcc10(%rbp),%rdi
xor    %esi,%esi
mov    $0x44c,%edx
call   1060 <memset@plt>
lea    0xdbc(%rip),%rax
mov    %rax,-0xcc18(%rbp)
lea    -0xc360(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xc360(%rbp,%rax,1),%eax
ff
mov    -0xcc18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12b7 <dosya_cek+0x147>
lea    -0xc360(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xc360(%rbp,%rax,1)
jmp    126e <dosya_cek+0xfe>
lea    -0xcc10(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xcc10(%rbp),%rdi
lea    0xd32(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xcc10(%rbp),%rdi
lea    -0xc360(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0xcc10(%rbp),%rdi
call   1050 <system@plt>
lea    -0xc7c0(%rbp),%rdi
call   1050 <system@plt>
mov    -0xc36c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc36c(%rbp)
jmp    11a0 <dosya_cek+0x30>
mov    -0xc36c(%rbp),%eax
add    $0xcc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dosya_cek>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xcbf8,%rsp
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0x8a0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc350,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12b6 <dosya_cek+0x146>
lea    0x450(%rsp),%r15
lea    0xe48(%rip),%r13
mov    %rsp,%r12
jmp    1221 <dosya_cek+0xb1>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
lea    0xe49(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %r12,%rdi
call   1050 <system@plt>
mov    %r15,%rdi
call   1050 <system@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0xc350,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12b6 <dosya_cek+0x146>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    $0x44c,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r15,%rdi
lea    0xdb9(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
lea    0xd9c(%rip),%rsi
call   1090 <strcat@plt>
mov    $0x44c,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     11d0 <dosya_cek+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    1290 <dosya_cek+0x120>
mov    %ebp,%eax
add    $0xcbf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"cp -pf \00"
@.str.2 = [11 x i8] c" ~/.repack\00"
@.str.3 = [14 x i8] c" 2> /dev/null\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [9 x i8] c"mkdir -p\00"
define i32 @dosya_cek(i8* %0) {
%2 = alloca i8*
%3 = alloca [50000 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [1100 x i8]
%7 = alloca [1100 x i8]
%8 = alloca i8*
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
store i32 0, i32* %5
br label %11
11: ; preds = %55, %1
%12 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i32* @fgets(i8* %12, i32 50000, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %69
16: ; preds = %11
%17 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
%22 = bitcast [1100 x i8]* %6 to i8*
%23 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%30 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%31 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%35 = bitcast [1100 x i8]* %7 to i8*
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %36
36: ; preds = %49, %16
%37 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = load i8*, i8** %8
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %43, %47
br i1 %48, label %49, label %55
49: ; preds = %36
%50 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 %53
store i8 0, i8* %54
br label %36
55: ; preds = %36
%56 = getelementptr inbounds [1100 x i8], [1100 x i8]* %7, i64 0, i64 0
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%58 = getelementptr inbounds [1100 x i8], [1100 x i8]* %7, i64 0, i64 0
%59 = call i32 @strcat(i8* %58, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%60 = getelementptr inbounds [1100 x i8], [1100 x i8]* %7, i64 0, i64 0
%61 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%62 = call i32 @strcat(i8* %60, i8* %61)
%63 = getelementptr inbounds [1100 x i8], [1100 x i8]* %7, i64 0, i64 0
%64 = call i32 @system(i8* %63)
%65 = getelementptr inbounds [1100 x i8], [1100 x i8]* %6, i64 0, i64 0
%66 = call i32 @system(i8* %65)
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %11
69: ; preds = %11
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"cp -pf \00"
@.str.2 = [11 x i8] c" ~/.repack\00"
@.str.3 = [14 x i8] c" 2> /dev/null\00"
@.str.5 = [9 x i8] c"mkdir -p\00"
define i32 @dosya_cek(i8* nocapture %0) {
%2 = alloca [50000 x i8]
%3 = alloca [1100 x i8]
%4 = alloca [1100 x i8]
%5 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32* @fgets(i8* %5, i32 50000, i32* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %49, label %9
9: ; preds = %1
%10 = getelementptr inbounds [1100 x i8], [1100 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [1100 x i8], [1100 x i8]* %4, i64 0, i64 0
br label %12
12: ; preds = %9, %40
%13 = phi i32 [ 0, %9 ], [ %46, %40 ]
%14 = call i32 @strlen(i8* %5)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @strcat(i8* %10, i8* %5)
%20 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @strcat(i8* %10, i8* %5)
%22 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @strlen(i8* %5)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 47
br i1 %28, label %40, label %29
29: ; preds = %12, %29
%30 = call i32 @strlen(i8* %5)
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 @strlen(i8* %5)
%35 = add nsw i32 %34, -1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 47
br i1 %39, label %40, label %29
40: ; preds = %29, %12
%41 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @strcat(i8* %11, i8* %5)
%44 = call i32 @system(i8* %11)
%45 = call i32 @system(i8* %10)
%46 = add nuw nsw i32 %13, 1
%47 = call i32* @fgets(i8* %5, i32 50000, i32* %6)
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %12
49: ; preds = %40, %1
%50 = phi i32 [ 0, %1 ], [ %46, %40 ]
ret i32 %50
}