#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*/ assert(int);
unsigned int fx(unsigned int);
int /*<<< orphan*/ hex_rki2xy(unsigned int, unsigned int, unsigned int, int *,
                              int *);
void hex_unlineate(unsigned int l, signed int *x, signed int *y) {
  unsigned int r = 0, k = 0, i = 0;
  int remainder;
  if (l == 0) {
    *x = 0;
    *y = 0;
    return;
  }
  while (fx(r) <= l) {
    r++;
  }
  remainder = l - fx(r - 1);
  assert(r != 0);
  k = remainder / r;
  i = remainder % r;
  hex_rki2xy(r, k, i, x, y);
  return;
}


x86 assembly (clang, -O0):
<hex_unlineate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117b <hex_unlineate+0x4b>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11f7 <hex_unlineate+0xc7>
jmp    1180 <hex_unlineate+0x50>
mov    -0x1c(%rbp),%edi
call   1030 <fx@plt>
cmp    -0x4(%rbp),%eax
ja     119f <hex_unlineate+0x6f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1180 <hex_unlineate+0x50>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
call   1030 <fx@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%eax
xor    %edx,%edx
divl   -0x1c(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
xor    %edx,%edx
divl   -0x1c(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1050 <hex_rki2xy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_unlineate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
test   %edi,%edi
je     1196 <hex_unlineate+0x66>
mov    %edi,%ebp
mov    $0xffffffff,%ebx
nopl   0x0(%rax)
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <fx@plt>
cmp    %ebp,%eax
jbe    1150 <hex_unlineate+0x20>
xor    %r12d,%r12d
mov    %ebx,%edi
add    $0xffffffff,%edi
setb   %r12b
call   1030 <fx@plt>
sub    %eax,%ebp
mov    %r12d,%edi
call   1040 <assert@plt>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %ebx,%edi
mov    %eax,%esi
mov    %r15,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <hex_rki2xy@plt>
movl   $0x0,(%r15)
movl   $0x0,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hex_unlineate(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i32*, i32** %5
store i32 0, i32* %14
%15 = load i32*, i32** %6
store i32 0, i32* %15
br label %47
16: ; preds = %3
br label %17
17: ; preds = %22, %16
%18 = load i32, i32* %7
%19 = call i32 @fx(i32 %18)
%20 = load i32, i32* %4
%21 = icmp ule i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %7
%24 = add i32 %23, 1
store i32 %24, i32* %7
br label %17
25: ; preds = %17
%26 = load i32, i32* %4
%27 = load i32, i32* %7
%28 = sub i32 %27, 1
%29 = call i32 @fx(i32 %28)
%30 = sub i32 %26, %29
store i32 %30, i32* %10
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %10
%36 = load i32, i32* %7
%37 = udiv i32 %35, %36
store i32 %37, i32* %8
%38 = load i32, i32* %10
%39 = load i32, i32* %7
%40 = urem i32 %38, %39
store i32 %40, i32* %9
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = load i32*, i32** %5
%45 = load i32*, i32** %6
%46 = call i32 @hex_rki2xy(i32 %41, i32 %42, i32 %43, i32* %44, i32* %45)
br label %47
47: ; preds = %25, %13
ret void
}

LLVM IR (-O2):
define void @hex_unlineate(i32 %0, i32* %1, i32* %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %6
5: ; preds = %3
store i32 0, i32* %1
store i32 0, i32* %2
br label %21
6: ; preds = %3, %6
%7 = phi i32 [ %10, %6 ], [ 0, %3 ]
%8 = tail call i32 @fx(i32 %7)
%9 = icmp ugt i32 %8, %0
%10 = add i32 %7, 1
br i1 %9, label %11, label %6
11: ; preds = %6
%12 = add i32 %7, -1
%13 = tail call i32 @fx(i32 %12)
%14 = sub i32 %0, %13
%15 = icmp ne i32 %7, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = udiv i32 %14, %7
%19 = urem i32 %14, %7
%20 = tail call i32 @hex_rki2xy(i32 %7, i32 %18, i32 %19, i32* %1, i32* %2)
br label %21
21: ; preds = %11, %5
ret void
}