#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__ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int sscanf(char *, char *, int *, char *, int *, int *);
int main() {
  char str[100], sign;
  int i, a, b, r, res, count = 0;
  while (gets(str)) {
    if (sscanf(str, "%d%c%d=%d", &a, &sign, &b, &res) != 4) {
      continue;
    }
    switch (sign) {
    case '+':
      r = a + b;
      break;
    case '-':
      r = a - b;
      break;
    }
    if (r == res)
      count++;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8c(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
cmp    $0x0,%rax
je     11ff <main+0xcf>
lea    -0x70(%rbp),%rdi
lea    0xe96(%rip),%rsi
lea    -0x7c(%rbp),%rdx
lea    -0x71(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    -0x88(%rbp),%r9
call   1050 <sscanf@plt>
cmp    $0x4,%eax
je     1190 <main+0x60>
jmp    114c <main+0x1c>
movsbl -0x71(%rbp),%eax
mov    %eax,-0x90(%rbp)
sub    $0x2b,%eax
je     11bc <main+0x8c>
jmp    11a8 <main+0x78>
mov    -0x90(%rbp),%eax
sub    $0x2d,%eax
je     11cd <main+0x9d>
jmp    11d9 <main+0xa9>
mov    -0x7c(%rbp),%eax
add    -0x80(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    11d9 <main+0xa9>
mov    -0x7c(%rbp),%eax
sub    -0x80(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x88(%rbp),%eax
jne    11fa <main+0xca>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    114c <main+0x1c>
mov    -0x8c(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movl   $0x0,0xc(%rsp)
lea    0x20(%rsp),%rbx
lea    0xeab(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xb(%rsp),%r13
lea    0x10(%rsp),%rbp
lea    0x1c(%rsp),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <gets@plt>
test   %rax,%rax
je     11d1 <main+0xa1>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
mov    %r14,%r9
call   1050 <sscanf@plt>
cmp    $0x4,%eax
jne    1170 <main+0x40>
movsbl 0xb(%rsp),%eax
cmp    $0x2d,%eax
je     11b6 <main+0x86>
cmp    $0x2b,%eax
mov    0x18(%rsp),%ecx
jne    11be <main+0x8e>
mov    0x10(%rsp),%ecx
add    0x14(%rsp),%ecx
jmp    11be <main+0x8e>
mov    0x14(%rsp),%ecx
sub    0x10(%rsp),%ecx
xor    %eax,%eax
mov    %ecx,0x18(%rsp)
cmp    0x1c(%rsp),%ecx
sete   %al
add    %eax,0xc(%rsp)
jmp    1170 <main+0x40>
lea    0xe32(%rip),%rdi
mov    0xc(%rsp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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