#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 addInstructionToMemory(int);
int addStringLiteralToMemory(char **, int, int);
int constantExistsInTable(int /*<<< orphan*/);
int getElementAddressFromStr(char *, int);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ strToInt(char *);
int strlen2(char *);
int variableExistsInTable(char);
int createPrintInstruction(char tokenArray[][20], int numberOfTokens) {
  int instruction;
  int variableAddress;
  int variableIdx;
  if (numberOfTokens < 3) {
    return -1;
  }
  for (variableIdx = 2; variableIdx < numberOfTokens; variableIdx++) {
    instruction = 11 * 10000;
    if (!isdigit(tokenArray[variableIdx][0])) {
      variableAddress = variableExistsInTable(tokenArray[variableIdx][0]);
      if (tokenArray[variableIdx][0] == '"') {
        variableAddress =
            addStringLiteralToMemory(tokenArray, numberOfTokens, variableIdx);
        instruction = 16 * 10000;
        variableIdx = numberOfTokens;
      } else if (strlen2(tokenArray[variableIdx]) == 2 &&
                 tokenArray[variableIdx][1] == '$') {
        instruction = 16 * 10000;
        variableIdx = numberOfTokens;
      } else if (strlen2(tokenArray[variableIdx]) > 3) {
        variableAddress =
            getElementAddressFromStr(tokenArray[variableIdx], variableAddress);
        if (variableAddress == -1) {
          return -1;
        }
      }
    } else
      variableAddress =
          constantExistsInTable(strToInt(tokenArray[variableIdx]));
    instruction += variableAddress;
    if (addInstructionToMemory(instruction) == -1)
      return -1;
    ;
  }
  return 1;
}


