#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 *, long long, long long);
int scanf(char *, long long *);
int main() {
  long long s, i, sum;
  while (scanf("%lld", &s) == 1) {
    if (s == 0)
      break;
    sum = 0;
    for (i = 1; sum <= s; i++)
      sum += i;
    printf("%lld %lld\n", sum - s, i - 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11b4 <main+0x94>
cmpq   $0x0,-0x10(%rbp)
jne    1158 <main+0x38>
jmp    11b4 <main+0x94>
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     1193 <main+0x73>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <main+0x48>
mov    -0x20(%rbp),%rsi
sub    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
sub    $0x1,%rdx
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a5 <main+0x85>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11a5 <main+0x85>
lea    0xeb5(%rip),%r14
lea    0xea9(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    $0x1,%edx
xor    %esi,%esi
test   %rax,%rax
js     117c <main+0x5c>
nopl   0x0(%rax)
add    %rdx,%rsi
add    $0x1,%rdx
cmp    %rax,%rsi
jle    1170 <main+0x50>
sub    %rax,%rsi
add    $0xffffffffffffffff,%rdx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a5 <main+0x85>
mov    0x8(%rsp),%rax
test   %rax,%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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