#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 convertCharToInt(char *);
char *cutString(char *, int, int, int);
int /*<<< orphan*/ free(char *);
char *getWordByNumberNoDelete(int, int *, char **);
scalar_t__ insert(char **, int, int);
int /*<<< orphan*/ insertArray(char *, int *, int *, char **);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
void commandPrev(char *data, char *param1, char *param2, int *wordNumber,
                 int *wordNumberArray, char **wordArray) {
  if (param1 != NULL && param2 != NULL) {
    int number = convertCharToInt(data);
    int begin = convertCharToInt(param1);
    int end = convertCharToInt(param2);
    char *wordFromArray, *temp;
    int len = 0;
    if (number >= 0 && begin >= 0 && end >= begin) {
      wordFromArray =
          getWordByNumberNoDelete(number, wordNumberArray, wordArray);
      if (wordFromArray != NULL)
        len = strlen(wordFromArray);
      temp = cutString(wordFromArray, begin, end, len);
      if (temp != NULL) {
        if (insert(&temp, *wordNumber, end - begin + 1)) {
          printf("word number: %d\n", (*wordNumber));
          insertArray(temp, wordNumber, wordNumberArray, wordArray);
          (*wordNumber)++;
        } else {
          printf("ignored\n");
        }
      } else
        printf("ignored\n");
    } else
      printf("ignored\n");
  } else
    printf("ignored\n");
  if (data != NULL) {
    free(data);
    data = NULL;
  }
}


