#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int remove_database(char *data) {
  FILE *fp, *gp;
  char database[128], file[256];
  int d, i = 0;
  fp = fopen("Database/database.txt", "r");
  gp = fopen("Database/.database_temp.txt", "w");
  while ((d = fscanf(fp, " %[^\n]s", database)) && d != EOF) {
    if (strcmp(database, data))
      fprintf(gp, "%s\n", database);
    i++;
  }
  fclose(fp);
  fclose(gp);
  remove("Database/database.txt");
  rename("Database/.database_temp.txt", "Database/database.txt");
  strcpy(database, "Database/");
  strcat(database, data);
  strcpy(file, database);
  strcat(file, "_teacher");
  remove(file);
  strcpy(file, database);
  strcat(file, "_subject");
  remove(file);
  strcpy(file, database);
  strcat(file, "_batch");
  remove(file);
  strcpy(file, database);
  strcat(file, "_room");
  remove(file);
  return 1;
}


x86 assembly (clang, -O0):
<remove_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1a8(%rbp)
lea    0xe50(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe4f(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xe4b(%rip),%rsi
call   1060 <fscanf@plt>
mov    %eax,%ecx
mov    %ecx,-0x1a4(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a9(%rbp)
je     121f <remove_database+0x8f>
mov    -0x1a4(%rbp),%eax
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x1a9(%rbp)
mov    -0x1a9(%rbp),%al
test   $0x1,%al
jne    1232 <remove_database+0xa2>
jmp    1277 <remove_database+0xe7>
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1263 <remove_database+0xd3>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xdde(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11d7 <remove_database+0x47>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xd70(%rip),%rdi
call   1030 <remove@plt>
lea    0xd7a(%rip),%rdi
lea    0xd5d(%rip),%rsi
call   10a0 <rename@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10b0 <strcat@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xd0c(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xce1(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <remove@plt>
mov    $0x1,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_database>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x188,%rsp
mov    %rdi,%r14
lea    0xe55(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0xe55(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xe5d(%rip),%rsi
mov    %rsp,%rdx
mov    %r12,%rdi
call   1060 <fscanf@plt>
test   %eax,%eax
je     1239 <remove_database+0xa9>
mov    0x2dfb(%rip),%rbp
cmp    0x0(%rbp),%eax
je     1239 <remove_database+0xa9>
mov    %rsp,%rbx
lea    0xe38(%rip),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1222 <remove_database+0x92>
mov    %r15,%rdi
lea    0xe22(%rip),%rsi
mov    %rbx,%rdx
call   1080 <fprintf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
test   %eax,%eax
je     1239 <remove_database+0xa9>
cmp    0x0(%rbp),%eax
jne    1200 <remove_database+0x70>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xdb0(%rip),%rbx
mov    %rbx,%rdi
call   1030 <remove@plt>
lea    0xdb7(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <rename@plt>
lea    0xdd2(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xdac(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xd93(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xd7a(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xd5f(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    $0x1,%eax
add    $0x188,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Database/database.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Database/.database_temp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c" %[^\0A]s\00"
@EOF = global i32 0
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [10 x i8] c"Database/\00"
@.str.7 = [9 x i8] c"_teacher\00"
@.str.8 = [9 x i8] c"_subject\00"
@.str.9 = [7 x i8] c"_batch\00"
@.str.10 = [6 x i8] c"_room\00"
define i32 @remove_database(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [128 x i8]
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
%10 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %4
br label %11
11: ; preds = %31, %1
%12 = load i32*, i32** %3
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %13)
store i32 %14, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %7
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br label %20
20: ; preds = %16, %11
%21 = phi i1 [ false, %11 ], [ %19, %16 ]
br i1 %21, label %22, label %34
22: ; preds = %20
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%24 = load i8*, i8** %2
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32*, i32** %4
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%30 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %22
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %11
34: ; preds = %20
%35 = load i32*, i32** %3
%36 = call i32 @fclose(i32* %35)
%37 = load i32*, i32** %4
%38 = call i32 @fclose(i32* %37)
%39 = call i32 @remove(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%40 = call i32 @rename(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%44 = load i8*, i8** %2
%45 = call i32 @strcat(i8* %43, i8* %44)
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%52 = call i32 @remove(i8* %51)
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%55 = call i32 @strcpy(i8* %53, i8* %54)
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%59 = call i32 @remove(i8* %58)
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%62 = call i32 @strcpy(i8* %60, i8* %61)
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%66 = call i32 @remove(i8* %65)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%69 = call i32 @strcpy(i8* %67, i8* %68)
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%71 = call i32 @strcat(i8* %70, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%73 = call i32 @remove(i8* %72)
ret i32 1
}

LLVM IR (-O2):
@.str = [22 x i8] c"Database/database.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Database/.database_temp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c" %[^\0A]s\00"
@EOF = global i32 0
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [10 x i8] c"Database/\00"
@.str.7 = [9 x i8] c"_teacher\00"
@.str.8 = [9 x i8] c"_subject\00"
@.str.9 = [7 x i8] c"_batch\00"
@.str.10 = [6 x i8] c"_room\00"
define i32 @remove_database(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%9 = icmp ne i32 %8, 0
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %8, %10
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %24
13: ; preds = %1, %18
%14 = call i64 @strcmp(i8* %4, i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %18
18: ; preds = %16, %13
%19 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%20 = icmp ne i32 %19, 0
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %19, %21
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %13, label %24
24: ; preds = %18, %1
%25 = call i32 @fclose(i32* %6)
%26 = call i32 @fclose(i32* %7)
%27 = call i32 @remove(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @rename(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 @strcat(i8* %4, i8* %0)
%31 = call i32 @strcpy(i8* %5, i8* %4)
%32 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @remove(i8* %5)
%34 = call i32 @strcpy(i8* %5, i8* %4)
%35 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 @remove(i8* %5)
%37 = call i32 @strcpy(i8* %5, i8* %4)
%38 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%39 = call i32 @remove(i8* %5)
%40 = call i32 @strcpy(i8* %5, i8* %4)
%41 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%42 = call i32 @remove(i8* %5)
ret i32 1
}