#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 */
typedef int /*<<< orphan*/ n;

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ order(int, int *, int *);
int /*<<< orphan*/ print_array(int, int *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n;
  int *times;
  int *arranged;
  scanf("%d", &n);
  times = (int *)malloc(n * sizeof(n));
  arranged = (int *)malloc(n * sizeof(n));
  for (int i = 0; i < n; i++) {
    int arrival, time;
    scanf("%d %d", &arrival, &time);
    times[i] = arrival + time;
    arranged[i] = i + 1;
  }
  order(n, times, arranged);
  print_array(n, arranged);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e0 <main+0xa0>
lea    0xe5f(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x20(%rbp),%edx
add    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118e <main+0x4e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <order@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeae(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11d0 <main+0x90>
lea    0xe72(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%eax
add    0x14(%rsp),%eax
mov    %eax,(%r14,%rbp,4)
lea    0x1(%rbp),%rax
mov    %eax,(%rbx,%rbp,4)
movslq 0xc(%rsp),%rdi
mov    %rax,%rbp
cmp    %rdi,%rax
jl     11a0 <main+0x60>
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <order@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x18,%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 = [6 x i8] c"%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
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %4
store i32 0, i32* %5
br label %21
21: ; preds = %40, %0
%22 = load i32, i32* %5
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %43
25: ; preds = %21
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = add nsw i32 %27, %28
%30 = load i32*, i32** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = load i32*, i32** %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 %35, i32* %39
br label %40
40: ; preds = %25
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %21
43: ; preds = %21
%44 = load i32, i32* %2
%45 = load i32*, i32** %3
%46 = load i32*, i32** %4
%47 = call i32 @order(i32 %44, i32* %45, i32* %46)
%48 = load i32, i32* %2
%49 = load i32*, i32** %4
%50 = call i32 @print_array(i32 %48, i32* %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @main() {
%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 = shl i32 %6, 2
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = load i32, i32* %1
%11 = shl i32 %10, 2
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = bitcast i32* %2 to i8*
%18 = bitcast i32* %3 to i8*
br label %24
19: ; preds = %24, %0
%20 = phi i32 [ %14, %0 ], [ %34, %24 ]
%21 = call i32 @order(i32 %20, i32* %9, i32* %13)
%22 = load i32, i32* %1
%23 = call i32 @print_array(i32 %22, i32* %13)
ret i32 0
24: ; preds = %16, %24
%25 = phi i64 [ 0, %16 ], [ %31, %24 ]
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, %27
%30 = getelementptr inbounds i32, i32* %9, i64 %25
store i32 %29, i32* %30
%31 = add nuw nsw i64 %25, 1
%32 = getelementptr inbounds i32, i32* %13, i64 %25
%33 = trunc i64 %31 to i32
store i32 %33, i32* %32
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %31, %35
br i1 %36, label %24, label %19
}