x86 assembly (clang, -O0):
<commandPrev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12e1 <commandPrev+0x161>
cmpq   $0x0,-0x18(%rbp)
je     12e1 <commandPrev+0x161>
mov    -0x8(%rbp),%rdi
call   10a0 <convertCharToInt@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <convertCharToInt@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <convertCharToInt@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     12ce <commandPrev+0x14e>
cmpl   $0x0,-0x38(%rbp)
jl     12ce <commandPrev+0x14e>
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jl     12ce <commandPrev+0x14e>
mov    -0x34(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <getWordByNumberNoDelete@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     122c <commandPrev+0xac>
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x54(%rbp),%ecx
call   1060 <cutString@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     12bb <commandPrev+0x13b>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x3c(%rbp),%edx
sub    -0x38(%rbp),%edx
add    $0x1,%edx
lea    -0x50(%rbp),%rdi
call   1090 <insert@plt>
cmp    $0x0,%rax
je     12a8 <commandPrev+0x128>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <insertArray@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    12b6 <commandPrev+0x136>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12c9 <commandPrev+0x149>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12dc <commandPrev+0x15c>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12ef <commandPrev+0x16f>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     130b <commandPrev+0x18b>
mov    -0x8(%rbp),%rdi
call   1050 <free@plt>
movq   $0x0,-0x8(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<commandPrev>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r13
test   %rsi,%rsi
je     1287 <commandPrev+0xf7>
mov    %rdx,%rbp
test   %rdx,%rdx
je     1287 <commandPrev+0xf7>
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %r8,(%rsp)
mov    %r9,0x8(%rsp)
mov    %r13,%rdi
call   10b0 <convertCharToInt@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   10b0 <convertCharToInt@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   10b0 <convertCharToInt@plt>
test   %r12d,%r12d
js     1287 <commandPrev+0xf7>
test   %ebx,%ebx
js     1287 <commandPrev+0xf7>
mov    %eax,%r15d
mov    %eax,%ebp
sub    %ebx,%ebp
jl     1287 <commandPrev+0xf7>
mov    %r12d,%edi
mov    (%rsp),%rsi
mov    0x8(%rsp),%rdx
call   1030 <getWordByNumberNoDelete@plt>
mov    %rax,%r12
test   %rax,%rax
je     1225 <commandPrev+0x95>
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
jmp    1227 <commandPrev+0x97>
xor    %ecx,%ecx
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1070 <cutString@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1287 <commandPrev+0xf7>
mov    (%r14),%esi
add    $0x1,%ebp
lea    0x10(%rsp),%rdi
mov    %ebp,%edx
call   10a0 <insert@plt>
test   %rax,%rax
je     1287 <commandPrev+0xf7>
mov    (%r14),%esi
lea    0xda1(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    (%rsp),%rdx
mov    0x8(%rsp),%rcx
call   1040 <insertArray@plt>
addl   $0x1,(%r14)
test   %r13,%r13
jne    1298 <commandPrev+0x108>
jmp    12a0 <commandPrev+0x110>
lea    0xd83(%rip),%rdi
call   1060 <puts@plt>
test   %r13,%r13
je     12a0 <commandPrev+0x110>
mov    %r13,%rdi
call   1050 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"word number: %d\0A\00"
@.str.1 = [9 x i8] c"ignored\0A\00"
define void @commandPrev(i8* %0, i8* %1, i8* %2, i32* %3, i32* %4, i8** %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i8** %5, i8*** %12
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %88
21: ; preds = %6
%22 = load i8*, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %88
24: ; preds = %21
%25 = load i8*, i8** %7
%26 = call i32 @convertCharToInt(i8* %25)
store i32 %26, i32* %13
%27 = load i8*, i8** %8
%28 = call i32 @convertCharToInt(i8* %27)
store i32 %28, i32* %14
%29 = load i8*, i8** %9
%30 = call i32 @convertCharToInt(i8* %29)
store i32 %30, i32* %15
store i32 0, i32* %18
%31 = load i32, i32* %13
%32 = icmp sge i32 %31, 0
br i1 %32, label %33, label %85
33: ; preds = %24
%34 = load i32, i32* %14
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %85
36: ; preds = %33
%37 = load i32, i32* %15
%38 = load i32, i32* %14
%39 = icmp sge i32 %37, %38
br i1 %39, label %40, label %85
40: ; preds = %36
%41 = load i32, i32* %13
%42 = load i32*, i32** %11
%43 = load i8**, i8*** %12
%44 = call i8* @getWordByNumberNoDelete(i32 %41, i32* %42, i8** %43)
store i8* %44, i8** %16
%45 = load i8*, i8** %16
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %40
%48 = load i8*, i8** %16
%49 = call i32 @strlen(i8* %48)
store i32 %49, i32* %18
br label %50
50: ; preds = %47, %40
%51 = load i8*, i8** %16
%52 = load i32, i32* %14
%53 = load i32, i32* %15
%54 = load i32, i32* %18
%55 = call i8* @cutString(i8* %51, i32 %52, i32 %53, i32 %54)
store i8* %55, i8** %17
%56 = load i8*, i8** %17
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %82
58: ; preds = %50
%59 = load i32*, i32** %10
%60 = load i32, i32* %59
%61 = load i32, i32* %15
%62 = load i32, i32* %14
%63 = sub nsw i32 %61, %62
%64 = add nsw i32 %63, 1
%65 = call i64 @insert(i8** %17, i32 %60, i32 %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %79
67: ; preds = %58
%68 = load i32*, i32** %10
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = load i8*, i8** %17
%72 = load i32*, i32** %10
%73 = load i32*, i32** %11
%74 = load i8**, i8*** %12
%75 = call i32 @insertArray(i8* %71, i32* %72, i32* %73, i8** %74)
%76 = load i32*, i32** %10
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 1
store i32 %78, i32* %76
br label %81
79: ; preds = %58
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %81
81: ; preds = %79, %67
br label %84
82: ; preds = %50
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %84
84: ; preds = %82, %81
br label %87
85: ; preds = %36, %33, %24
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %87
87: ; preds = %85, %84
br label %90
88: ; preds = %21, %6
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %90
90: ; preds = %88, %87
%91 = load i8*, i8** %7
%92 = icmp ne i8* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i8*, i8** %7
%95 = call i32 @free(i8* %94)
store i8* null, i8** %7
br label %96
96: ; preds = %93, %90
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"word number: %d\0A\00"
@str.4 = [8 x i8] c"ignored\00"
define void @commandPrev(i8* %0, i8* %1, i8* %2, i32* %3, i32* %4, i8** %5) {
%7 = alloca i8*
%8 = icmp ne i8* %1, null
%9 = icmp ne i8* %2, null
%10 = and i1 %8, %9
br i1 %10, label %11, label %50
11: ; preds = %6
%12 = tail call i32 @convertCharToInt(i8* %0)
%13 = tail call i32 @convertCharToInt(i8* %1)
%14 = tail call i32 @convertCharToInt(i8* %2)
%15 = bitcast i8** %7 to i8*
%16 = icmp slt i32 %12, 0
%17 = icmp slt i32 %13, 0
%18 = select i1 %16, i1 true, i1 %17
%19 = icmp slt i32 %14, %13
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %47, label %21
21: ; preds = %11
%22 = tail call i8* @getWordByNumberNoDelete(i32 %12, i32* %4, i8** %5)
%23 = icmp eq i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @strlen(i8* %22)
br label %26
26: ; preds = %24, %21
%27 = phi i32 [ %25, %24 ], [ 0, %21 ]
%28 = tail call i8* @cutString(i8* %22, i32 %13, i32 %14, i32 %27)
store i8* %28, i8** %7
%29 = icmp eq i8* %28, null
br i1 %29, label %45, label %30
30: ; preds = %26
%31 = load i32, i32* %3
%32 = sub nsw i32 1, %13
%33 = add i32 %32, %14
%34 = call i64 @insert(i8** %7, i32 %31, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %30
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i8*, i8** %7
%40 = call i32 @insertArray(i8* %39, i32* %3, i32* %4, i8** %5)
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %49
43: ; preds = %30
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br label %49
45: ; preds = %26
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br label %49
47: ; preds = %11
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br label %49
49: ; preds = %45, %43, %36, %47
br label %52
50: ; preds = %6
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
%53 = icmp eq i8* %0, null
br i1 %53, label %56, label %54
54: ; preds = %52
%55 = call i32 @free(i8* %0)
br label %56
56: ; preds = %54, %52
ret void
}