#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 */
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int sumOut = 0, sumIn = 0, countOut = 0, countIn = 0, i, input, value;
  while (1) {
    scanf("%d", &input);
    if (!input) {
      break;
    }
    scanf("%d", &value);
    if (input == 1) {
      sumIn += value;
      countIn++;
    } else {
      sumOut += value;
      countOut++;
    }
  }
  printf("%d %d\n%d %d %d", countIn, countOut, sumIn, sumOut, sumIn - sumOut);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    116a <main+0x4a>
jmp    11b2 <main+0x92>
lea    0xe9b(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    119b <main+0x7b>
mov    -0x20(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x8d>
mov    -0x20(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114b <main+0x2b>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
sub    -0x8(%rbp),%r9d
lea    0xe32(%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
lea    0xeda(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
je     1197 <main+0x77>
xor    %r14d,%r14d
lea    0xec2(%rip),%rbx
mov    %rsp,%r13
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1178 <main+0x58>
nopw   0x0(%rax,%rax,1)
add    %eax,%r14d
add    $0x1,%r15d
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
je     11a2 <main+0x82>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,(%rsp)
mov    0x4(%rsp),%eax
jne    1160 <main+0x40>
add    %eax,%ebp
add    $0x1,%r12d
jmp    1167 <main+0x47>
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %r14d,%r14d
mov    %ebp,%r9d
sub    %r14d,%r9d
lea    0xe51(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
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"
@.str.1 = [15 x i8] c"%d %d\0A%d %d %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 i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %0, %30
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
br label %31
14: ; preds = %9
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %30
24: ; preds = %14
%25 = load i32, i32* %8
%26 = load i32, i32* %2
%27 = add nsw i32 %26, %25
store i32 %27, i32* %2
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %30
30: ; preds = %24, %18
br label %9
31: ; preds = %13
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = sub nsw i32 %36, %37
%39 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33, i32 %34, i32 %35, i32 %38)
ret i32 0
}

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