#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 /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int a, c, sum = 0, n = 0, i = 0;
  char b, x;
  while (scanf("%d", &a)) {
    if (a == 0) {
      break;
    } else
      sum += a;
  }
  x = getchar();
  b = getchar();
  while (scanf("%d", &c)) {
    if (c == 0)
      break;
    else
      n += c;
  }
  if (b == '+')
    i = sum + n;
  else if (b == '-')
    i = sum - n;
  printf("%d", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     118b <main+0x5b>
cmpl   $0x0,-0x8(%rbp)
jne    117d <main+0x4d>
jmp    118b <main+0x5b>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <main+0x24>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1a(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x19(%rbp)
lea    0xe5a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     11d6 <main+0xa6>
cmpl   $0x0,-0xc(%rbp)
jne    11c8 <main+0x98>
jmp    11d6 <main+0xa6>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    119f <main+0x6f>
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    11f1 <main+0xc1>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    120c <main+0xdc>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    1207 <main+0xd7>
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    120c <main+0xdc>
mov    -0x18(%rbp),%esi
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
lea    0xebc(%rip),%r14
lea    0x4(%rsp),%rbp
nopl   0x0(%rax)
mov    %eax,%r13d
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     116f <main+0x3f>
mov    0x4(%rsp),%ecx
lea    (%rcx,%r13,1),%eax
test   %ecx,%ecx
jne    1150 <main+0x20>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r14d
lea    0xe77(%rip),%r15
mov    %rsp,%r12
nopl   0x0(%rax)
mov    %ebx,%ebp
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11ac <main+0x7c>
mov    (%rsp),%eax
lea    (%rax,%rbp,1),%ebx
test   %eax,%eax
jne    1190 <main+0x60>
cmp    $0x2d,%r14b
je     11c1 <main+0x91>
xor    %esi,%esi
cmp    $0x2b,%r14b
jne    11c7 <main+0x97>
add    %r13d,%ebp
mov    %ebp,%esi
jmp    11c7 <main+0x97>
sub    %ebp,%r13d
mov    %r13d,%esi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %12, %5 ]
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = icmp eq i64 %7, 0
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
%11 = select i1 %8, i1 true, i1 %10
%12 = add nsw i32 %9, %6
br i1 %11, label %13, label %5
13: ; preds = %5
%14 = call signext i8 (...) @getchar()
%15 = call signext i8 (...) @getchar()
br label %16
16: ; preds = %16, %13
%17 = phi i32 [ 0, %13 ], [ %23, %16 ]
%18 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
%22 = select i1 %19, i1 true, i1 %21
%23 = add nsw i32 %20, %17
br i1 %22, label %24, label %16
24: ; preds = %16
switch i8 %15, label %29 [
i8 43, label %25
i8 45, label %27
]
25: ; preds = %24
%26 = add nsw i32 %17, %6
br label %29
27: ; preds = %24
%28 = sub nsw i32 %6, %17
br label %29
29: ; preds = %24, %27, %25
%30 = phi i32 [ %26, %25 ], [ %28, %27 ], [ 0, %24 ]
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
ret i32 0
}