#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, ...);
scalar_t__ strlen(char const *);
int xyzo_to_meta(char *path, size_t len, const char *tile_dir,
                 const char *xmlconfig, const char *options, int x, int y,
                 int z) {
  unsigned char i, hash[5], offset, mask;
  mask = (8) - 1;
  offset = (x & mask) * (8) + (y & mask);
  x &= ~mask;
  y &= ~mask;
  for (i = 0; i < 5; i++) {
    hash[i] = ((x & 0x0f) << 4) | (y & 0x0f);
    x >>= 4;
    y >>= 4;
  }
  if (strlen(options)) {
    snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.%s.meta", tile_dir, xmlconfig,
             z, hash[4], hash[3], hash[2], hash[1], hash[0], options);
  } else {
    snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.meta", tile_dir, xmlconfig, z,
             hash[4], hash[3], hash[2], hash[1], hash[0]);
  }
  return offset;
}


x86 assembly (clang, -O0):
<xyzo_to_meta>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9d,-0x44(%rbp)
movb   $0x7,-0x4c(%rbp)
mov    -0x44(%rbp),%eax
movzbl -0x4c(%rbp),%ecx
and    %ecx,%eax
shl    $0x3,%eax
mov    0x10(%rbp),%ecx
movzbl -0x4c(%rbp),%edx
and    %edx,%ecx
add    %ecx,%eax
mov    %al,-0x4b(%rbp)
movzbl -0x4c(%rbp),%eax
xor    $0xffffffff,%eax
and    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
movzbl -0x4c(%rbp),%eax
xor    $0xffffffff,%eax
and    0x10(%rbp),%eax
mov    %eax,0x10(%rbp)
movb   $0x0,-0x45(%rbp)
movzbl -0x45(%rbp),%eax
cmp    $0x5,%eax
jge    11ce <xyzo_to_meta+0xae>
mov    -0x44(%rbp),%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    0x10(%rbp),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %al,%cl
movzbl -0x45(%rbp),%eax
mov    %cl,-0x4a(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x44(%rbp)
mov    0x10(%rbp),%eax
sar    $0x4,%eax
mov    %eax,0x10(%rbp)
mov    -0x45(%rbp),%al
add    $0x1,%al
mov    %al,-0x45(%rbp)
jmp    1187 <xyzo_to_meta+0x67>
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     124e <xyzo_to_meta+0x12e>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    0x18(%rbp),%r9d
mov    -0x46(%rbp),%r15b
mov    -0x47(%rbp),%r14b
mov    -0x48(%rbp),%bl
mov    -0x49(%rbp),%r11b
mov    -0x4a(%rbp),%r10b
mov    -0x40(%rbp),%rax
lea    0xded(%rip),%rdx
movzbl %r15b,%r15d
mov    %r15d,(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x8(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x10(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x18(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x20(%rsp)
mov    %rax,0x28(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    12a5 <xyzo_to_meta+0x185>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    0x18(%rbp),%r9d
mov    -0x46(%rbp),%bl
mov    -0x47(%rbp),%r11b
mov    -0x48(%rbp),%r10b
mov    -0x49(%rbp),%al
lea    0xda9(%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 -0x4a(%rbp),%eax
mov    %eax,0x20(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
movzbl -0x4b(%rbp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<xyzo_to_meta>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%r10
mov    %rcx,%r8
mov    %rdx,%rcx
mov    0x48(%rsp),%r9d
mov    0x40(%rsp),%r15d
mov    %r14d,%eax
and    $0x8,%eax
shl    $0x4,%eax
mov    %r15d,%r11d
and    $0x8,%r11d
or     %eax,%r11d
mov    %r15d,%r12d
shr    $0x4,%r12d
mov    %r14d,%eax
and    $0xf0,%eax
and    $0xf,%r12d
or     %eax,%r12d
mov    %r15d,%ebx
shr    $0x8,%ebx
mov    %r14d,%eax
shr    $0x4,%eax
and    $0xf0,%eax
and    $0xf,%ebx
or     %eax,%ebx
mov    %r15d,%eax
shr    $0xc,%eax
mov    %r14d,%ebp
shr    $0x8,%ebp
and    $0xf0,%ebp
and    $0xf,%eax
or     %ebp,%eax
mov    %r15d,%ebp
shr    $0x10,%ebp
mov    %r14d,%edx
shr    $0xc,%edx
and    $0xf0,%edx
and    $0xf,%ebp
or     %edx,%ebp
cmpb   $0x0,(%r10)
je     11cb <xyzo_to_meta+0xbb>
movzbl %r11b,%r11d
movzbl %r12b,%r12d
movzbl %bl,%ebx
movzbl %al,%r13d
movzbl %bpl,%ebp
lea    0xe42(%rip),%rdx
xor    %eax,%eax
push   %r10
push   %r11
push   %r12
push   %rbx
push   %r13
jmp    11f2 <xyzo_to_meta+0xe2>
sub    $0x8,%rsp
movzbl %r11b,%r10d
movzbl %r12b,%r11d
movzbl %bl,%ebx
movzbl %al,%r12d
movzbl %bpl,%ebp
lea    0xe37(%rip),%rdx
xor    %eax,%eax
push   %r10
push   %r11
push   %rbx
push   %r12
push   %rbp
call   1030 <snprintf@plt>
add    $0x30,%rsp
and    $0x7,%r14d
and    $0x7,%r15d
lea    (%r15,%r14,8),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.%s.meta\00"
@.str.1 = [29 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.meta\00"
define i32 @xyzo_to_meta(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8
%18 = alloca [5 x i8]
%19 = alloca i8
%20 = alloca i8
store i8* %0, i8** %9
store i64 %1, i64* %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i8 7, i8* %20
%21 = load i32, i32* %14
%22 = load i8, i8* %20
%23 = zext i8 %22 to i32
%24 = and i32 %21, %23
%25 = mul nsw i32 %24, 8
%26 = load i32, i32* %15
%27 = load i8, i8* %20
%28 = zext i8 %27 to i32
%29 = and i32 %26, %28
%30 = add nsw i32 %25, %29
%31 = trunc i32 %30 to i8
store i8 %31, i8* %19
%32 = load i8, i8* %20
%33 = zext i8 %32 to i32
%34 = xor i32 %33, -1
%35 = load i32, i32* %14
%36 = and i32 %35, %34
store i32 %36, i32* %14
%37 = load i8, i8* %20
%38 = zext i8 %37 to i32
%39 = xor i32 %38, -1
%40 = load i32, i32* %15
%41 = and i32 %40, %39
store i32 %41, i32* %15
store i8 0, i8* %17
br label %42
42: ; preds = %61, %8
%43 = load i8, i8* %17
%44 = zext i8 %43 to i32
%45 = icmp slt i32 %44, 5
br i1 %45, label %46, label %64
46: ; preds = %42
%47 = load i32, i32* %14
%48 = and i32 %47, 15
%49 = shl i32 %48, 4
%50 = load i32, i32* %15
%51 = and i32 %50, 15
%52 = or i32 %49, %51
%53 = trunc i32 %52 to i8
%54 = load i8, i8* %17
%55 = zext i8 %54 to i64
%56 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 %55
store i8 %53, i8* %56
%57 = load i32, i32* %14
%58 = ashr i32 %57, 4
store i32 %58, i32* %14
%59 = load i32, i32* %15
%60 = ashr i32 %59, 4
store i32 %60, i32* %15
br label %61
61: ; preds = %46
%62 = load i8, i8* %17
%63 = add i8 %62, 1
store i8 %63, i8* %17
br label %42
64: ; preds = %42
%65 = load i8*, i8** %13
%66 = call i64 @strlen(i8* %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %86
68: ; preds = %64
%69 = load i8*, i8** %9
%70 = load i64, i64* %10
%71 = load i8*, i8** %11
%72 = load i8*, i8** %12
%73 = load i32, i32* %16
%74 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 4
%75 = load i8, i8* %74
%76 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 3
%77 = load i8, i8* %76
%78 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 2
%79 = load i8, i8* %78
%80 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 1
%81 = load i8, i8* %80
%82 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 0
%83 = load i8, i8* %82
%84 = load i8*, i8** %13
%85 = call i32 (i8*, i64, i8*, i8*, i8*, i32, i8, i8, i8, i8, i8, ...) @snprintf(i8* %69, i64 %70, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %71, i8* %72, i32 %73, i8 zeroext %75, i8 zeroext %77, i8 zeroext %79, i8 zeroext %81, i8 zeroext %83, i8* %84)
br label %103
86: ; preds = %64
%87 = load i8*, i8** %9
%88 = load i64, i64* %10
%89 = load i8*, i8** %11
%90 = load i8*, i8** %12
%91 = load i32, i32* %16
%92 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 4
%93 = load i8, i8* %92
%94 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 3
%95 = load i8, i8* %94
%96 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 2
%97 = load i8, i8* %96
%98 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 1
%99 = load i8, i8* %98
%100 = getelementptr inbounds [5 x i8], [5 x i8]* %18, i64 0, i64 0
%101 = load i8, i8* %100
%102 = call i32 (i8*, i64, i8*, i8*, i8*, i32, i8, i8, i8, i8, i8, ...) @snprintf(i8* %87, i64 %88, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %89, i8* %90, i32 %91, i8 zeroext %93, i8 zeroext %95, i8 zeroext %97, i8 zeroext %99, i8 zeroext %101)
br label %103
103: ; preds = %86, %68
%104 = load i8, i8* %19
%105 = zext i8 %104 to i32
ret i32 %105
}

LLVM IR (-O2):
@.str = [32 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.%s.meta\00"
@.str.1 = [29 x i8] c"%s/%s/%d/%u/%u/%u/%u/%u.meta\00"
define i32 @xyzo_to_meta(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7) {
%9 = shl i32 %5, 4
%10 = and i32 %9, 128
%11 = and i32 %6, 8
%12 = or i32 %10, %11
%13 = trunc i32 %12 to i8
%14 = lshr i32 %6, 4
%15 = and i32 %5, 240
%16 = and i32 %14, 15
%17 = or i32 %15, %16
%18 = trunc i32 %17 to i8
%19 = lshr i32 %6, 8
%20 = lshr i32 %5, 4
%21 = and i32 %20, 240
%22 = and i32 %19, 15
%23 = or i32 %21, %22
%24 = trunc i32 %23 to i8
%25 = lshr i32 %6, 12
%26 = lshr i32 %5, 8
%27 = and i32 %26, 240
%28 = and i32 %25, 15
%29 = or i32 %27, %28
%30 = trunc i32 %29 to i8
%31 = lshr i32 %6, 16
%32 = lshr i32 %5, 12
%33 = and i32 %32, 240
%34 = and i32 %31, 15
%35 = or i32 %33, %34
%36 = trunc i32 %35 to i8
%37 = load i8, i8* %4
%38 = icmp eq i8 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %8
%40 = tail call i32 (i8*, i64, i8*, i8*, i8*, i32, i8, i8, i8, i8, i8, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i32 %7, i8 zeroext %36, i8 zeroext %30, i8 zeroext %24, i8 zeroext %18, i8 zeroext %13, i8* %4)
br label %43
41: ; preds = %8
%42 = tail call i32 (i8*, i64, i8*, i8*, i8*, i32, i8, i8, i8, i8, i8, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3, i32 %7, i8 zeroext %36, i8 zeroext %30, i8 zeroext %24, i8 zeroext %18, i8 zeroext %13)
br label %43
43: ; preds = %41, %39
%44 = shl i32 %5, 3
%45 = and i32 %44, 56
%46 = and i32 %6, 7
%47 = or i32 %45, %46
ret i32 %47
}