#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*/ getchar();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(int argc, char const *argv[]) {
  int i = 1, area, job, sum[101] = {0};
  int index[100] = {0}, *p = index;
  do {
    scanf("%d %d", &area, &job);
    getchar();
    if (!sum[area])
      *(p++) = area;
    sum[area] += job;
  } while (area);
  p = index;
  while (*p) {
    printf("%d %d\n", *p, sum[*p]);
    p++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x194,%edx
call   1040 <memset@plt>
lea    -0x340(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    -0x340(%rbp),%rax
mov    %rax,-0x348(%rbp)
lea    0xe65(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movslq -0x18(%rbp),%rax
cmpl   $0x0,-0x1b0(%rbp,%rax,4)
jne    11db <main+0x9b>
mov    -0x18(%rbp),%ecx
mov    -0x348(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x348(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
movslq -0x18(%rbp),%rax
add    -0x1b0(%rbp,%rax,4),%ecx
mov    %ecx,-0x1b0(%rbp,%rax,4)
cmpl   $0x0,-0x18(%rbp)
jne    1194 <main+0x54>
lea    -0x340(%rbp),%rax
mov    %rax,-0x348(%rbp)
mov    -0x348(%rbp),%rax
cmpl   $0x0,(%rax)
je     1255 <main+0x115>
mov    -0x348(%rbp),%rax
mov    (%rax),%esi
mov    -0x348(%rbp),%rax
movslq (%rax),%rax
mov    -0x1b0(%rbp,%rax,4),%edx
lea    0xdcd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x348(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x348(%rbp)
jmp    1208 <main+0xc8>
xor    %eax,%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x348,%rsp
lea    0x10(%rsp),%rdi
mov    $0x194,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x1b0(%rsp),%rbx
mov    $0x190,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe83(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
jmp    119c <main+0x5c>
nopl   0x0(%rax)
add    0xc(%rsp),%edx
mov    %edx,0x10(%rsp,%rcx,4)
test   %eax,%eax
je     11d3 <main+0x93>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x8(%rsp),%eax
movslq %eax,%rcx
mov    0x10(%rsp,%rcx,4),%edx
test   %edx,%edx
jne    1190 <main+0x50>
mov    %eax,(%rbx)
add    $0x4,%rbx
mov    0x8(%rsp),%eax
movslq %eax,%rcx
mov    0x10(%rsp,%rcx,4),%edx
jmp    1190 <main+0x50>
mov    0x1b0(%rsp),%eax
test   %eax,%eax
je     1209 <main+0xc9>
lea    0x1b4(%rsp),%rbx
lea    0xe19(%rip),%r14
nopl   (%rax)
movslq %eax,%rsi
mov    0x10(%rsp,%rsi,4),%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
add    $0x4,%rbx
test   %eax,%eax
jne    11f0 <main+0xb0>
xor    %eax,%eax
add    $0x348,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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