#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 */
scalar_t__ atoll(char *);
double floor(int);
int /*<<< orphan*/ printf(char *, int, int);
int sqrt(int);
int main(int argc, char **argv) {
  double z = (double)atoll(argv[1]);
  double w = floor((sqrt(8 * z + 1) - 1) / 2.0);
  double t = (w * w + w) / 2.0;
  double y = z - t;
  double x = w - y;
  printf("LP: %d, mark: %d\n", (int)x, (int)y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoll@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe2d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x38(%rbp),%esi
cvttsd2si -0x30(%rbp),%edx
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <atoll@plt>
cvtsi2sd %rax,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xea4(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xea0(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe8d(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <floor@plt>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe70(%rip),%xmm1
movsd  (%rsp),%xmm2
subsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%esi
cvttsd2si %xmm2,%edx
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"LP: %d, mark: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @atoll(i8* %13)
%15 = sitofp i64 %14 to double
store double %15, double* %6
%16 = load double, double* %6
%17 = call double @llvm.fmuladd.f64(double 8.000000e+00, double %16, double 1.000000e+00)
%18 = fptosi double %17 to i32
%19 = call i32 @sqrt(i32 %18)
%20 = sub nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 2.000000e+00
%23 = fptosi double %22 to i32
%24 = call double @floor(i32 %23)
store double %24, double* %7
%25 = load double, double* %7
%26 = load double, double* %7
%27 = load double, double* %7
%28 = call double @llvm.fmuladd.f64(double %25, double %26, double %27)
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %8
%30 = load double, double* %6
%31 = load double, double* %8
%32 = fsub double %30, %31
store double %32, double* %9
%33 = load double, double* %7
%34 = load double, double* %9
%35 = fsub double %33, %34
store double %35, double* %10
%36 = load double, double* %10
%37 = fptosi double %36 to i32
%38 = load double, double* %9
%39 = fptosi double %38 to i32
%40 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"LP: %d, mark: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @atoll(i8* %4)
%6 = sitofp i64 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double 8.000000e+00, double 1.000000e+00)
%8 = fptosi double %7 to i32
%9 = tail call i32 @sqrt(i32 %8)
%10 = add nsw i32 %9, -1
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 5.000000e-01
%13 = fptosi double %12 to i32
%14 = tail call double @floor(i32 %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %14)
%16 = fmul double %15, 5.000000e-01
%17 = fsub double %6, %16
%18 = fsub double %14, %17
%19 = fptosi double %18 to i32
%20 = fptosi double %17 to i32
%21 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
ret i32 0
}