#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 *, ...);
int /*<<< orphan*/ stdin;
long long strtol(char *, int /*<<< orphan*/ *, int);
long long strtoll(char *, int /*<<< orphan*/ *, int);
int main(int ac, char *av[]) {
  long long n, p, d, d2;
  char buf[1024];
  if (ac < 2) {
    printf("usage : brotherprime2 d2\n");
    return (1);
  }
  d2 = strtoll(av[1], NULL, 10);
  p = 0;
  while (fgets(buf, 1024, stdin)) {
    d = strtol(buf, NULL, 10);
    n = p + d;
    if (p != 0 && d == d2)
      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)
cmpl   $0x2,-0x8(%rbp)
jge    117d <main+0x3d>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x430(%rbp),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1224 <main+0xe4>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1217 <main+0xd7>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1217 <main+0xd7>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    119f <main+0x5f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x1,%edi
jg     117c <main+0x2c>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1208 <main+0xb8>
mov    0x8(%rsi),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoll@plt>
mov    %rax,%r14
mov    0x2e50(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1208 <main+0xb8>
mov    %rsp,%r12
lea    0xe49(%rip),%r15
xor    %r13d,%r13d
jmp    11d5 <main+0x85>
nopl   0x0(%rax)
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1206 <main+0xb6>
mov    %r13,%rbx
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
add    %rax,%r13
test   %rbx,%rbx
je     11c0 <main+0x70>
cmp    %r14,%rax
jne    11c0 <main+0x70>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <main+0x70>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"usage : brotherprime2 d2\0A\00"
@stdin = global i32 0
@.str.1 = [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 i64
%10 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %44
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strtoll(i8* %18, i32* null, i32 10)
store i64 %19, i64* %9
store i64 0, i64* %7
br label %20
20: ; preds = %41, %15
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%22 = load i32, i32* @stdin
%23 = call i64 @fgets(i8* %21, i32 1024, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %20
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%27 = call i64 @strtol(i8* %26, i32* null, i32 10)
store i64 %27, i64* %8
%28 = load i64, i64* %7
%29 = load i64, i64* %8
%30 = add nsw i64 %28, %29
store i64 %30, i64* %6
%31 = load i64, i64* %7
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %25
%34 = load i64, i64* %8
%35 = load i64, i64* %9
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i64, i64* %7
%39 = load i64, i64* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %38, i64 %39)
br label %41
41: ; preds = %37, %33, %25
%42 = load i64, i64* %6
store i64 %42, i64* %7
br label %20
43: ; preds = %20
store i32 0, i32* %3
br label %44
44: ; preds = %43, %13
%45 = load i32, i32* %3
ret i32 %45
}

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