#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*/ snprintf(char *, size_t, char *, char const *, char const *,
                            int, unsigned char, unsigned char, unsigned char,
                            unsigned char, unsigned char);
void xyz_to_path(char *path, size_t len, const char *tile_dir,
                 const char *xmlconfig, int x, int y, int z) {
  unsigned char i, hash[5];
  for (i = 0; i < 5; i++) {
    hash[i] = ((x & 0x0f) << 4) | (y & 0x0f);
    x >>= 4;
    y >>= 4;
  }
  snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.png", tile_dir, xmlconfig, z,
           hash[4], hash[3], hash[2], hash[1], hash[0]);
  return;
}


x86 assembly (clang, -O0):
<xyz_to_path>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
movb   $0x0,-0x31(%rbp)
movzbl -0x31(%rbp),%eax
cmp    $0x5,%eax
jge    117f <xyz_to_path+0x6f>
mov    -0x2c(%rbp),%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    -0x30(%rbp),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %al,%cl
movzbl -0x31(%rbp),%eax
mov    %cl,-0x36(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x30(%rbp)
mov    -0x31(%rbp),%al
add    $0x1,%al
mov    %al,-0x31(%rbp)
jmp    1138 <xyz_to_path+0x28>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    -0x32(%rbp),%bl
mov    -0x33(%rbp),%r11b
mov    -0x34(%rbp),%r10b
mov    -0x35(%rbp),%al
lea    0xe58(%rip),%rdx
movzbl %bl,%ebx
mov    %ebx,(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x8(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x10(%rsp)
movzbl %al,%eax
mov    %eax,0x18(%rsp)
movzbl -0x36(%rbp),%eax
mov    %eax,0x20(%rsp)
call   1030 <snprintf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<xyz_to_path>:
push   %rbp
push   %r14
push   %rbx
mov    %r9d,%ebx
mov    %rcx,%r10
mov    %rdx,%rcx
mov    0x20(%rsp),%r9d
mov    %r8d,%eax
shl    $0x4,%eax
mov    %ebx,%edx
and    $0xf,%edx
or     %eax,%edx
mov    %ebx,%r11d
shr    $0x4,%r11d
mov    %r8d,%eax
and    $0xf0,%eax
and    $0xf,%r11d
or     %eax,%r11d
mov    %ebx,%r14d
shr    $0x8,%r14d
mov    %r8d,%eax
shr    $0x4,%eax
and    $0xf0,%eax
and    $0xf,%r14d
or     %eax,%r14d
mov    %ebx,%eax
shr    $0xc,%eax
mov    %r8d,%ebp
shr    $0x8,%ebp
and    $0xf0,%ebp
and    $0xf,%eax
or     %ebp,%eax
shr    $0x10,%ebx
shr    $0xc,%r8d
and    $0xf0,%r8d
and    $0xf,%ebx
or     %r8d,%ebx
sub    $0x8,%rsp
movzbl %dl,%ebp
lea    0xe6a(%rip),%rdx
mov    %r10,%r8
push   %rbp
push   %r11
push   %r14
push   %rax
push   %rbx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.png\00"
define void @xyz_to_path(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
%16 = alloca [5 x i8]
store i8* %0, i8** %8
store i64 %1, i64* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
store i8 0, i8* %15
br label %17
17: ; preds = %36, %7
%18 = load i8, i8* %15
%19 = zext i8 %18 to i32
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %39
21: ; preds = %17
%22 = load i32, i32* %12
%23 = and i32 %22, 15
%24 = shl i32 %23, 4
%25 = load i32, i32* %13
%26 = and i32 %25, 15
%27 = or i32 %24, %26
%28 = trunc i32 %27 to i8
%29 = load i8, i8* %15
%30 = zext i8 %29 to i64
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 %30
store i8 %28, i8* %31
%32 = load i32, i32* %12
%33 = ashr i32 %32, 4
store i32 %33, i32* %12
%34 = load i32, i32* %13
%35 = ashr i32 %34, 4
store i32 %35, i32* %13
br label %36
36: ; preds = %21
%37 = load i8, i8* %15
%38 = add i8 %37, 1
store i8 %38, i8* %15
br label %17
39: ; preds = %17
%40 = load i8*, i8** %8
%41 = load i64, i64* %9
%42 = load i8*, i8** %10
%43 = load i8*, i8** %11
%44 = load i32, i32* %14
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 4
%46 = load i8, i8* %45
%47 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 3
%48 = load i8, i8* %47
%49 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 2
%50 = load i8, i8* %49
%51 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 1
%52 = load i8, i8* %51
%53 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%54 = load i8, i8* %53
%55 = call i32 @snprintf(i8* %40, i64 %41, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %42, i8* %43, i32 %44, i8 zeroext %46, i8 zeroext %48, i8 zeroext %50, i8 zeroext %52, i8 zeroext %54)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.png\00"
define void @xyz_to_path(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = shl i32 %4, 4
%9 = and i32 %5, 15
%10 = or i32 %8, %9
%11 = trunc i32 %10 to i8
%12 = lshr i32 %5, 4
%13 = and i32 %4, 240
%14 = and i32 %12, 15
%15 = or i32 %13, %14
%16 = trunc i32 %15 to i8
%17 = lshr i32 %5, 8
%18 = lshr i32 %4, 4
%19 = and i32 %18, 240
%20 = and i32 %17, 15
%21 = or i32 %19, %20
%22 = trunc i32 %21 to i8
%23 = lshr i32 %5, 12
%24 = lshr i32 %4, 8
%25 = and i32 %24, 240
%26 = and i32 %23, 15
%27 = or i32 %25, %26
%28 = trunc i32 %27 to i8
%29 = lshr i32 %5, 16
%30 = lshr i32 %4, 12
%31 = and i32 %30, 240
%32 = and i32 %29, 15
%33 = or i32 %31, %32
%34 = trunc i32 %33 to i8
%35 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i32 %6, i8 zeroext %34, i8 zeroext %28, i8 zeroext %22, i8 zeroext %16, i8 zeroext %11)
ret void
}