#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 snprintf(char *, size_t, char *, char const *, int, int, int, char const *);
char *get_tile_path_r(char *buffer, size_t size, const char *prefix, int x,
                      int y, int zoom, const char *suffix) {
  if (snprintf(buffer, size, "%s/%d/%d/%d%s", prefix, zoom, x, y, suffix) >=
      (int)size)
    return NULL;
  return buffer;
}


x86 assembly (clang, -O0):
<get_tile_path_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x28(%rbp),%r10d
mov    0x10(%rbp),%rax
lea    0xeaa(%rip),%rdx
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rcx
cmp    %ecx,%eax
jl     117d <get_tile_path_r+0x6d>
movq   $0x0,-0x8(%rbp)
jmp    1185 <get_tile_path_r+0x75>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tile_path_r>:
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r10d
mov    %ecx,%eax
mov    %rdx,%rcx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xed7(%rip),%rdx
mov    %r9d,%r8d
mov    %eax,%r9d
push   0x20(%rsp)
push   %r10
call   1030 <snprintf@plt>
add    $0x10,%rsp
xor    %ecx,%ecx
cmp    %ebx,%eax
cmovl  %r14,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%s/%d/%d/%d%s\00"
define i8* @get_tile_path_r(i8* %0, i64 %1, i8* %2, i32 %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store i8* %0, i8** %9
store i64 %1, i64* %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i8* %6, i8** %15
%16 = load i8*, i8** %9
%17 = load i64, i64* %10
%18 = load i8*, i8** %11
%19 = load i32, i32* %14
%20 = load i32, i32* %12
%21 = load i32, i32* %13
%22 = load i8*, i8** %15
%23 = call i32 @snprintf(i8* %16, i64 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19, i32 %20, i32 %21, i8* %22)
%24 = load i64, i64* %10
%25 = trunc i64 %24 to i32
%26 = icmp sge i32 %23, %25
br i1 %26, label %27, label %28
27: ; preds = %7
store i8* null, i8** %8
br label %30
28: ; preds = %7
%29 = load i8*, i8** %9
store i8* %29, i8** %8
br label %30
30: ; preds = %28, %27
%31 = load i8*, i8** %8
ret i8* %31
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s/%d/%d/%d%s\00"
define i8* @get_tile_path_r(i8* %0, i64 %1, i8* %2, i32 %3, i32 %4, i32 %5, i8* %6) {
%8 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %5, i32 %3, i32 %4, i8* %6)
%9 = trunc i64 %1 to i32
%10 = icmp slt i32 %8, %9
%11 = select i1 %10, i8* %0, i8* null
ret i8* %11
}