#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ GetFilPathForLot(char *, int, char *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ fstat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ *lotOpenFileNoCasheByLotNr(int, char *, char *, char,
                                              char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  FILE *fh;
  struct stat inode;
  char lotPath[512];
  char revindexPath[512];
  int i;
  if (argc != 3) {
    printf("usage: ./removeUnnecessaryRevindex lotNr subname\n");
    exit(1);
  }
  int lotNr = atoi(argv[1]);
  char *subname = argv[2];
  GetFilPathForLot(lotPath, lotNr, subname);
  if ((fh = lotOpenFileNoCasheByLotNr(lotNr, "reposetory", "rb", 'r',
                                      subname)) == NULL) {
    printf("dont have a reposetory\n");
    exit(1);
  }
  fstat(fileno(fh), &inode);
  if (inode.st_size < 2147483647) {
    printf("reposetory to smal\n");
    exit(1);
  }
  if ((fh = lotOpenFileNoCasheByLotNr(lotNr, "reposetory", "rb", 'r',
                                      subname)) == NULL) {
    printf("dont have a reposetory\n");
    exit(1);
  }
  for (i = 0; i < 64; i++) {
    sprintf(revindexPath, "%srevindex/Main/%i.txt", lotPath, i);
    printf("revindexPath %s\n", revindexPath);
    unlink(revindexPath);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11cb <main+0x3b>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x430(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x428(%rbp),%esi
mov    -0x430(%rbp),%rdx
call   1050 <GetFilPathForLot@plt>
mov    -0x428(%rbp),%edi
mov    -0x430(%rbp),%r8
lea    0xe18(%rip),%rsi
lea    0xe1c(%rip),%rdx
mov    $0x72,%ecx
call   1060 <lotOpenFileNoCasheByLotNr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1251 <main+0xc1>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   10b0 <fstat@plt>
cmpl   $0x7fffffff,-0x20(%rbp)
jge    128a <main+0xfa>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x428(%rbp),%edi
mov    -0x430(%rbp),%r8
lea    0xd94(%rip),%rsi
lea    0xd98(%rip),%rdx
mov    $0x72,%ecx
call   1060 <lotOpenFileNoCasheByLotNr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12d5 <main+0x145>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x424(%rbp)
cmpl   $0x40,-0x424(%rbp)
jge    1341 <main+0x1b1>
lea    -0x420(%rbp),%rdi
lea    -0x220(%rbp),%rdx
mov    -0x424(%rbp),%ecx
lea    0xd65(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x420(%rbp),%rsi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    12df <main+0x14f>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
cmp    $0x3,%edi
jne    12a8 <main+0x108>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rbx
lea    0x10(%rsp),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1060 <GetFilPathForLot@plt>
lea    0xe6a(%rip),%rsi
lea    0xe19(%rip),%rdx
mov    %ebp,%edi
mov    $0x72,%ecx
mov    %rbx,%r8
call   1070 <lotOpenFileNoCasheByLotNr@plt>
test   %rax,%rax
je     129f <main+0xff>
mov    %rax,%rdi
call   1080 <fileno@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   10c0 <fstat@plt>
cmpl   $0x7fffffff,0x8(%rsp)
7f
jne    12b1 <main+0x111>
lea    0xe22(%rip),%rsi
lea    0xdd1(%rip),%rdx
mov    %ebp,%edi
mov    $0x72,%ecx
mov    %rbx,%r8
call   1070 <lotOpenFileNoCasheByLotNr@plt>
test   %rax,%rax
je     129f <main+0xff>
lea    0xdb9(%rip),%r14
lea    0x210(%rsp),%rbp
lea    0x10(%rsp),%r15
lea    0xdbc(%rip),%r12
xor    %ebx,%ebx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1030 <unlink@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1260 <main+0xc0>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd98(%rip),%rdi
jmp    12b8 <main+0x118>
lea    0xda6(%rip),%rdi
jmp    12b8 <main+0x118>
lea    0xd73(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [50 x i8] c"usage: ./removeUnnecessaryRevindex lotNr subname\0A\00"
@.str.1 = [11 x i8] c"reposetory\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [24 x i8] c"dont have a reposetory\0A\00"
@.str.4 = [20 x i8] c"reposetory to smal\0A\00"
@.str.5 = [23 x i8] c"%srevindex/Main/%i.txt\00"
@.str.6 = [17 x i8] c"revindexPath %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.stat
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %11
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %12
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%27 = load i32, i32* %11
%28 = load i8*, i8** %12
%29 = call i32 @GetFilPathForLot(i8* %26, i32 %27, i8* %28)
%30 = load i32, i32* %11
%31 = load i8*, i8** %12
%32 = call i32* @lotOpenFileNoCasheByLotNr(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext 114, i8* %31)
store i32* %32, i32** %6
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %18
%38 = load i32*, i32** %6
%39 = call i32 @fileno(i32* %38)
%40 = call i32 @fstat(i32 %39, %struct.stat* %7)
%41 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%42 = load i32, i32* %41
%43 = icmp slt i32 %42, 2147483647
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %37
%48 = load i32, i32* %11
%49 = load i8*, i8** %12
%50 = call i32* @lotOpenFileNoCasheByLotNr(i32 %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext 114, i8* %49)
store i32* %50, i32** %6
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %47
store i32 0, i32* %10
br label %56
56: ; preds = %68, %55
%57 = load i32, i32* %10
%58 = icmp slt i32 %57, 64
br i1 %58, label %59, label %71
59: ; preds = %56
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%62 = load i32, i32* %10
%63 = call i32 @sprintf(i8* %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %61, i32 %62)
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%67 = call i32 @unlink(i8* %66)
br label %68
68: ; preds = %59
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %56
71: ; preds = %56
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str.1 = [11 x i8] c"reposetory\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.5 = [23 x i8] c"%srevindex/Main/%i.txt\00"
@.str.6 = [17 x i8] c"revindexPath %s\0A\00"
@str.7 = [19 x i8] c"reposetory to smal\00"
@str.8 = [23 x i8] c"dont have a reposetory\00"
@str.9 = [49 x i8] c"usage: ./removeUnnecessaryRevindex lotNr subname\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 3
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.9, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @GetFilPathForLot(i8* %7, i32 %16, i8* %18)
%20 = call i32* @lotOpenFileNoCasheByLotNr(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext 114, i8* %18)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = call i32 @fileno(i32* %20)
%27 = call i32 @fstat(i32 %26, %struct.stat* %3)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 2147483647
br i1 %30, label %34, label %31
31: ; preds = %25
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %25
%35 = call i32* @lotOpenFileNoCasheByLotNr(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext 114, i8* %18)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %34, %40
%41 = phi i32 [ %45, %40 ], [ 0, %34 ]
%42 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %7, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%44 = call i32 @unlink(i8* %8)
%45 = add nuw nsw i32 %41, 1
%46 = icmp eq i32 %45, 64
br i1 %46, label %47, label %40
47: ; preds = %40
ret i32 0
}