#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*/ MapsWithMe_AppendString(char *, int, int *, char *,
                                           size_t const);
char MapsWithMe_Base64Char(int const);
int /*<<< orphan*/ MapsWithMe_LatLonToString(double, double, char *, int);
int /*<<< orphan*/ MapsWithMe_TransformName(char *);
size_t MapsWithMe_UrlEncodeString(char *, int /*<<< orphan*/, char **);
int /*<<< orphan*/ free(char *);
char *strdup(char const *);
int /*<<< orphan*/ strlen(char *);
int MapsWithMe_GenShortShowMapUrl(double lat, double lon, double zoom,
                                  char const *name, char *buf, int bufSize) {
  int fullUrlSize = 0;
  char urlPrefix[] = "ge0://ZCoord6789";
  int const zoomI =
      (zoom <= 4 ? 0 : (zoom >= 19.75 ? 63 : (int)((zoom - 4) * 4)));
  urlPrefix[6] = MapsWithMe_Base64Char(zoomI);
  MapsWithMe_LatLonToString(lat, lon, urlPrefix + 7, 9);
  MapsWithMe_AppendString(buf, bufSize, &fullUrlSize, urlPrefix, 16);
  if (name != 0 && name[0] != 0) {
    MapsWithMe_AppendString(buf, bufSize, &fullUrlSize, "/", 1);
    char *newName = strdup(name);
    MapsWithMe_TransformName(newName);
    char *encName;
    size_t const encNameSize =
        MapsWithMe_UrlEncodeString(newName, strlen(newName), &encName);
    MapsWithMe_AppendString(buf, bufSize, &fullUrlSize, encName, encNameSize);
    free(encName);
    free(newName);
  }
  return fullUrlSize;
}


