#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long long);
scalar_t__ isdigit(char);
int main() {
  FILE *f = fopen("INP.TXT", "r");
  char c, prevc = 100;
  unsigned long long x = 0, y = 0;
  while ((c = fgetc(f)) != EOF) {
    if (isdigit(prevc) && !isdigit(c)) {
      y += x;
      x = 0;
    } else if (isdigit(c)) {
      x = x * 10 + c - 48;
    }
    prevc = c;
  }
  fclose(f);
  f = fopen("OUT.TXT", "w");
  fprintf(f, "%lld\n", y);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movb   $0x64,-0x12(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e48(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1222 <main+0xd2>
movsbl -0x12(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11ea <main+0x9a>
movsbl -0x11(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11ea <main+0x9a>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
jmp    1217 <main+0xc7>
movsbl -0x11(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1212 <main+0xc2>
imul   $0xa,-0x20(%rbp),%rax
movsbq -0x11(%rbp),%rcx
add    %rcx,%rax
sub    $0x30,%rax
mov    %rax,-0x20(%rbp)
jmp    1217 <main+0xc7>
mov    -0x11(%rbp),%al
mov    %al,-0x12(%rbp)
jmp    118a <main+0x3a>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdd8(%rip),%rdi
lea    0xdd9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdc3(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e68(%rip),%r15
cmp    (%r15),%al
jne    11d1 <main+0x81>
xor    %r14d,%r14d
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe73(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe67(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x64,%bl
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    11f3 <main+0xa3>
nopl   0x0(%rax,%rax,1)
add    %r13,%r14
xor    %r13d,%r13d
mov    %r12,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%al
je     1188 <main+0x38>
mov    %ebx,%ecx
mov    %eax,%ebx
movsbl %cl,%edi
call   1030 <isdigit@plt>
movsbl %bl,%ebp
test   %rax,%rax
je     1213 <main+0xc3>
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11e0 <main+0x90>
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11e6 <main+0x96>
lea    0x0(,%r13,4),%rax
add    %r13,%rax
movsbq %bl,%rcx
lea    (%rcx,%rax,2),%r13
add    $0xffffffffffffffd0,%r13
jmp    11e6 <main+0x96>

LLVM IR (-O0):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
store i8 100, i8* %4
store i64 0, i64* %5
store i64 0, i64* %6
br label %8
8: ; preds = %39, %0
%9 = load i32*, i32** %2
%10 = call signext i8 @fgetc(i32* %9)
store i8 %10, i8* %3
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %41
15: ; preds = %8
%16 = load i8, i8* %4
%17 = call i64 @isdigit(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i8, i8* %3
%21 = call i64 @isdigit(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i64, i64* %5
%25 = load i64, i64* %6
%26 = add i64 %25, %24
store i64 %26, i64* %6
store i64 0, i64* %5
br label %39
27: ; preds = %19, %15
%28 = load i8, i8* %3
%29 = call i64 @isdigit(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i64, i64* %5
%33 = mul i64 %32, 10
%34 = load i8, i8* %3
%35 = sext i8 %34 to i64
%36 = add i64 %33, %35
%37 = sub i64 %36, 48
store i64 %37, i64* %5
br label %38
38: ; preds = %31, %27
br label %39
39: ; preds = %38, %23
%40 = load i8, i8* %3
store i8 %40, i8* %4
br label %8
41: ; preds = %8
%42 = load i32*, i32** %2
%43 = call i32 @fclose(i32* %42)
%44 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %44, i32** %2
%45 = load i32*, i32** %2
%46 = load i64, i64* %6
%47 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %46)
%48 = load i32*, i32** %2
%49 = call i32 @fclose(i32* %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call signext i8 @fgetc(i32* %1)
%3 = load i8, i8* @EOF
%4 = icmp eq i8 %2, %3
br i1 %4, label %31, label %5
5: ; preds = %0, %25
%6 = phi i8 [ %28, %25 ], [ %2, %0 ]
%7 = phi i64 [ %27, %25 ], [ 0, %0 ]
%8 = phi i64 [ %26, %25 ], [ 0, %0 ]
%9 = phi i8 [ %6, %25 ], [ 100, %0 ]
%10 = tail call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %5
%13 = tail call i64 @isdigit(i8 signext %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = add i64 %7, %8
br label %25
17: ; preds = %12, %5
%18 = tail call i64 @isdigit(i8 signext %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = mul i64 %8, 10
%22 = sext i8 %6 to i64
%23 = add i64 %21, -48
%24 = add i64 %23, %22
br label %25
25: ; preds = %17, %20, %15
%26 = phi i64 [ %24, %20 ], [ %8, %17 ], [ 0, %15 ]
%27 = phi i64 [ %7, %20 ], [ %7, %17 ], [ %16, %15 ]
%28 = tail call signext i8 @fgetc(i32* %1)
%29 = load i8, i8* @EOF
%30 = icmp eq i8 %28, %29
br i1 %30, label %31, label %5
31: ; preds = %25, %0
%32 = phi i64 [ 0, %0 ], [ %27, %25 ]
%33 = tail call i32 @fclose(i32* %1)
%34 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = tail call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %32)
%36 = tail call i32 @fclose(i32* %34)
ret i32 0
}