#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*/ add_task(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ delete_task(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ file_exist();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ start(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ tasknum(int /*<<< orphan*/ *);
int /*<<< orphan*/ view_tasks(int /*<<< orphan*/ *);
int /*<<< orphan*/ weekly_reset(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main() {
  file_exist();
  FILE *fd, *out;
  weekly_reset(fd, out);
  char buf[100];
  tasknum(fd);
  putchar('\n');
  printf("\t\t\t\t--------------------------\n");
  printf("\t\t\t\t|-----Scheduler program-----|\n");
  printf("\t\t\t\t---------------------------\n");
  putchar('\n');
  printf("%% ");
  while (fgets(buf, 100, stdin) != NULL) {
    tasknum(fd);
    if (buf[strlen(buf) - 1 == '\n'])
      buf[strlen(buf) - 1] = 0;
    if (strcmp(buf, "start") == 0) {
      start(fd, out);
    } else if (strcmp(buf, "tasks") == 0) {
      view_tasks(fd);
    } else if (strcmp(buf, "add") == 0) {
      add_task(fd, out);
    } else if (strcmp(buf, "delete") == 0) {
      delete_task(fd, out);
    } else if (strcmp(buf, "exit") == 0) {
      exit(0);
    } else if (strcmp(buf, "clear") == 0) {
      clear();
    }
    printf("%% ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10e0 <file_exist@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <weekly_reset@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <tasknum@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde0(%rip),%rdi
call   1060 <printf@plt>
lea    0xdf4(%rip),%rdi
call   1060 <printf@plt>
lea    0xe0b(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe16(%rip),%rdi
call   1060 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     13cc <main+0x1ec>
mov    -0x10(%rbp),%rdi
call   10d0 <tasknum@plt>
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
cmpb   $0x0,-0x80(%rbp,%rax,1)
je     12b4 <main+0xd4>
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12e0 <main+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <start@plt>
jmp    13bb <main+0x1db>
lea    -0x80(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1308 <main+0x128>
mov    -0x10(%rbp),%rdi
call   1040 <view_tasks@plt>
jmp    13b6 <main+0x1d6>
lea    -0x80(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1334 <main+0x154>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <add_task@plt>
jmp    13b1 <main+0x1d1>
lea    -0x80(%rbp),%rdi
lea    0xd39(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1360 <main+0x180>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <delete_task@plt>
jmp    13ac <main+0x1cc>
lea    -0x80(%rbp),%rdi
lea    0xd14(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1381 <main+0x1a1>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    -0x80(%rbp),%rdi
lea    0xcf8(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    13a2 <main+0x1c2>
mov    $0x0,%al
call   1100 <clear@plt>
jmp    13a7 <main+0x1c7>
jmp    13ac <main+0x1cc>
jmp    13b1 <main+0x1d1>
jmp    13b6 <main+0x1d6>
jmp    13bb <main+0x1db>
lea    0xca2(%rip),%rdi
call   1060 <printf@plt>
jmp    1253 <main+0x73>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xor    %eax,%eax
call   10f0 <file_exist@plt>
call   10d0 <weekly_reset@plt>
call   10e0 <tasknum@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdb2(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d8e(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     138e <main+0x19e>
lea    0xd87(%rip),%r14
lea    0xd7c(%rip),%r15
lea    0xd7f(%rip),%r12
lea    0xd7e(%rip),%r13
jmp    12c6 <main+0xd6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   10c0 <start@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     138e <main+0x19e>
call   10e0 <tasknum@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
xor    %ecx,%ecx
cmp    $0xb,%eax
sete   %cl
cmpb   $0x0,(%rsp,%rcx,1)
je     12f0 <main+0x100>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12a0 <main+0xb0>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1370 <main+0x180>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     137a <main+0x18a>
mov    %rbx,%rdi
lea    0xcea(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1384 <main+0x194>
mov    %rbx,%rdi
lea    0xcdd(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     139f <main+0x1af>
mov    %rbx,%rdi
lea    0xcce(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12a5 <main+0xb5>
xor    %eax,%eax
call   1110 <clear@plt>
jmp    12a5 <main+0xb5>
nopl   0x0(%rax)
call   1050 <view_tasks@plt>
jmp    12a5 <main+0xb5>
call   1090 <add_task@plt>
jmp    12a5 <main+0xb5>
call   1080 <delete_task@plt>
jmp    12a5 <main+0xb5>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\09\09\09\09--------------------------\0A\00"
@.str.1 = [35 x i8] c"\09\09\09\09|-----Scheduler program-----|\0A\00"
@.str.2 = [33 x i8] c"\09\09\09\09---------------------------\0A\00"
@.str.3 = [4 x i8] c"%% \00"
@stdin = global i32 0
@.str.4 = [6 x i8] c"start\00"
@.str.5 = [6 x i8] c"tasks\00"
@.str.6 = [4 x i8] c"add\00"
@.str.7 = [7 x i8] c"delete\00"
@.str.8 = [5 x i8] c"exit\00"
@.str.9 = [6 x i8] c"clear\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [100 x i8]
store i32 0, i32* %1
%5 = call i32 (...) @file_exist()
%6 = load i32*, i32** %2
%7 = load i32*, i32** %3
%8 = call i32 @weekly_reset(i32* %6, i32* %7)
%9 = load i32*, i32** %2
%10 = call i32 @tasknum(i32* %9)
%11 = call i32 @putchar(i8 signext 10)
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @putchar(i8 signext 10)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %88, %0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32* @fgets(i8* %18, i32 100, i32 %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %90
22: ; preds = %17
%23 = load i32*, i32** %2
%24 = call i32 @tasknum(i32* %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = icmp eq i32 %27, 10
%29 = zext i1 %28 to i32
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = icmp ne i8 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %22
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %34, %22
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i32*, i32** %2
%46 = load i32*, i32** %3
%47 = call i32 @start(i32* %45, i32* %46)
br label %88
48: ; preds = %40
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32*, i32** %2
%54 = call i32 @view_tasks(i32* %53)
br label %87
55: ; preds = %48
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32*, i32** %2
%61 = load i32*, i32** %3
%62 = call i32 @add_task(i32* %60, i32* %61)
br label %86
63: ; preds = %55
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = load i32*, i32** %2
%69 = load i32*, i32** %3
%70 = call i32 @delete_task(i32* %68, i32* %69)
br label %85
71: ; preds = %63
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @exit(i32 0)
unreachable
77: ; preds = %71
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = call i32 (...) @clear()
br label %83
83: ; preds = %81, %77
br label %84
84: ; preds = %83
br label %85
85: ; preds = %84, %67
br label %86
86: ; preds = %85, %59
br label %87
87: ; preds = %86, %52
br label %88
88: ; preds = %87, %44
%89 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %17
90: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%% \00"
@stdin = global i32 0
@.str.4 = [6 x i8] c"start\00"
@.str.5 = [6 x i8] c"tasks\00"
@.str.6 = [4 x i8] c"add\00"
@.str.7 = [7 x i8] c"delete\00"
@.str.8 = [5 x i8] c"exit\00"
@.str.9 = [6 x i8] c"clear\00"
@str = [31 x i8] c"\09\09\09\09--------------------------\00"
@str.10 = [34 x i8] c"\09\09\09\09|-----Scheduler program-----|\00"
@str.11 = [32 x i8] c"\09\09\09\09---------------------------\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 (...) @file_exist()
%3 = tail call i32 @weekly_reset(i32* undef, i32* undef)
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = tail call i32 @tasknum(i32* undef)
%6 = tail call i32 @putchar(i8 signext 10)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.11, i64 0, i64 0))
%10 = tail call i32 @putchar(i8 signext 10)
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %4, i32 100, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %63, label %15
15: ; preds = %0, %58
%16 = call i32 @tasknum(i32* undef)
%17 = call i32 @strlen(i8* %4)
%18 = icmp eq i32 %17, 11
%19 = zext i1 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %15
%24 = call i32 @strlen(i8* %4)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %23, %15
%29 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @start(i32* undef, i32* undef)
br label %58
33: ; preds = %28
%34 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @view_tasks(i32* undef)
br label %58
38: ; preds = %33
%39 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @add_task(i32* undef, i32* undef)
br label %58
43: ; preds = %38
%44 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @delete_task(i32* undef, i32* undef)
br label %58
48: ; preds = %43
%49 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @exit(i32 0)
unreachable
53: ; preds = %48
%54 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (...) @clear()
br label %58
58: ; preds = %36, %46, %53, %56, %41, %31
%59 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32, i32* @stdin
%61 = call i32* @fgets(i8* %4, i32 100, i32 %60)
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %15
63: ; preds = %58, %0
ret i32 0
}