#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 *);
char *strdup(char *);
void modifyHistory(char *input, char *clihistory[200], int *clihistorycounter) {
  if (input != NULL) {
    if (*clihistorycounter < 200) {
      clihistory[(int)*clihistorycounter] = strdup(input);
      (*clihistorycounter)++;
    } else {
      printf("CLI History is full.  Rewriting from beginning.\n");
      (*clihistorycounter) = 0;
      clihistory[(int)*clihistorycounter] = strdup(input);
    }
  } else {
    printf("Command not found!\n");
  }
}


x86 assembly (clang, -O0):
<modifyHistory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b0 <modifyHistory+0x90>
mov    -0x18(%rbp),%rax
cmpl   $0xc8,(%rax)
jge    117a <modifyHistory+0x5a>
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11ab <modifyHistory+0x8b>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11bc <modifyHistory+0x9c>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modifyHistory>:
test   %rdi,%rdi
je     1158 <modifyHistory+0x38>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movslq (%rdx),%r12
cmp    $0xc7,%r12
jg     1164 <modifyHistory+0x44>
mov    %rbx,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r14,%r12,8)
lea    0x1(%r12),%eax
mov    %eax,(%r15)
jmp    1182 <modifyHistory+0x62>
lea    0xea1(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,(%r15)
mov    %rbx,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"CLI History is full. Rewriting from beginning.\0A\00"
@.str.1 = [20 x i8] c"Command not found!\0A\00"
define void @modifyHistory(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %35
9: ; preds = %3
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = icmp slt i32 %11, 200
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = call i8* @strdup(i8* %14)
%16 = load i8**, i8*** %5
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %16, i64 %19
store i8* %15, i8** %20
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %34
24: ; preds = %9
%25 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%26 = load i32*, i32** %6
store i32 0, i32* %26
%27 = load i8*, i8** %4
%28 = call i8* @strdup(i8* %27)
%29 = load i8**, i8*** %5
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %29, i64 %32
store i8* %28, i8** %33
br label %34
34: ; preds = %24, %13
br label %37
35: ; preds = %3
%36 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %34
ret void
}

LLVM IR (-O2):
@str = [19 x i8] c"Command not found!\00"
@str.2 = [48 x i8] c"CLI History is full. Rewriting from beginning.\00"
define void @modifyHistory(i8* %0, i8** nocapture writeonly %1, i32* nocapture %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 200
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = tail call i8* @strdup(i8* %0)
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
store i8* %9, i8** %11
%12 = add nsw i32 %6, 1
store i32 %12, i32* %2
br label %18
13: ; preds = %5
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.2, i64 0, i64 0))
store i32 0, i32* %2
%15 = tail call i8* @strdup(i8* %0)
store i8* %15, i8** %1
br label %18
16: ; preds = %3
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %8, %13, %16
ret void
}