#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 */
scalar_t__ CheckSpace(char *, int, scalar_t__);
int Str2Num(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
char *strtok(char *, char *);
int main() {
  int num1, num2;
  int len, index, i, flag1, flag2;
  char *delim1 = "+";
  char *delim2 = " ";
  char line[50], *p1, *p2, *cnum1, *cnum2, *cnum3, *cnum4;
  while (fgets(line, 50, stdin)) {
    num1 = num2 = 0;
    p1 = strtok(line, delim1);
    p2 = strtok(NULL, delim1);
    if (CheckSpace(p1, 0, strlen(p1) - 2)) {
      cnum1 = strtok(p1, delim2);
      cnum2 = strtok(NULL, delim2);
      num1 = Str2Num(cnum1) * 10 + Str2Num(cnum2);
    } else {
      cnum1 = strtok(line, delim2);
      num1 = Str2Num(cnum1);
    }
    if (CheckSpace(p2, 1, strlen(p2) - 4)) {
      cnum3 = strtok(p2, delim2);
      cnum4 = strtok(NULL, delim2);
      num2 = Str2Num(cnum3) * 10 + Str2Num(cnum4);
    } else {
      cnum3 = strtok(p2, delim2);
      num2 = Str2Num(cnum3);
    }
    if (num1 == 0 && num2 == 0)
      return 0;
    printf("%d\n", num1 + num2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe7e(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1375 <main+0x215>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1080 <strtok@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x78(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %rax,%rdx
sub    $0x2,%rdx
xor    %esi,%esi
call   1060 <CheckSpace@plt>
cmp    $0x0,%rax
je     1267 <main+0x107>
mov    -0x78(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x88(%rbp)
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1080 <strtok@plt>
mov    %rax,-0x90(%rbp)
mov    -0x88(%rbp),%rdi
call   1070 <Str2Num@plt>
imul   $0xa,%eax,%eax
mov    %eax,-0xac(%rbp)
mov    -0x90(%rbp),%rdi
call   1070 <Str2Num@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    128a <main+0x12a>
lea    -0x70(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
call   1070 <Str2Num@plt>
mov    %eax,-0x8(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    %rax,%rdx
sub    $0x4,%rdx
mov    $0x1,%esi
call   1060 <CheckSpace@plt>
cmp    $0x0,%rax
je     131b <main+0x1bb>
mov    -0x80(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1080 <strtok@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdi
call   1070 <Str2Num@plt>
imul   $0xa,%eax,%eax
mov    %eax,-0xbc(%rbp)
mov    -0xa0(%rbp),%rdi
call   1070 <Str2Num@plt>
mov    %eax,%ecx
mov    -0xbc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    133e <main+0x1de>
mov    -0x80(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1070 <Str2Num@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    135e <main+0x1fe>
cmpl   $0x0,-0xc(%rbp)
jne    135e <main+0x1fe>
movl   $0x0,-0x4(%rbp)
jmp    137c <main+0x21c>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xc99(%rip),%rdi
call   1040 <printf@plt>
jmp    1188 <main+0x28>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x32,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     12bf <main+0x15f>
lea    0xe6c(%rip),%r14
mov    %rsp,%r15
lea    0xe64(%rip),%r13
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r14,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1030 <strlen@plt>
lea    -0x2(%rax),%rdx
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <CheckSpace@plt>
test   %rax,%rax
je     1210 <main+0xb0>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r13,%rsi
call   1080 <strtok@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1070 <Str2Num@plt>
lea    (%rax,%rax,4),%ebp
mov    %r12,%rdi
call   1070 <Str2Num@plt>
lea    (%rax,%rbp,2),%r12d
jmp    1226 <main+0xc6>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1070 <Str2Num@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    -0x4(%rax),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <CheckSpace@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
test   %rbp,%rbp
je     1280 <main+0x120>
xor    %edi,%edi
mov    %r13,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <Str2Num@plt>
lea    (%rax,%rax,4),%ebx
mov    %rbp,%rdi
call   1070 <Str2Num@plt>
lea    (%rax,%rbx,2),%esi
jmp    128a <main+0x12a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <Str2Num@plt>
mov    %eax,%esi
mov    %r12d,%eax
or     %esi,%eax
je     12bf <main+0x15f>
add    %r12d,%esi
lea    0xd69(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x32,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <main+0x40>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c" \00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i64 @fgets(i8* %2, i32 50, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %49, label %6
6: ; preds = %0, %43
%7 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @strlen(i8* dereferenceable(1) %7)
%10 = add nsw i64 %9, -2
%11 = call i64 @CheckSpace(i8* %7, i32 0, i64 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %6
%14 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @Str2Num(i8* %14)
%17 = mul nsw i32 %16, 10
%18 = call i32 @Str2Num(i8* %15)
%19 = add nsw i32 %17, %18
br label %23
20: ; preds = %6
%21 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @Str2Num(i8* %21)
br label %23
23: ; preds = %20, %13
%24 = phi i32 [ %19, %13 ], [ %22, %20 ]
%25 = call i64 @strlen(i8* dereferenceable(1) %8)
%26 = add nsw i64 %25, -4
%27 = call i64 @CheckSpace(i8* %8, i32 1, i64 %26)
%28 = icmp eq i64 %27, 0
%29 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br i1 %28, label %36, label %30
30: ; preds = %23
%31 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @Str2Num(i8* %29)
%33 = mul nsw i32 %32, 10
%34 = call i32 @Str2Num(i8* %31)
%35 = add nsw i32 %33, %34
br label %38
36: ; preds = %23
%37 = call i32 @Str2Num(i8* %29)
br label %38
38: ; preds = %36, %30
%39 = phi i32 [ %35, %30 ], [ %37, %36 ]
%40 = icmp eq i32 %24, 0
%41 = icmp eq i32 %39, 0
%42 = select i1 %40, i1 %41, i1 false
br i1 %42, label %49, label %43
43: ; preds = %38
%44 = add nsw i32 %39, %24
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @stdin
%47 = call i64 @fgets(i8* %2, i32 50, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %6
49: ; preds = %38, %43, %0
ret i32 0
}