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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void process_termination(int flag) {
  printf("\n\n---------------------------------------------------------------"
         "\n\n");
  if (flag == 1 || flag == 2)
    printf("Process completed Normally::\nMonitor is shutting Down due to "
           "process completion\n");
  else
    printf("\x1b[31m"
           "Attack detected::Execution stopped\nMonitor is shutting Down due "
           "to attack detection\n"
           "\x1b[0m");
  printf("*********************************************************************"
         "********\n");
}


x86 assembly (clang, -O0):
<process_termination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
je     113b <process_termination+0x2b>
cmpl   $0x2,-0x4(%rbp)
jne    114c <process_termination+0x3c>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
jmp    1158 <process_termination+0x48>
lea    0xf42(%rip),%rdi
call   1030 <printf@plt>
lea    0xf94(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_termination>:
push   %rbx
mov    %edi,%ebx
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1145 <process_termination+0x25>
lea    0xfb1(%rip),%rdi
call   1030 <puts@plt>
jmp    1151 <process_termination+0x31>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xf49(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [68 x i8] c"\0A\0A---------------------------------------------------------------\0A\0A\00"
@.str.1 = [81 x i8] c"Process completed Normally::\0AMonitor is shutting Down due to process completion\0A\00"
@.str.2 = [94 x i8] c"\1B[31mAttack detected::Execution stopped\0AMonitor is shutting Down due to attack detection\0A\1B[0m\00"
@.str.3 = [79 x i8] c"*****************************************************************************\0A\00"
define void @process_termination(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = call i32 @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [94 x i8] c"\1B[31mAttack detected::Execution stopped\0AMonitor is shutting Down due to attack detection\0A\1B[0m\00"
@str = [67 x i8] c"\0A\0A---------------------------------------------------------------\0A\00"
@str.4 = [78 x i8] c"*****************************************************************************\00"
@str.5 = [80 x i8] c"Process completed Normally::\0AMonitor is shutting Down due to process completion\00"
define void @process_termination(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%3 = add i32 %0, -1
%4 = icmp ult i32 %3, 2
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.5, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.4, i64 0, i64 0))
ret void
}