#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 atoi(char);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main() {
  printf("Enter your desired operation without spaces:\n");
  char *operation = NULL;
  size_t size;
  if (getline(&operation, &size, stdin) == -1) {
    printf("No line has been read\n");
  } else {
    char *p = strtok(operation, "+-");
    while (p) {
      int value = atoi(*p);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    1193 <main+0x53>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <main+0x8b>
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c6 <main+0x86>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    11a7 <main+0x67>
jmp    11cb <main+0x8b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,(%rsp)
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11aa <main+0x6a>
mov    (%rsp),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11b6 <main+0x76>
mov    %rax,%rbx
movsbl (%rax),%edi
call   1050 <atoi@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1050 <atoi@plt>
jmp    11a0 <main+0x60>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Enter your desired operation without spaces:\0A\00"
@stdin = global i32 0
@.str.1 = [23 x i8] c"No line has been read\0A\00"
@.str.2 = [3 x i8] c"+-\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
%7 = load i32, i32* @stdin
%8 = call i32 @getline(i8** %2, i64* %3, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %23
12: ; preds = %0
%13 = load i8*, i8** %2
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %14, i8** %4
br label %15
15: ; preds = %18, %12
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = call i32 @atoi(i8 signext %20)
store i32 %21, i32* %5
br label %15
22: ; preds = %15
br label %23
23: ; preds = %22, %10
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [3 x i8] c"+-\00"
@str = [45 x i8] c"Enter your desired operation without spaces:\00"
@str.3 = [22 x i8] c"No line has been read\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%4 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%5 = bitcast i64* %2 to i8*
%6 = load i32, i32* @stdin
%7 = call i32 @getline(i8** %1, i64* %2, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
br label %21
11: ; preds = %0
%12 = load i8*, i8** %1
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = load i8, i8* %13
%17 = call i32 @atoi(i8 signext %16)
br label %18
18: ; preds = %18, %15
%19 = load i8, i8* %13
%20 = call i32 @atoi(i8 signext %19)
br label %18
21: ; preds = %11, %9
ret i32 0
}