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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int getInput(char *point, char hist[][80], int histCount) {
  char numstr[80];
  int iter = 1;
  memset(numstr, 0, sizeof(numstr));
  printf("osh> ");
  fflush(stdout);
  fgets(point, 80, stdin);
  if (point[strlen(point) - 1] == '\n')
    point[strlen(point) - 1] = '\0';
  if (point[0] == '!') {
    if (histCount != 1) {
      if (point[1] == '!') {
        memset(point, 0, strlen(point));
        strcpy(point, hist[0]);
        for (int i = 9; i >= 0; i--) {
          strcpy(hist[i], hist[i - 1]);
        }
        strcpy(hist[0], point);
        histCount++;
      } else if (isdigit(point[1])) {
        while (isdigit(point[iter])) {
          numstr[iter - 1] = point[iter];
          iter++;
        }
        iter = atoi(numstr);
        if ((histCount <= 10 && iter >= 1 && iter < histCount) ||
            (histCount > 10 && iter < histCount && iter >= histCount - 10)) {
          iter = (histCount - iter - 1) % 10;
          memset(point, 0, strlen(point));
          strcpy(point, hist[iter]);
          for (int i = 9; i >= 0; i--) {
            strcpy(hist[i], hist[i - 1]);
          }
          strcpy(hist[0], point);
          histCount++;
        } else
          printf("The number %d, is out of the range of "
                 "history.\n",
                 iter);
      } else
        printf("Improper use of !! or !n. The Proper usage "
               "is '!!' or '!n' where n is a number listed with "
               "the 'history' command.\n");
    } else
      printf("There is currently no command in the history.\n");
  } else if (point[0] != '\0' && strcmp(point, "history") != 0) {
    for (int i = 9; i >= 0; i--) {
      strcpy(hist[i], hist[i - 1]);
    }
    strcpy(hist[0], point);
    histCount++;
  }
  return histCount;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x1,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1070 <memset@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1247 <getInput+0xb7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    14a5 <getInput+0x315>
cmpl   $0x1,-0x14(%rbp)
je     1492 <getInput+0x302>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x21,%eax
jne    1304 <getInput+0x174>
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x9,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jl     12e9 <getInput+0x159>
mov    -0x10(%rbp),%rdi
movslq -0x78(%rbp),%rax
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x78(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x50,%rax,%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
jmp    12aa <getInput+0x11a>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    148d <getInput+0x2fd>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     147a <getInput+0x2ea>
jmp    1320 <getInput+0x190>
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1360 <getInput+0x1d0>
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1320 <getInput+0x190>
lea    -0x70(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0xa,-0x14(%rbp)
jg     138c <getInput+0x1fc>
cmpl   $0x1,-0x74(%rbp)
jl     138c <getInput+0x1fc>
mov    -0x74(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     13b3 <getInput+0x223>
cmpl   $0xa,-0x14(%rbp)
jle    1464 <getInput+0x2d4>
mov    -0x74(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1464 <getInput+0x2d4>
mov    -0x74(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0xa,%ecx
cmp    %ecx,%eax
jl     1464 <getInput+0x2d4>
mov    -0x14(%rbp),%eax
sub    -0x74(%rbp),%eax
sub    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x74(%rbp),%rax
imul   $0x50,%rax,%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
movl   $0x9,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jl     1449 <getInput+0x2b9>
mov    -0x10(%rbp),%rdi
movslq -0x7c(%rbp),%rax
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x7c(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x50,%rax,%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x7c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7c(%rbp)
jmp    140a <getInput+0x27a>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1475 <getInput+0x2e5>
mov    -0x74(%rbp),%esi
lea    0xb98(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1488 <getInput+0x2f8>
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    148d <getInput+0x2fd>
jmp    14a0 <getInput+0x310>
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1530 <getInput+0x3a0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     152b <getInput+0x39b>
mov    -0x8(%rbp),%rdi
lea    0xc18(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     152b <getInput+0x39b>
movl   $0x9,-0x80(%rbp)
cmpl   $0x0,-0x80(%rbp)
jl     1515 <getInput+0x385>
mov    -0x10(%rbp),%rdi
movslq -0x80(%rbp),%rax
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x80(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x50,%rax,%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x80(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x80(%rbp)
jmp    14d6 <getInput+0x346>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1530 <getInput+0x3a0>
mov    -0x14(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1080 <memset@plt>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x50,%esi
call   1090 <fgets@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbp,1)
jne    1218 <getInput+0x78>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    0x0(%rbp),%al
test   %al,%al
je     1405 <getInput+0x265>
cmp    $0x21,%al
jne    1244 <getInput+0xa4>
cmp    $0x1,%r14d
jne    1261 <getInput+0xc1>
lea    0xe0a(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r14d
jmp    1405 <getInput+0x265>
lea    0xdeb(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    134e <getInput+0x1ae>
jmp    1405 <getInput+0x265>
mov    0x1(%rbp),%al
cmp    $0x21,%al
jne    1287 <getInput+0xe7>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1080 <memset@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
jmp    1349 <getInput+0x1a9>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1417 <getInput+0x277>
movsbl 0x1(%rbp),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     12cb <getInput+0x12b>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbp,%rbx,1),%eax
mov    %al,(%rsp,%rbx,1)
movsbl 0x2(%rbp,%rbx,1),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    12b0 <getInput+0x110>
mov    %rsp,%rdi
call   10c0 <atoi@plt>
cmp    $0xa,%r14d
jg     12e2 <getInput+0x142>
test   %eax,%eax
jle    12e2 <getInput+0x142>
cmp    %r14d,%eax
jl     1301 <getInput+0x161>
cmp    $0xb,%r14d
jl     1425 <getInput+0x285>
cmp    %r14d,%eax
jge    1425 <getInput+0x285>
lea    -0xa(%r14),%ecx
cmp    %ecx,%eax
jl     1425 <getInput+0x285>
not    %eax
add    %r14d,%eax
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1080 <memset@plt>
movslq %ebx,%rax
lea    (%rax,%rax,4),%rsi
shl    $0x4,%rsi
add    %r15,%rsi
mov    %rbp,%rdi
call   1040 <strcpy@plt>
lea    0x2d0(%r15),%rdi
lea    0x280(%r15),%r12
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0x230(%r15),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0x1e0(%r15),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0x190(%r15),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0x140(%r15),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xf0(%r15),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0xa0(%r15),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0x50(%r15),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    -0x50(%r15),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r14d
mov    %r14d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4e(%rip),%rdi
call   1050 <puts@plt>
jmp    1405 <getInput+0x265>
lea    0xbda(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1405 <getInput+0x265>

LLVM IR (-O0):
@.str = [6 x i8] c"osh> \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [48 x i8] c"The number %d, is out of the range of history.\0A\00"
@.str.2 = [115 x i8] c"Improper use of !! or !n. The Proper usage is '!!' or '!n' where n is a number listed with the 'history' command.\0A\00"
@.str.3 = [47 x i8] c"There is currently no command in the history.\0A\00"
@.str.4 = [8 x i8] c"history\00"
define i32 @getInput(i8* %0, [80 x i8]* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca [80 x i8]*
%6 = alloca i32
%7 = alloca [80 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store [80 x i8]* %1, [80 x i8]** %5
store i32 %2, i32* %6
store i32 1, i32* %8
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 80)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = load i8*, i8** %4
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 80, i32 %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %36
29: ; preds = %3
%30 = load i8*, i8** %4
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %29, %3
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 33
br i1 %41, label %42, label %194
42: ; preds = %36
%43 = load i32, i32* %6
%44 = icmp ne i32 %43, 1
br i1 %44, label %45, label %191
45: ; preds = %42
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 33
br i1 %50, label %51, label %88
51: ; preds = %45
%52 = load i8*, i8** %4
%53 = load i8*, i8** %4
%54 = call i32 @strlen(i8* %53)
%55 = call i32 @memset(i8* %52, i32 0, i32 %54)
%56 = load i8*, i8** %4
%57 = load [80 x i8]*, [80 x i8]** %5
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %57, i64 0
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %58, i64 0, i64 0
%60 = call i32 @strcpy(i8* %56, i8* %59)
store i32 9, i32* %9
br label %61
61: ; preds = %77, %51
%62 = load i32, i32* %9
%63 = icmp sge i32 %62, 0
br i1 %63, label %64, label %80
64: ; preds = %61
%65 = load [80 x i8]*, [80 x i8]** %5
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %65, i64 %67
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %68, i64 0, i64 0
%70 = load [80 x i8]*, [80 x i8]** %5
%71 = load i32, i32* %9
%72 = sub nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [80 x i8], [80 x i8]* %70, i64 %73
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %74, i64 0, i64 0
%76 = call i32 @strcpy(i8* %69, i8* %75)
br label %77
77: ; preds = %64
%78 = load i32, i32* %9
%79 = add nsw i32 %78, -1
store i32 %79, i32* %9
br label %61
80: ; preds = %61
%81 = load [80 x i8]*, [80 x i8]** %5
%82 = getelementptr inbounds [80 x i8], [80 x i8]* %81, i64 0
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %82, i64 0, i64 0
%84 = load i8*, i8** %4
%85 = call i32 @strcpy(i8* %83, i8* %84)
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
br label %190
88: ; preds = %45
%89 = load i8*, i8** %4
%90 = getelementptr inbounds i8, i8* %89, i64 1
%91 = load i8, i8* %90
%92 = call i64 @isdigit(i8 signext %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %187
94: ; preds = %88
br label %95
95: ; preds = %103, %94
%96 = load i8*, i8** %4
%97 = load i32, i32* %8
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
%100 = load i8, i8* %99
%101 = call i64 @isdigit(i8 signext %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %115
103: ; preds = %95
%104 = load i8*, i8** %4
%105 = load i32, i32* %8
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8, i8* %107
%109 = load i32, i32* %8
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %111
store i8 %108, i8* %112
%113 = load i32, i32* %8
%114 = add nsw i32 %113, 1
store i32 %114, i32* %8
br label %95
115: ; preds = %95
%116 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%117 = call i32 @atoi(i8* %116)
store i32 %117, i32* %8
%118 = load i32, i32* %6
%119 = icmp sle i32 %118, 10
br i1 %119, label %120, label %127
120: ; preds = %115
%121 = load i32, i32* %8
%122 = icmp sge i32 %121, 1
br i1 %122, label %123, label %127
123: ; preds = %120
%124 = load i32, i32* %8
%125 = load i32, i32* %6
%126 = icmp slt i32 %124, %125
br i1 %126, label %139, label %127
127: ; preds = %123, %120, %115
%128 = load i32, i32* %6
%129 = icmp sgt i32 %128, 10
br i1 %129, label %130, label %183
130: ; preds = %127
%131 = load i32, i32* %8
%132 = load i32, i32* %6
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %183
134: ; preds = %130
%135 = load i32, i32* %8
%136 = load i32, i32* %6
%137 = sub nsw i32 %136, 10
%138 = icmp sge i32 %135, %137
br i1 %138, label %139, label %183
139: ; preds = %134, %123
%140 = load i32, i32* %6
%141 = load i32, i32* %8
%142 = sub nsw i32 %140, %141
%143 = sub nsw i32 %142, 1
%144 = srem i32 %143, 10
store i32 %144, i32* %8
%145 = load i8*, i8** %4
%146 = load i8*, i8** %4
%147 = call i32 @strlen(i8* %146)
%148 = call i32 @memset(i8* %145, i32 0, i32 %147)
%149 = load i8*, i8** %4
%150 = load [80 x i8]*, [80 x i8]** %5
%151 = load i32, i32* %8
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [80 x i8], [80 x i8]* %150, i64 %152
%154 = getelementptr inbounds [80 x i8], [80 x i8]* %153, i64 0, i64 0
%155 = call i32 @strcpy(i8* %149, i8* %154)
store i32 9, i32* %10
br label %156
156: ; preds = %172, %139
%157 = load i32, i32* %10
%158 = icmp sge i32 %157, 0
br i1 %158, label %159, label %175
159: ; preds = %156
%160 = load [80 x i8]*, [80 x i8]** %5
%161 = load i32, i32* %10
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [80 x i8], [80 x i8]* %160, i64 %162
%164 = getelementptr inbounds [80 x i8], [80 x i8]* %163, i64 0, i64 0
%165 = load [80 x i8]*, [80 x i8]** %5
%166 = load i32, i32* %10
%167 = sub nsw i32 %166, 1
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [80 x i8], [80 x i8]* %165, i64 %168
%170 = getelementptr inbounds [80 x i8], [80 x i8]* %169, i64 0, i64 0
%171 = call i32 @strcpy(i8* %164, i8* %170)
br label %172
172: ; preds = %159
%173 = load i32, i32* %10
%174 = add nsw i32 %173, -1
store i32 %174, i32* %10
br label %156
175: ; preds = %156
%176 = load [80 x i8]*, [80 x i8]** %5
%177 = getelementptr inbounds [80 x i8], [80 x i8]* %176, i64 0
%178 = getelementptr inbounds [80 x i8], [80 x i8]* %177, i64 0, i64 0
%179 = load i8*, i8** %4
%180 = call i32 @strcpy(i8* %178, i8* %179)
%181 = load i32, i32* %6
%182 = add nsw i32 %181, 1
store i32 %182, i32* %6
br label %186
183: ; preds = %134, %130, %127
%184 = load i32, i32* %8
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %184)
br label %186
186: ; preds = %183, %175
br label %189
187: ; preds = %88
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0))
br label %189
189: ; preds = %187, %186
br label %190
190: ; preds = %189, %80
br label %193
191: ; preds = %42
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %193
193: ; preds = %191, %190
br label %233
194: ; preds = %36
%195 = load i8*, i8** %4
%196 = getelementptr inbounds i8, i8* %195, i64 0
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = icmp ne i32 %198, 0
br i1 %199, label %200, label %232
200: ; preds = %194
%201 = load i8*, i8** %4
%202 = call i64 @strcmp(i8* %201, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%203 = icmp ne i64 %202, 0
br i1 %203, label %204, label %232
204: ; preds = %200
store i32 9, i32* %11
br label %205
205: ; preds = %221, %204
%206 = load i32, i32* %11
%207 = icmp sge i32 %206, 0
br i1 %207, label %208, label %224
208: ; preds = %205
%209 = load [80 x i8]*, [80 x i8]** %5
%210 = load i32, i32* %11
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds [80 x i8], [80 x i8]* %209, i64 %211
%213 = getelementptr inbounds [80 x i8], [80 x i8]* %212, i64 0, i64 0
%214 = load [80 x i8]*, [80 x i8]** %5
%215 = load i32, i32* %11
%216 = sub nsw i32 %215, 1
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [80 x i8], [80 x i8]* %214, i64 %217
%219 = getelementptr inbounds [80 x i8], [80 x i8]* %218, i64 0, i64 0
%220 = call i32 @strcpy(i8* %213, i8* %219)
br label %221
221: ; preds = %208
%222 = load i32, i32* %11
%223 = add nsw i32 %222, -1
store i32 %223, i32* %11
br label %205
224: ; preds = %205
%225 = load [80 x i8]*, [80 x i8]** %5
%226 = getelementptr inbounds [80 x i8], [80 x i8]* %225, i64 0
%227 = getelementptr inbounds [80 x i8], [80 x i8]* %226, i64 0, i64 0
%228 = load i8*, i8** %4
%229 = call i32 @strcpy(i8* %227, i8* %228)
%230 = load i32, i32* %6
%231 = add nsw i32 %230, 1
store i32 %231, i32* %6
br label %232
232: ; preds = %224, %200, %194
br label %233
233: ; preds = %232, %193
%234 = load i32, i32* %6
ret i32 %234
}

LLVM IR (-O2):
@.str = [6 x i8] c"osh> \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [48 x i8] c"The number %d, is out of the range of history.\0A\00"
@.str.4 = [8 x i8] c"history\00"
@str = [46 x i8] c"There is currently no command in the history.\00"
@str.5 = [114 x i8] c"Improper use of !! or !n. The Proper usage is '!!' or '!n' where n is a number listed with the 'history' command.\00"
define i32 @getInput(i8* %0, [80 x i8]* %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 80)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %0, i32 80, i32 %10)
%12 = call i32 @strlen(i8* %0)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %23
18: ; preds = %3
%19 = call i32 @strlen(i8* %0)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %18, %3
%24 = load i8, i8* %0
switch i8 %24, label %128 [
i8 33, label %25
i8 0, label %155
]
25: ; preds = %23
%26 = icmp eq i32 %2, 1
br i1 %26, label %126, label %27
27: ; preds = %25
%28 = getelementptr inbounds i8, i8* %0, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 33
br i1 %30, label %31, label %58
31: ; preds = %27
%32 = call i32 @strlen(i8* %0)
%33 = call i32 @memset(i8* %0, i32 0, i32 %32)
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%35 = call i32 @strcpy(i8* %0, i8* %34)
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 9, i64 0
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 8, i64 0
%38 = call i32 @strcpy(i8* %36, i8* %37)
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 7, i64 0
%40 = call i32 @strcpy(i8* %37, i8* %39)
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 6, i64 0
%42 = call i32 @strcpy(i8* %39, i8* %41)
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 5, i64 0
%44 = call i32 @strcpy(i8* %41, i8* %43)
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 4, i64 0
%46 = call i32 @strcpy(i8* %43, i8* %45)
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 3, i64 0
%48 = call i32 @strcpy(i8* %45, i8* %47)
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 2, i64 0
%50 = call i32 @strcpy(i8* %47, i8* %49)
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 1, i64 0
%52 = call i32 @strcpy(i8* %49, i8* %51)
%53 = call i32 @strcpy(i8* %51, i8* %34)
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 -1, i64 0
%55 = call i32 @strcpy(i8* %34, i8* %54)
%56 = call i32 @strcpy(i8* %34, i8* %0)
%57 = add nsw i32 %2, 1
br label %155
58: ; preds = %27
%59 = call i64 @isdigit(i8 signext %29)
%60 = icmp eq i64 %59, 0
br i1 %60, label %124, label %61
61: ; preds = %58
%62 = load i8, i8* %28
%63 = call i64 @isdigit(i8 signext %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %76, label %65
65: ; preds = %61, %65
%66 = phi i64 [ %71, %65 ], [ 1, %61 ]
%67 = phi i8* [ %72, %65 ], [ %28, %61 ]
%68 = load i8, i8* %67
%69 = add nsw i64 %66, -1
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %69
store i8 %68, i8* %70
%71 = add nuw nsw i64 %66, 1
%72 = getelementptr inbounds i8, i8* %0, i64 %71
%73 = load i8, i8* %72
%74 = call i64 @isdigit(i8 signext %73)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %65
76: ; preds = %65, %61
%77 = call i32 @atoi(i8* %5)
%78 = icmp slt i32 %2, 11
%79 = icmp sgt i32 %77, 0
%80 = select i1 %78, i1 %79, i1 false
%81 = icmp slt i32 %77, %2
%82 = select i1 %80, i1 %81, i1 false
br i1 %82, label %90, label %83
83: ; preds = %76
%84 = icmp sgt i32 %2, 10
%85 = select i1 %84, i1 %81, i1 false
%86 = xor i1 %85, true
%87 = add nsw i32 %2, -10
%88 = icmp slt i32 %77, %87
%89 = select i1 %86, i1 true, i1 %88
br i1 %89, label %122, label %90
90: ; preds = %83, %76
%91 = xor i32 %77, -1
%92 = add i32 %91, %2
%93 = srem i32 %92, 10
%94 = call i32 @strlen(i8* %0)
%95 = call i32 @memset(i8* %0, i32 0, i32 %94)
%96 = sext i32 %93 to i64
%97 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 %96, i64 0
%98 = call i32 @strcpy(i8* %0, i8* %97)
%99 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 9, i64 0
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 8, i64 0
%101 = call i32 @strcpy(i8* %99, i8* %100)
%102 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 7, i64 0
%103 = call i32 @strcpy(i8* %100, i8* %102)
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 6, i64 0
%105 = call i32 @strcpy(i8* %102, i8* %104)
%106 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 5, i64 0
%107 = call i32 @strcpy(i8* %104, i8* %106)
%108 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 4, i64 0
%109 = call i32 @strcpy(i8* %106, i8* %108)
%110 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 3, i64 0
%111 = call i32 @strcpy(i8* %108, i8* %110)
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 2, i64 0
%113 = call i32 @strcpy(i8* %110, i8* %112)
%114 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 1, i64 0
%115 = call i32 @strcpy(i8* %112, i8* %114)
%116 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%117 = call i32 @strcpy(i8* %114, i8* %116)
%118 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 -1, i64 0
%119 = call i32 @strcpy(i8* %116, i8* %118)
%120 = call i32 @strcpy(i8* %116, i8* %0)
%121 = add nsw i32 %2, 1
br label %155
122: ; preds = %83
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %77)
br label %155
124: ; preds = %58
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @str.5, i64 0, i64 0))
br label %155
126: ; preds = %25
%127 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %155
128: ; preds = %23
%129 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%130 = icmp eq i64 %129, 0
br i1 %130, label %155, label %131
131: ; preds = %128
%132 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 9, i64 0
%133 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 8, i64 0
%134 = call i32 @strcpy(i8* %132, i8* %133)
%135 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 7, i64 0
%136 = call i32 @strcpy(i8* %133, i8* %135)
%137 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 6, i64 0
%138 = call i32 @strcpy(i8* %135, i8* %137)
%139 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 5, i64 0
%140 = call i32 @strcpy(i8* %137, i8* %139)
%141 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 4, i64 0
%142 = call i32 @strcpy(i8* %139, i8* %141)
%143 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 3, i64 0
%144 = call i32 @strcpy(i8* %141, i8* %143)
%145 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 2, i64 0
%146 = call i32 @strcpy(i8* %143, i8* %145)
%147 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 1, i64 0
%148 = call i32 @strcpy(i8* %145, i8* %147)
%149 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%150 = call i32 @strcpy(i8* %147, i8* %149)
%151 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 -1, i64 0
%152 = call i32 @strcpy(i8* %149, i8* %151)
%153 = call i32 @strcpy(i8* %149, i8* %0)
%154 = add nsw i32 %2, 1
br label %155
155: ; preds = %23, %128, %131, %126, %124, %122, %90, %31
%156 = phi i32 [ %57, %31 ], [ %121, %90 ], [ %2, %122 ], [ %2, %124 ], [ 1, %126 ], [ %154, %131 ], [ %2, %128 ], [ %2, %23 ]
ret i32 %156
}