#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*/ down_from(int, int, int *, int *, double);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n;
  double g;
  scanf("%d %lf", &n, &g);
  int arr[n << 1];
  int *dist = arr;
  int *deg = arr + n;
  for (int i = 0; i < n; i++)
    scanf("%d %d", dist + i, deg + i);
  for (int i = 0; i < n; i++)
    down_from(i, n, dist, deg, g);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <scanf@plt>
mov    -0x8(%rbp),%eax
add    %eax,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
movslq -0x8(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cc <main+0xac>
mov    -0x28(%rbp),%rsi
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x30(%rbp),%rdx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1186 <main+0x66>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1205 <main+0xe5>
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
movsd  -0x10(%rbp),%xmm0
call   1040 <down_from@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11d3 <main+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xec8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x48(%rbp),%rdx
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %rsp,%r14
mov    -0x2c(%rbp),%eax
add    %eax,%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movslq -0x2c(%rbp),%r13
test   %r13,%r13
jle    11dc <main+0xbc>
mov    %r14,-0x40(%rbp)
lea    (%r15,%r13,4),%rax
mov    %rax,-0x38(%rbp)
shl    $0x2,%r13
lea    0xe83(%rip),%r12
mov    %r15,%rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%r13,1),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rsi
add    $0x4,%rbx
cmp    %rsi,%r14
jl     1190 <main+0x70>
test   %esi,%esi
mov    -0x40(%rbp),%r14
mov    -0x38(%rbp),%r12
jle    11dc <main+0xbc>
xor    %ebx,%ebx
movsd  -0x48(%rbp),%xmm0
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <down_from@plt>
add    $0x1,%ebx
mov    -0x2c(%rbp),%esi
cmp    %esi,%ebx
jl     11c0 <main+0xa0>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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