x86 assembly (clang, -O0):
<createPrintInstruction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11a5 <createPrintInstruction+0x25>
movl   $0xffffffff,-0x4(%rbp)
jmp    1342 <createPrintInstruction+0x1c2>
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    133b <createPrintInstruction+0x1bb>
movl   $0x1adb0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    12e4 <createPrintInstruction+0x164>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movsbl (%rax),%edi
call   1060 <variableExistsInTable@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1238 <createPrintInstruction+0xb8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <addStringLiteralToMemory@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x27100,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    12df <createPrintInstruction+0x15f>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1070 <strlen2@plt>
cmp    $0x2,%eax
jne    1283 <createPrintInstruction+0x103>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movsbl 0x1(%rax),%eax
cmp    $0x24,%eax
jne    1283 <createPrintInstruction+0x103>
movl   $0x27100,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    12da <createPrintInstruction+0x15a>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1070 <strlen2@plt>
cmp    $0x3,%eax
jle    12d5 <createPrintInstruction+0x155>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <getElementAddressFromStr@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12d0 <createPrintInstruction+0x150>
movl   $0xffffffff,-0x4(%rbp)
jmp    1342 <createPrintInstruction+0x1c2>
jmp    12d5 <createPrintInstruction+0x155>
jmp    12da <createPrintInstruction+0x15a>
jmp    12df <createPrintInstruction+0x15f>
jmp    1302 <createPrintInstruction+0x182>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1040 <strToInt@plt>
mov    %eax,%edi
call   1090 <constantExistsInTable@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <addInstructionToMemory@plt>
cmp    $0xffffffff,%eax
jne    1328 <createPrintInstruction+0x1a8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1342 <createPrintInstruction+0x1c2>
jmp    132d <createPrintInstruction+0x1ad>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <createPrintInstruction+0x2c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPrintInstruction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0xffffffff,%eax
cmp    $0x3,%esi
jl     12ad <createPrintInstruction+0x12d>
mov    %esi,%r15d
mov    %rdi,%rbx
mov    $0x2,%ebp
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
movslq %ebp,%rax
lea    (%rax,%rax,4),%r15
lea    (%rbx,%r15,4),%r12
movsbl (%rbx,%r15,4),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11f0 <createPrintInstruction+0x70>
mov    %r12,%rdi
call   1040 <strToInt@plt>
mov    %eax,%edi
call   1090 <constantExistsInTable@plt>
mov    %eax,%r13d
mov    $0x1adb0,%r14d
mov    0xc(%rsp),%r15d
jmp    1280 <createPrintInstruction+0x100>
nopl   0x0(%rax,%rax,1)
movsbl (%r12),%edi
call   1060 <variableExistsInTable@plt>
cmpb   $0x22,(%r12)
jne    1221 <createPrintInstruction+0xa1>
mov    %rbx,%rdi
mov    0xc(%rsp),%r15d
mov    %r15d,%esi
mov    %ebp,%edx
call   1050 <addStringLiteralToMemory@plt>
mov    %eax,%r13d
mov    $0x27100,%r14d
mov    %r15d,%ebp
jmp    1280 <createPrintInstruction+0x100>
mov    %eax,%r13d
mov    %r12,%rdi
call   1070 <strlen2@plt>
cmp    $0x2,%eax
jne    124e <createPrintInstruction+0xce>
mov    $0x27100,%r14d
mov    0x10(%rsp),%rax
cmpb   $0x24,0x1(%rax,%r15,4)
jne    124e <createPrintInstruction+0xce>
mov    0xc(%rsp),%r15d
mov    %r15d,%ebp
jmp    1280 <createPrintInstruction+0x100>
mov    %r12,%rdi
call   1070 <strlen2@plt>
mov    $0x1adb0,%r14d
cmp    $0x4,%eax
jl     11e1 <createPrintInstruction+0x61>
mov    %r12,%rdi
mov    %r13d,%esi
call   10a0 <getElementAddressFromStr@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
mov    0xc(%rsp),%r15d
je     12a8 <createPrintInstruction+0x128>
nopl   0x0(%rax)
add    %r13d,%r14d
mov    %r14d,%edi
call   1080 <addInstructionToMemory@plt>
cmp    $0xffffffff,%eax
je     12a8 <createPrintInstruction+0x128>
add    $0x1,%ebp
cmp    %r15d,%ebp
mov    0x10(%rsp),%rbx
jl     11b0 <createPrintInstruction+0x30>
mov    $0x1,%eax
jmp    12ad <createPrintInstruction+0x12d>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @createPrintInstruction([20 x i8]* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [20 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [20 x i8]* %0, [20 x i8]** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %112
12: ; preds = %2
store i32 2, i32* %8
br label %13
13: ; preds = %108, %12
%14 = load i32, i32* %8
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %111
17: ; preds = %13
store i32 110000, i32* %6
%18 = load [20 x i8]*, [20 x i8]** %4
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 %20
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%23 = load i8, i8* %22
%24 = call i32 @isdigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %91, label %26
26: ; preds = %17
%27 = load [20 x i8]*, [20 x i8]** %4
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %27, i64 %29
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %30, i64 0, i64 0
%32 = load i8, i8* %31
%33 = call i32 @variableExistsInTable(i8 signext %32)
store i32 %33, i32* %7
%34 = load [20 x i8]*, [20 x i8]** %4
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %34, i64 %36
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %37, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 34
br i1 %41, label %42, label %49
42: ; preds = %26
%43 = load [20 x i8]*, [20 x i8]** %4
%44 = bitcast [20 x i8]* %43 to i8**
%45 = load i32, i32* %5
%46 = load i32, i32* %8
%47 = call i32 @addStringLiteralToMemory(i8** %44, i32 %45, i32 %46)
store i32 %47, i32* %7
store i32 160000, i32* %6
%48 = load i32, i32* %5
store i32 %48, i32* %8
br label %90
49: ; preds = %26
%50 = load [20 x i8]*, [20 x i8]** %4
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %50, i64 %52
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %53, i64 0, i64 0
%55 = call i32 @strlen2(i8* %54)
%56 = icmp eq i32 %55, 2
br i1 %56, label %57, label %68
57: ; preds = %49
%58 = load [20 x i8]*, [20 x i8]** %4
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %58, i64 %60
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %61, i64 0, i64 1
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 36
br i1 %65, label %66, label %68
66: ; preds = %57
store i32 160000, i32* %6
%67 = load i32, i32* %5
store i32 %67, i32* %8
br label %89
68: ; preds = %57, %49
%69 = load [20 x i8]*, [20 x i8]** %4
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [20 x i8], [20 x i8]* %69, i64 %71
%73 = getelementptr inbounds [20 x i8], [20 x i8]* %72, i64 0, i64 0
%74 = call i32 @strlen2(i8* %73)
%75 = icmp sgt i32 %74, 3
br i1 %75, label %76, label %88
76: ; preds = %68
%77 = load [20 x i8]*, [20 x i8]** %4
%78 = load i32, i32* %8
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [20 x i8], [20 x i8]* %77, i64 %79
%81 = getelementptr inbounds [20 x i8], [20 x i8]* %80, i64 0, i64 0
%82 = load i32, i32* %7
%83 = call i32 @getElementAddressFromStr(i8* %81, i32 %82)
store i32 %83, i32* %7
%84 = load i32, i32* %7
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %87
86: ; preds = %76
store i32 -1, i32* %3
br label %112
87: ; preds = %76
br label %88
88: ; preds = %87, %68
br label %89
89: ; preds = %88, %66
br label %90
90: ; preds = %89, %42
br label %99
91: ; preds = %17
%92 = load [20 x i8]*, [20 x i8]** %4
%93 = load i32, i32* %8
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [20 x i8], [20 x i8]* %92, i64 %94
%96 = getelementptr inbounds [20 x i8], [20 x i8]* %95, i64 0, i64 0
%97 = call i32 @strToInt(i8* %96)
%98 = call i32 @constantExistsInTable(i32 %97)
store i32 %98, i32* %7
br label %99
99: ; preds = %91, %90
%100 = load i32, i32* %7
%101 = load i32, i32* %6
%102 = add nsw i32 %101, %100
store i32 %102, i32* %6
%103 = load i32, i32* %6
%104 = call i32 @addInstructionToMemory(i32 %103)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %107
106: ; preds = %99
store i32 -1, i32* %3
br label %112
107: ; preds = %99
br label %108
108: ; preds = %107
%109 = load i32, i32* %8
%110 = add nsw i32 %109, 1
store i32 %110, i32* %8
br label %13
111: ; preds = %13
store i32 1, i32* %3
br label %112
112: ; preds = %111, %106, %86, %11
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
define i32 @createPrintInstruction([20 x i8]* %0, i32 %1) {
%3 = icmp slt i32 %1, 3
br i1 %3, label %46, label %4
4: ; preds = %2
%5 = bitcast [20 x i8]* %0 to i8**
br label %8
6: ; preds = %38
%7 = icmp slt i32 %45, %1
br i1 %7, label %8, label %46
8: ; preds = %4, %6
%9 = phi i32 [ 2, %4 ], [ %45, %6 ]
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %0, i64 %10, i64 0
%12 = load i8, i8* %11
%13 = tail call i32 @isdigit(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %8
%16 = load i8, i8* %11
%17 = tail call i32 @variableExistsInTable(i8 signext %16)
%18 = load i8, i8* %11
%19 = icmp eq i8 %18, 34
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @addStringLiteralToMemory(i8** %5, i32 %1, i32 %9)
br label %38
22: ; preds = %15
%23 = tail call i32 @strlen2(i8* %11)
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %0, i64 %10, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 36
br i1 %28, label %38, label %29
29: ; preds = %25, %22
%30 = tail call i32 @strlen2(i8* %11)
%31 = icmp sgt i32 %30, 3
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = tail call i32 @getElementAddressFromStr(i8* %11, i32 %17)
%34 = icmp eq i32 %33, -1
br i1 %34, label %46, label %38
35: ; preds = %8
%36 = tail call i32 @strToInt(i8* %11)
%37 = tail call i32 @constantExistsInTable(i32 %36)
br label %38
38: ; preds = %25, %20, %29, %32, %35
%39 = phi i32 [ 110000, %35 ], [ 160000, %20 ], [ 110000, %32 ], [ 110000, %29 ], [ 160000, %25 ]
%40 = phi i32 [ %37, %35 ], [ %21, %20 ], [ %33, %32 ], [ %17, %29 ], [ %17, %25 ]
%41 = phi i32 [ %9, %35 ], [ %1, %20 ], [ %9, %32 ], [ %9, %29 ], [ %1, %25 ]
%42 = add nsw i32 %40, %39
%43 = tail call i32 @addInstructionToMemory(i32 %42)
%44 = icmp eq i32 %43, -1
%45 = add nsw i32 %41, 1
br i1 %44, label %46, label %6
46: ; preds = %32, %38, %6, %2
%47 = phi i32 [ -1, %2 ], [ -1, %32 ], [ -1, %38 ], [ 1, %6 ]
ret i32 %47
}