#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 */
char getchar();
int isNumChecker(char);
int /*<<< orphan*/ makeOperand(char, unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void simpleCalc() {
  unsigned int x = 0;
  unsigned int y = 0;
  double d = 0.0;
  int endOfNumFlag = 0;
  int operandSuccess = 0;
  int operationSuccessFlag = 0;
  char c, operation;
  printf("Please enter an expression: ");
  while (c != '\n') {
    c = getchar();
    putchar(c);
    if (isNumChecker(c) == 1) {
      if (operandSuccess == 0) {
        makeOperand(c, x);
        operandSuccess++;
      }
      if (operandSuccess == 1)
        makeOperand(c, x);
      if (operandSuccess == 2)
        makeOperand(c, y);
      endOfNumFlag = 1;
    }
    if (isNumChecker(c) == 0) {
      if (endOfNumFlag == 1) {
        operandSuccess++;
        endOfNumFlag = 0;
      }
    }
  }
  c = getchar();
  printf("Blah!\n");
}


x86 assembly (clang, -O0):
<simpleCalc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
je     124f <simpleCalc+0xff>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x1d(%rbp),%edi
call   1050 <isNumChecker@plt>
cmp    $0x1,%eax
jne    1219 <simpleCalc+0xc9>
cmpl   $0x0,-0x18(%rbp)
jne    11e2 <simpleCalc+0x92>
mov    -0x1d(%rbp),%al
mov    -0x4(%rbp),%esi
movsbl %al,%edi
call   1070 <makeOperand@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11fa <simpleCalc+0xaa>
mov    -0x1d(%rbp),%al
mov    -0x4(%rbp),%esi
movsbl %al,%edi
call   1070 <makeOperand@plt>
cmpl   $0x2,-0x18(%rbp)
jne    1212 <simpleCalc+0xc2>
mov    -0x1d(%rbp),%al
mov    -0x8(%rbp),%esi
movsbl %al,%edi
call   1070 <makeOperand@plt>
movl   $0x1,-0x14(%rbp)
movsbl -0x1d(%rbp),%edi
call   1050 <isNumChecker@plt>
cmp    $0x0,%eax
jne    124a <simpleCalc+0xfa>
cmpl   $0x1,-0x14(%rbp)
jne    1245 <simpleCalc+0xf5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    124a <simpleCalc+0xfa>
jmp    118f <simpleCalc+0x3f>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1d(%rbp)
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpleCalc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe92(%rip),%rdi
call   1050 <printf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11ab <simpleCalc+0x4b>
mov    $0x2,%ebx
mov    %r15d,%edi
xor    %esi,%esi
call   1080 <makeOperand@plt>
mov    %r15d,%edi
call   1060 <isNumChecker@plt>
mov    %ebp,%ecx
xor    $0x1,%ecx
xor    %edx,%edx
or     %eax,%ecx
sete   %dl
cmove  %r14d,%ebp
add    %edx,%ebx
cmp    $0xa,%r15b
je     11ef <simpleCalc+0x8f>
xor    %eax,%eax
call   1070 <getchar@plt>
movsbl %al,%r15d
mov    %r15d,%edi
call   1030 <putchar@plt>
mov    %r15d,%edi
call   1060 <isNumChecker@plt>
cmp    $0x1,%eax
jne    118b <simpleCalc+0x2b>
mov    $0x1,%ebp
cmp    $0x2,%ebx
je     117c <simpleCalc+0x1c>
cmp    $0x1,%ebx
je     1181 <simpleCalc+0x21>
test   %ebx,%ebx
jne    118b <simpleCalc+0x2b>
mov    %r15d,%edi
xor    %esi,%esi
call   1080 <makeOperand@plt>
mov    $0x1,%ebx
jmp    1181 <simpleCalc+0x21>
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xe20(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Please enter an expression: \00"
@.str.1 = [7 x i8] c"Blah!\0A\00"
define void @simpleCalc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %56, %0
%11 = load i8, i8* %7
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %57
14: ; preds = %10
%15 = call signext i8 (...) @getchar()
store i8 %15, i8* %7
%16 = load i8, i8* %7
%17 = call i32 @putchar(i8 signext %16)
%18 = load i8, i8* %7
%19 = call i32 @isNumChecker(i8 signext %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %45
21: ; preds = %14
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i8, i8* %7
%26 = load i32, i32* %1
%27 = call i32 @makeOperand(i8 signext %25, i32 %26)
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %30
30: ; preds = %24, %21
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8, i8* %7
%35 = load i32, i32* %1
%36 = call i32 @makeOperand(i8 signext %34, i32 %35)
br label %37
37: ; preds = %33, %30
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i8, i8* %7
%42 = load i32, i32* %2
%43 = call i32 @makeOperand(i8 signext %41, i32 %42)
br label %44
44: ; preds = %40, %37
store i32 1, i32* %4
br label %45
45: ; preds = %44, %14
%46 = load i8, i8* %7
%47 = call i32 @isNumChecker(i8 signext %46)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %45
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
store i32 0, i32* %4
br label %55
55: ; preds = %52, %49
br label %56
56: ; preds = %55, %45
br label %10
57: ; preds = %10
%58 = call signext i8 (...) @getchar()
store i8 %58, i8* %7
%59 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Please enter an expression: \00"
@str = [6 x i8] c"Blah!\00"
define void @simpleCalc() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %16
%3 = phi i32 [ %25, %16 ], [ 0, %0 ]
%4 = phi i32 [ %24, %16 ], [ 0, %0 ]
%5 = tail call signext i8 (...) @getchar()
%6 = tail call i32 @putchar(i8 signext %5)
%7 = tail call i32 @isNumChecker(i8 signext %5)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %2
switch i32 %4, label %16 [
i32 0, label %10
i32 1, label %13
i32 2, label %12
]
10: ; preds = %9
%11 = tail call i32 @makeOperand(i8 signext %5, i32 0)
br label %13
12: ; preds = %9
br label %13
13: ; preds = %10, %9, %12
%14 = phi i32 [ 2, %12 ], [ %4, %9 ], [ 1, %10 ]
%15 = tail call i32 @makeOperand(i8 signext %5, i32 0)
br label %16
16: ; preds = %13, %9, %2
%17 = phi i32 [ %4, %2 ], [ %4, %9 ], [ %14, %13 ]
%18 = phi i32 [ %3, %2 ], [ 1, %9 ], [ 1, %13 ]
%19 = tail call i32 @isNumChecker(i8 signext %5)
%20 = icmp eq i32 %19, 0
%21 = icmp eq i32 %18, 1
%22 = select i1 %20, i1 %21, i1 false
%23 = zext i1 %22 to i32
%24 = add nsw i32 %17, %23
%25 = select i1 %22, i32 0, i32 %18
%26 = icmp eq i8 %5, 10
br i1 %26, label %27, label %2
27: ; preds = %16
%28 = tail call signext i8 (...) @getchar()
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret void
}