#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 */
char *calloc(int, int);
char *to_name(int num) {
  char *n = calloc(6, sizeof(char));
  n[0] = '/';
  for (int i = 1; i < 5; i++) {
    n[i] = num % 255 + 1;
    num /= 256;
  }
  n[5] = '\0';
  return n;
}


x86 assembly (clang, -O0):
<to_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x2f,(%rax)
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    117b <to_name+0x6b>
mov    -0x4(%rbp),%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <to_name+0x2c>
mov    -0x10(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xffffff(%rbx),%r14d
test   %edi,%edi
cmovns %edi,%r14d
lea    0xffff(%rbx),%r15d
test   %edi,%edi
cmovns %edi,%r15d
lea    0xff(%rbx),%ebp
test   %edi,%edi
cmovns %edi,%ebp
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
movb   $0x2f,(%rax)
movslq %ebx,%rcx
imul   $0xffffffff80808081,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x7,%edx
add    %esi,%edx
add    %ecx,%edx
add    $0x1,%dl
mov    %dl,0x1(%rax)
sar    $0x8,%ebp
movslq %ebp,%rcx
imul   $0xffffffff80808081,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x7,%edx
add    %esi,%edx
add    %ecx,%edx
add    $0x1,%dl
mov    %dl,0x2(%rax)
sar    $0x10,%r15d
imul   $0xffff8081,%r15d,%ecx
shr    $0x10,%ecx
add    %r15d,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x7,%ecx
add    %edx,%ecx
add    %r15d,%ecx
add    $0x1,%cl
mov    %cl,0x3(%rax)
shr    $0x18,%r14d
add    $0x1,%r14b
mov    %r14b,0x4(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @to_name(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i8* @calloc(i32 6, i32 1)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
store i8 47, i8* %7
store i32 1, i32* %4
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %2
%13 = srem i32 %12, 255
%14 = add nsw i32 %13, 1
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 256
store i32 %21, i32* %2
br label %22
22: ; preds = %11
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %8
25: ; preds = %8
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 5
store i8 0, i8* %27
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
define noalias i8* @to_name(i32 %0) {
%2 = tail call dereferenceable_or_null(6) i8* @calloc(i32 6, i32 1)
store i8 47, i8* %2
%3 = srem i32 %0, 255
%4 = trunc i32 %3 to i8
%5 = add i8 %4, 1
%6 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %5, i8* %6
%7 = sdiv i32 %0, 256
%8 = srem i32 %7, 255
%9 = trunc i32 %8 to i8
%10 = add i8 %9, 1
%11 = getelementptr inbounds i8, i8* %2, i64 2
store i8 %10, i8* %11
%12 = sdiv i32 %0, 65536
%13 = trunc i32 %12 to i16
%14 = srem i16 %13, 255
%15 = trunc i16 %14 to i8
%16 = add i8 %15, 1
%17 = getelementptr inbounds i8, i8* %2, i64 3
store i8 %16, i8* %17
%18 = sdiv i32 %0, 16777216
%19 = trunc i32 %18 to i8
%20 = add i8 %19, 1
%21 = getelementptr inbounds i8, i8* %2, i64 4
store i8 %20, i8* %21
ret i8* %2
}