x86 assembly (clang, -O0):
<MapsWithMe_GenShortShowMapUrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0xe5d(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe58(%rip),%al
mov    %al,-0x40(%rbp)
movsd  0xe2d(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11e8 <MapsWithMe_GenShortShowMapUrl+0x68>
xor    %eax,%eax
mov    %eax,-0x74(%rbp)
jmp    1236 <MapsWithMe_GenShortShowMapUrl+0xb6>
movsd  -0x18(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     120c <MapsWithMe_GenShortShowMapUrl+0x8c>
mov    $0x3f,%eax
mov    %eax,-0x78(%rbp)
jmp    1230 <MapsWithMe_GenShortShowMapUrl+0xb0>
movsd  -0x18(%rbp),%xmm0
movsd  0xde7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xddb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
call   1080 <MapsWithMe_Base64Char@plt>
mov    %al,-0x4a(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x50(%rbp),%rdi
add    $0x7,%rdi
mov    $0x9,%esi
call   1070 <MapsWithMe_LatLonToString@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x50(%rbp),%rcx
lea    -0x30(%rbp),%rdx
mov    $0x10,%r8d
call   1040 <MapsWithMe_AppendString@plt>
cmpq   $0x0,-0x20(%rbp)
je     1319 <MapsWithMe_GenShortShowMapUrl+0x199>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1319 <MapsWithMe_GenShortShowMapUrl+0x199>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    0xd77(%rip),%rcx
mov    $0x1,%r8d
call   1040 <MapsWithMe_AppendString@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
call   1090 <MapsWithMe_TransformName@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%esi
lea    -0x68(%rbp),%rdx
call   1050 <MapsWithMe_UrlEncodeString@plt>
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x68(%rbp),%rcx
mov    -0x70(%rbp),%r8
lea    -0x30(%rbp),%rdx
call   1040 <MapsWithMe_AppendString@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MapsWithMe_GenShortShowMapUrl>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x28(%rsp)
movl   $0x0,0x4(%rsp)
movaps 0xe72(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
xor    %edi,%edi
movsd  0xe3e(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    11ec <MapsWithMe_GenShortShowMapUrl+0x6c>
ucomisd 0xe38(%rip),%xmm2
addsd  0xe38(%rip),%xmm2
mulsd  0xe20(%rip),%xmm2
cvttsd2si %xmm2,%eax
mov    $0x3f,%edi
cmovb  %eax,%edi
call   1080 <MapsWithMe_Base64Char@plt>
mov    %al,0x16(%rsp)
lea    0x17(%rsp),%rdi
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    $0x9,%esi
call   1070 <MapsWithMe_LatLonToString@plt>
lea    0x4(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    $0x10,%r8d
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <MapsWithMe_AppendString@plt>
test   %rbp,%rbp
je     12a8 <MapsWithMe_GenShortShowMapUrl+0x128>
cmpb   $0x0,0x0(%rbp)
je     12a8 <MapsWithMe_GenShortShowMapUrl+0x128>
lea    0xdf4(%rip),%rcx
lea    0x4(%rsp),%r15
mov    $0x1,%r8d
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1040 <MapsWithMe_AppendString@plt>
mov    %rbp,%rdi
call   10a0 <strdup@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1090 <MapsWithMe_TransformName@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %eax,%esi
call   1050 <MapsWithMe_UrlEncodeString@plt>
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
mov    %rax,%r8
call   1040 <MapsWithMe_AppendString@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.MapsWithMe_GenShortShowMapUrl.urlPrefix = [17 x i8] c"ge0://ZCoord6789\00"
@.str = [2 x i8] c"/\00"
define i32 @MapsWithMe_GenShortShowMapUrl(double %0, double %1, double %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [17 x i8]
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i64
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i32 0, i32* %13
%19 = bitcast [17 x i8]* %14 to i8*
%20 = load double, double* %9
%21 = fcmp ole double %20, 4.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %6
br label %34
23: ; preds = %6
%24 = load double, double* %9
%25 = fcmp oge double %24, 1.975000e+01
br i1 %25, label %26, label %27
26: ; preds = %23
br label %32
27: ; preds = %23
%28 = load double, double* %9
%29 = fsub double %28, 4.000000e+00
%30 = fmul double %29, 4.000000e+00
%31 = fptosi double %30 to i32
br label %32
32: ; preds = %27, %26
%33 = phi i32 [ 63, %26 ], [ %31, %27 ]
br label %34
34: ; preds = %32, %22
%35 = phi i32 [ 0, %22 ], [ %33, %32 ]
store i32 %35, i32* %15
%36 = load i32, i32* %15
%37 = call signext i8 @MapsWithMe_Base64Char(i32 %36)
%38 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 6
store i8 %37, i8* %38
%39 = load double, double* %7
%40 = load double, double* %8
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 7
%43 = call i32 @MapsWithMe_LatLonToString(double %39, double %40, i8* %42, i32 9)
%44 = load i8*, i8** %11
%45 = load i32, i32* %12
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %14, i64 0, i64 0
%47 = call i32 @MapsWithMe_AppendString(i8* %44, i32 %45, i32* %13, i8* %46, i64 16)
%48 = load i8*, i8** %10
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %77
50: ; preds = %34
%51 = load i8*, i8** %10
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %77
56: ; preds = %50
%57 = load i8*, i8** %11
%58 = load i32, i32* %12
%59 = call i32 @MapsWithMe_AppendString(i8* %57, i32 %58, i32* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64 1)
%60 = load i8*, i8** %10
%61 = call i8* @strdup(i8* %60)
store i8* %61, i8** %16
%62 = load i8*, i8** %16
%63 = call i32 @MapsWithMe_TransformName(i8* %62)
%64 = load i8*, i8** %16
%65 = load i8*, i8** %16
%66 = call i32 @strlen(i8* %65)
%67 = call i64 @MapsWithMe_UrlEncodeString(i8* %64, i32 %66, i8** %17)
store i64 %67, i64* %18
%68 = load i8*, i8** %11
%69 = load i32, i32* %12
%70 = load i8*, i8** %17
%71 = load i64, i64* %18
%72 = call i32 @MapsWithMe_AppendString(i8* %68, i32 %69, i32* %13, i8* %70, i64 %71)
%73 = load i8*, i8** %17
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %16
%76 = call i32 @free(i8* %75)
br label %77
77: ; preds = %56, %50, %34
%78 = load i32, i32* %13
ret i32 %78
}

LLVM IR (-O2):
@__const.MapsWithMe_GenShortShowMapUrl.urlPrefix = [17 x i8] c"ge0://ZCoord6789\00"
@.str = [2 x i8] c"/\00"
define i32 @MapsWithMe_GenShortShowMapUrl(double %0, double %1, double %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca [17 x i8]
%9 = alloca i8*
%10 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%12 = fcmp ugt double %2, 4.000000e+00
br i1 %12, label %13, label %19
13: ; preds = %6
%14 = fcmp oge double %2, 1.975000e+01
%15 = fadd double %2, -4.000000e+00
%16 = fmul double %15, 4.000000e+00
%17 = fptosi double %16 to i32
%18 = select i1 %14, i32 63, i32 %17
br label %19
19: ; preds = %6, %13
%20 = phi i32 [ %18, %13 ], [ 0, %6 ]
%21 = tail call signext i8 @MapsWithMe_Base64Char(i32 %20)
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 6
store i8 %21, i8* %22
%23 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 7
%24 = call i32 @MapsWithMe_LatLonToString(double %0, double %1, i8* %23, i32 9)
%25 = call i32 @MapsWithMe_AppendString(i8* %4, i32 %5, i32* %7, i8* %11, i64 16)
%26 = icmp eq i8* %3, null
br i1 %26, label %42, label %27
27: ; preds = %19
%28 = load i8, i8* %3
%29 = icmp eq i8 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %27
%31 = call i32 @MapsWithMe_AppendString(i8* %4, i32 %5, i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64 1)
%32 = call i8* @strdup(i8* %3)
%33 = call i32 @MapsWithMe_TransformName(i8* %32)
%34 = bitcast i8** %9 to i8*
%35 = call i32 @strlen(i8* %32)
%36 = call i64 @MapsWithMe_UrlEncodeString(i8* %32, i32 %35, i8** %9)
%37 = load i8*, i8** %9
%38 = call i32 @MapsWithMe_AppendString(i8* %4, i32 %5, i32* %7, i8* %37, i64 %36)
%39 = load i8*, i8** %9
%40 = call i32 @free(i8* %39)
%41 = call i32 @free(i8* %32)
br label %42
42: ; preds = %30, %27, %19
%43 = load i32, i32* %7
ret i32 %43
}