#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*/ fast_encode(char *, long, int);
void encode_triple(char *result, long difx, long dify) {
  if (dify < 4 * 34) {
    fast_encode(result, ((difx / 28) + 6 * (dify / 34)), 1);
    fast_encode(result + 1, ((difx % 28) * 34 + (dify % 34)), 2);
  } else {
    fast_encode(result, (difx / 24) + 24, 1);
    fast_encode(result + 1, (difx % 24) * 40 + (dify - 136), 2);
  }
}


x86 assembly (clang, -O0):
<encode_triple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x88,-0x18(%rbp)
jge    11a0 <encode_triple+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x1c,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
mov    -0x18(%rbp),%rax
mov    $0x22,%ecx
cqto
idiv   %rcx
imul   $0x6,%rax,%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <fast_encode@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
mov    $0x1c,%ecx
cqto
idiv   %rcx
imul   $0x22,%rdx,%rsi
mov    -0x18(%rbp),%rax
mov    $0x22,%ecx
cqto
idiv   %rcx
add    %rdx,%rsi
mov    $0x2,%edx
call   1030 <fast_encode@plt>
jmp    11f4 <encode_triple+0xe4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
add    $0x18,%rsi
mov    $0x1,%edx
call   1030 <fast_encode@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
imul   $0x28,%rdx,%rsi
mov    -0x18(%rbp),%rax
sub    $0x88,%rax
add    %rax,%rsi
mov    $0x2,%edx
call   1030 <fast_encode@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_triple>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
cmp    $0x87,%rdx
jg     11c3 <encode_triple+0xb3>
movabs $0x7878787878787879,%rcx
78 78 78
mov    %r15,%rax
imul   %rcx
mov    %rdx,%r13
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x4,%r13
add    %rax,%r13
lea    0x0(,%r13,2),%rcx
add    %r13,%rcx
movabs $0x4924924924924925,%rdx
92 24 49
mov    %r12,%rax
imul   %rdx
mov    %rdx,%rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x3,%rbx
add    %rax,%rbx
lea    (%rbx,%rcx,2),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <fast_encode@plt>
add    $0x1,%r14
lea    (%rbx,%rbx,8),%rax
lea    (%rax,%rax,2),%rax
add    %rbx,%rax
sub    %rax,%r12
mov    %r12,%rax
shl    $0x5,%rax
lea    (%rax,%r12,2),%rax
mov    %r13,%rcx
shl    $0x5,%rcx
lea    (%rcx,%r13,2),%rcx
sub    %rcx,%r15
add    %rax,%r15
mov    %r14,%rdi
mov    %r15,%rsi
jmp    121a <encode_triple+0x10a>
movabs $0x2aaaaaaaaaaaaaab,%rcx
aa aa 2a
mov    %r12,%rax
imul   %rcx
mov    %rdx,%rbx
mov    %rdx,%r13
shr    $0x3f,%r13
sar    $0x2,%rbx
lea    (%rbx,%r13,1),%rsi
add    $0x18,%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <fast_encode@plt>
add    $0x1,%r14
add    %r13,%rbx
shl    $0x3,%rbx
lea    (%rbx,%rbx,2),%rax
sub    %rax,%r12
lea    (%r12,%r12,4),%rax
lea    (%r15,%rax,8),%rsi
add    $0xffffffffffffff78,%rsi
mov    %r14,%rdi
mov    $0x2,%edx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fast_encode@plt>

LLVM IR (-O0):
define void @encode_triple(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
%8 = icmp slt i64 %7, 136
br i1 %8, label %9, label %27
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i64, i64* %5
%12 = sdiv i64 %11, 28
%13 = load i64, i64* %6
%14 = sdiv i64 %13, 34
%15 = mul nsw i64 6, %14
%16 = add nsw i64 %12, %15
%17 = call i32 @fast_encode(i8* %10, i64 %16, i32 1)
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i64, i64* %5
%21 = srem i64 %20, 28
%22 = mul nsw i64 %21, 34
%23 = load i64, i64* %6
%24 = srem i64 %23, 34
%25 = add nsw i64 %22, %24
%26 = call i32 @fast_encode(i8* %19, i64 %25, i32 2)
br label %42
27: ; preds = %3
%28 = load i8*, i8** %4
%29 = load i64, i64* %5
%30 = sdiv i64 %29, 24
%31 = add nsw i64 %30, 24
%32 = call i32 @fast_encode(i8* %28, i64 %31, i32 1)
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i64, i64* %5
%36 = srem i64 %35, 24
%37 = mul nsw i64 %36, 40
%38 = load i64, i64* %6
%39 = sub nsw i64 %38, 136
%40 = add nsw i64 %37, %39
%41 = call i32 @fast_encode(i8* %34, i64 %40, i32 2)
br label %42
42: ; preds = %27, %9
ret void
}

LLVM IR (-O2):
define void @encode_triple(i8* %0, i64 %1, i64 %2) {
%4 = icmp slt i64 %2, 136
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = sdiv i64 %1, 28
%7 = sdiv i64 %2, 34
%8 = mul nsw i64 %7, 6
%9 = add nsw i64 %8, %6
%10 = tail call i32 @fast_encode(i8* %0, i64 %9, i32 1)
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = srem i64 %1, 28
%13 = mul nsw i64 %12, 34
%14 = srem i64 %2, 34
%15 = add nsw i64 %13, %14
%16 = tail call i32 @fast_encode(i8* %11, i64 %15, i32 2)
br label %27
17: ; preds = %3
%18 = sdiv i64 %1, 24
%19 = add nsw i64 %18, 24
%20 = tail call i32 @fast_encode(i8* %0, i64 %19, i32 1)
%21 = getelementptr inbounds i8, i8* %0, i64 1
%22 = srem i64 %1, 24
%23 = mul nsw i64 %22, 40
%24 = add nsw i64 %2, -136
%25 = add nsw i64 %24, %23
%26 = tail call i32 @fast_encode(i8* %21, i64 %25, i32 2)
br label %27
27: ; preds = %17, %5
ret void
}