#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*/ scanf(char *, int *, ...);
scalar_t__ score(int, int);
int total_score() {
  int darts, _score = 0;
  scanf("%d", &darts);
  while (darts--) {
    int x, y;
    scanf("%d %d", &x, &y);
    _score += score(x, y);
  }
  return _score;
}


x86 assembly (clang, -O0):
<total_score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1188 <total_score+0x68>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <score@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
jmp    1141 <total_score+0x21>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<total_score>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed1(%rip),%rdi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     1186 <total_score+0x66>
lea    0xeb2(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1030 <score@plt>
add    %eax,%ebx
subl   $0x1,0xc(%rsp)
jae    1160 <total_score+0x40>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @total_score() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %2
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i64 @score(i32 %12, i32 %13)
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i32
store i32 %18, i32* %2
br label %6
19: ; preds = %6
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @total_score() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %23, label %9
9: ; preds = %0
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
br label %12
12: ; preds = %9, %12
%13 = phi i32 [ 0, %9 ], [ %19, %12 ]
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i64 @score(i32 %15, i32 %16)
%18 = trunc i64 %17 to i32
%19 = add i32 %13, %18
%20 = load i32, i32* %1
%21 = add nsw i32 %20, -1
store i32 %21, i32* %1
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %12
23: ; preds = %12, %0
%24 = phi i32 [ 0, %0 ], [ %19, %12 ]
ret i32 %24
}