int main(int argc, const char *argv[]) {
  if (argc < 2) {
    puts("No expression to calculate!");
    return 0;
  }
  __auto_type length = strlen(argv[1]);
  if (length == 0) {
    puts("No expression to calculate!");
    return 0;
  }
  if (length > 2047)
    length = 2047;
  char argBuffer[2047 + 1];
  strncpy(argBuffer, argv[1], length);
  char result[32];
  __auto_type state = CalculateArithmeticExpression(argBuffer, result);
  printf("The arithmetic expression to be calculated: %s\n", argBuffer);
  if (state)
    printf("The answer is: %s\n", result);
  else
    puts("Invalid expression!");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118d <main+0x3d>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c3 <main+0x73>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <main+0x106>
cmpq   $0x7ff,-0x18(%rbp)
jbe    11d9 <main+0x89>
movq   $0x7ff,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
lea    -0x820(%rbp),%rdi
lea    -0x840(%rbp),%rsi
mov    $0x0,%al
call   1070 <CalculateArithmeticExpression@plt>
mov    %eax,-0x844(%rbp)
lea    -0x820(%rbp),%rsi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x844(%rbp)
je     1248 <main+0xf8>
lea    -0x840(%rbp),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1256 <main+0x106>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x828,%rsp
cmp    $0x1,%edi
jle    11c6 <main+0x76>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
je     11c6 <main+0x76>
cmp    $0x7ff,%rax
mov    $0x7ff,%edx
cmovb  %rax,%rdx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <CalculateArithmeticExpression@plt>
mov    %eax,%ebx
lea    0xe77(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
je     11e1 <main+0x91>
lea    0xe92(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d4 <main+0x84>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe77(%rip),%rdi
jmp    11cd <main+0x7d>

LLVM IR (-O0):
@.str = [28 x i8] c"No expression to calculate!\00"
@.str.1 = [48 x i8] c"The arithmetic expression to be calculated: %s\0A\00"
@.str.2 = [19 x i8] c"The answer is: %s\0A\00"
@.str.3 = [20 x i8] c"Invalid expression!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [2048 x i8]
%8 = alloca [32 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %46
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %6
%19 = load i64, i64* %6
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %46
23: ; preds = %14
%24 = load i64, i64* %6
%25 = icmp ugt i64 %24, 2047
br i1 %25, label %26, label %27
26: ; preds = %23
store i64 2047, i64* %6
br label %27
27: ; preds = %26, %23
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i64, i64* %6
%33 = call i8* @strncpy(i8* %28, i8* %31, i64 %32)
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%36 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @CalculateArithmeticExpression to i32 (i8*, i8*, ...)*)(i8* %34, i8* %35)
store i32 %36, i32* %9
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %27
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %46
44: ; preds = %27
%45 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %12, %21, %44, %41
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [28 x i8] c"No expression to calculate!\00"
@.str.1 = [48 x i8] c"The arithmetic expression to be calculated: %s\0A\00"
@.str.2 = [19 x i8] c"The answer is: %s\0A\00"
@.str.3 = [20 x i8] c"Invalid expression!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = alloca [32 x i8]
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %29
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %29
15: ; preds = %8
%16 = icmp ult i64 %11, 2047
%17 = select i1 %16, i64 %11, i64 2047
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%19 = call i8* @strncpy(i8* %18, i8* %10, i64 %17)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @CalculateArithmeticExpression to i32 (i8*, i8*, ...)*)(i8* %18, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%23 = icmp eq i32 %21, 0
br i1 %23, label %26, label %24
24: ; preds = %15
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %28
26: ; preds = %15
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %13, %28, %6
ret i32 0
}