#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execlp(char *, char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
void clear() {
  pid_t pid;
  int status;
  char file[100];
  strcpy(file, "./clear.sh\0");
  if ((pid = fork()) < 0)
    perror("fork");
  else if (pid == 0) {
    execlp(file, file, (char *)0);
    perror("couldn't execute");
  }
  if ((pid = waitpid(pid, &status, 0)) < 0)
    perror("waitpid error");
  putchar('\n');
  printf("\t\t\t\t--------------------------\n");
  printf("\t\t\t\t|-----Scheduler program-----|\n");
  printf("\t\t\t\t---------------------------\n");
  putchar('\n');
}


x86 assembly (clang, -O0):
<clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jge    11ae <clear+0x3e>
lea    0xe68(%rip),%rdi
call   1070 <perror@plt>
jmp    11db <clear+0x6b>
cmpq   $0x0,-0x8(%rbp)
jne    11d6 <clear+0x66>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
lea    0xe40(%rip),%rdi
call   1070 <perror@plt>
jmp    11db <clear+0x6b>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jge    1204 <clear+0x94>
lea    0xe23(%rip),%rdi
call   1070 <perror@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear>:
push   %rbx
sub    $0x80,%rsp
lea    0xe81(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   1090 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
js     11ef <clear+0x7f>
je     11f8 <clear+0x88>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <waitpid@plt>
test   %rax,%rax
js     1215 <clear+0xa5>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe71(%rip),%rdi
call   1050 <puts@plt>
lea    0xe84(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x80,%rsp
pop    %rbx
ret
lea    0xe16(%rip),%rdi
jmp    120e <clear+0x9e>
lea    0x10(%rsp),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
lea    0xe03(%rip),%rdi
call   1070 <perror@plt>
jmp    119a <clear+0x2a>
lea    0xe06(%rip),%rdi
call   1070 <perror@plt>
jmp    11ae <clear+0x3e>

LLVM IR (-O0):
@.str = [12 x i8] c"./clear.sh\00\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [17 x i8] c"couldn't execute\00"
@.str.3 = [14 x i8] c"waitpid error\00"
@.str.4 = [32 x i8] c"\09\09\09\09--------------------------\0A\00"
@.str.5 = [35 x i8] c"\09\09\09\09|-----Scheduler program-----|\0A\00"
@.str.6 = [33 x i8] c"\09\09\09\09---------------------------\0A\00"
define void @clear() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i64 (...) @fork()
store i64 %6, i64* %1
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %19
10: ; preds = %0
%11 = load i64, i64* %1
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i32 @execlp(i8* %14, i8* %15, i8* null)
%17 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %13, %10
br label %19
19: ; preds = %18, %8
%20 = load i64, i64* %1
%21 = call i64 @waitpid(i64 %20, i32* %2, i32 0)
store i64 %21, i64* %1
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = call i32 @putchar(i8 signext 10)
%27 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"./clear.sh\00\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [17 x i8] c"couldn't execute\00"
@.str.3 = [14 x i8] c"waitpid error\00"
@str = [31 x i8] c"\09\09\09\09--------------------------\00"
@str.7 = [34 x i8] c"\09\09\09\09|-----Scheduler program-----|\00"
@str.8 = [32 x i8] c"\09\09\09\09---------------------------\00"
define void @clear() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i64 (...) @fork()
%7 = icmp slt i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = icmp eq i64 %6, 0
br i1 %9, label %10, label %15
10: ; preds = %8
%11 = call i32 @execlp(i8* %4, i8* %4, i8* null)
br label %12
12: ; preds = %0, %10
%13 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %0 ]
%14 = call i32 @perror(i8* %13)
br label %15
15: ; preds = %12, %8
%16 = call i64 @waitpid(i64 %6, i32* %1, i32 0)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = call i32 @putchar(i8 signext 10)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.7, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%25 = call i32 @putchar(i8 signext 10)
ret void
}