#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*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ WUNTRACED;
int /*<<< orphan*/ error_log(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ execlp(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
void clear(void) {
  pid_t newpid;
  switch (newpid = fork()) {
  case -1:
    error_log(-9, NULL, NULL, NULL, "Fork");
  case 0:
    execlp("clear", NULL, NULL);
    error_log(-9, NULL, NULL, NULL, "execlp");
  default:
    waitpid(newpid, NULL, WUNTRACED);
    fprintf(stderr,
            "------------------------------------------------------------\n");
  }
  return;
}


x86 assembly (clang, -O0):
<clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <fork@plt>
mov    %eax,-0x4(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
sub    $0xffffffff,%eax
je     1185 <clear+0x35>
jmp    1175 <clear+0x25>
mov    -0x8(%rbp),%eax
test   %eax,%eax
je     11a0 <clear+0x50>
jmp    11ce <clear+0x7e>
mov    $0xfffffff7,%edi
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe6b(%rip),%r8
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <error_log@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1060 <execlp@plt>
mov    $0xfffffff7,%edi
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe48(%rip),%r8
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <error_log@plt>
mov    -0x4(%rbp),%edi
mov    0x2e08(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <waitpid@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
mov    %eax,%ebx
test   %eax,%eax
je     117a <clear+0x2a>
cmp    $0xffffffff,%ebx
jne    11a1 <clear+0x51>
lea    0xe96(%rip),%r8
mov    $0xfffffff7,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <error_log@plt>
lea    0xe84(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <execlp@plt>
lea    0xe7a(%rip),%r8
mov    $0xfffffff7,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <error_log@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <waitpid@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
pop    %rbx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"Fork\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [7 x i8] c"execlp\00"
@WUNTRACED = global i32 0
@stderr = global i32 0
@.str.3 = [62 x i8] c"------------------------------------------------------------\0A\00"
define void @clear() {
%1 = alloca i32
%2 = call i32 (...) @fork()
store i32 %2, i32* %1
switch i32 %2, label %8 [
i32 -1, label %3
i32 0, label %5
]
3: ; preds = %0
%4 = call i32 @error_log(i32 -9, i32* null, i32* null, i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %3
%6 = call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null, i32* null)
%7 = call i32 @error_log(i32 -9, i32* null, i32* null, i32* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %0, %5
%9 = load i32, i32* %1
%10 = load i32, i32* @WUNTRACED
%11 = call i32 @waitpid(i32 %9, i32* null, i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"Fork\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [7 x i8] c"execlp\00"
@WUNTRACED = global i32 0
@stderr = global i32 0
@.str.3 = [62 x i8] c"------------------------------------------------------------\0A\00"
define void @clear() {
%1 = tail call i32 (...) @fork()
switch i32 %1, label %7 [
i32 -1, label %2
i32 0, label %4
]
2: ; preds = %0
%3 = tail call i32 @error_log(i32 -9, i32* null, i32* null, i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %2
%5 = tail call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null, i32* null)
%6 = tail call i32 @error_log(i32 -9, i32* null, i32* null, i32* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %0, %4
%8 = load i32, i32* @WUNTRACED
%9 = tail call i32 @waitpid(i32 %1, i32* null, i32 %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0))
ret void
}