#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__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long long, long long);
int /*<<< orphan*/ stdin;
long long strtoll(char *, int /*<<< orphan*/ *, int);
int main(int ac, char *av[]) {
  long long d, n, p;
  char buf[1024];
  p = 0;
  while (fgets(buf, 1024, stdin)) {
    d = strtoll(buf, NULL, 10);
    n = p + d;
    if (p != 0 && d == 2)
      printf("%lld %lld\n", p, n);
    p = n;
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11d1 <main+0xa1>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c4 <main+0x94>
cmpq   $0x2,-0x18(%rbp)
jne    11c4 <main+0x94>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    0x2ea1(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11b6 <main+0x86>
xor    %r12d,%r12d
mov    %rsp,%r15
lea    0xe96(%rip),%r14
jmp    1186 <main+0x56>
nopl   0x0(%rax)
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11b6 <main+0x86>
mov    %r12,%rbx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
add    %rax,%r12
test   %rbx,%rbx
je     1170 <main+0x40>
cmp    $0x2,%rax
jne    1170 <main+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1030 <printf@plt>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [11 x i8] c"%lld %lld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
br label %10
10: ; preds = %30, %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %11, i32 1024, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %10
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%17 = call i64 @strtoll(i8* %16, i32* null, i32 10)
store i64 %17, i64* %6
%18 = load i64, i64* %8
%19 = load i64, i64* %6
%20 = add nsw i64 %18, %19
store i64 %20, i64* %7
%21 = load i64, i64* %8
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %15
%24 = load i64, i64* %6
%25 = icmp eq i64 %24, 2
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i64, i64* %8
%28 = load i64, i64* %7
%29 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %27, i64 %28)
br label %30
30: ; preds = %26, %23, %15
%31 = load i64, i64* %7
store i64 %31, i64* %8
br label %10
32: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [11 x i8] c"%lld %lld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 1024, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %2, %17
%9 = phi i64 [ %11, %17 ], [ 0, %2 ]
%10 = call i64 @strtoll(i8* nocapture %4, i32* null, i32 10)
%11 = add nsw i64 %10, %9
%12 = icmp ne i64 %9, 0
%13 = icmp eq i64 %10, 2
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %9, i64 %11)
br label %17
17: ; preds = %15, %8
%18 = load i32, i32* @stdin
%19 = call i64 @fgets(i8* %4, i32 1024, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %17, %2
ret i32 0
}