#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
unsigned long LONG_MAX;
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
const char *ubcstr(unsigned long bar, unsigned long lim) {
  static char str[64];
  char *p = str;
  char *e = p + sizeof(str) - 1;
  if (bar == LONG_MAX)
    p += snprintf(p, e - p, "unlimited");
  else
    p += snprintf(p, e - p, "%lu", bar);
  if (bar == lim)
    return str;
  *p++ = ':';
  if (lim == LONG_MAX)
    p += snprintf(p, e - p, "unlimited");
  else
    p += snprintf(p, e - p, "%lu", lim);
  return str;
}


x86 assembly (clang, -O0):
<ubcstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0x2f19(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%rax
jne    1183 <ubcstr+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe99(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    11b6 <ubcstr+0xa6>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    0xe6b(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11d4 <ubcstr+0xc4>
lea    0x2e75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126c <ubcstr+0x15c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x3a,(%rax)
mov    -0x18(%rbp),%rax
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
jne    122e <ubcstr+0x11e>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xdee(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1261 <ubcstr+0x151>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
lea    0xdc0(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
lea    0x2dd8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ubcstr>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ebe(%rip),%r15
cmp    %rdi,(%r15)
jne    1148 <ubcstr+0x38>
lea    0x2f12(%rip),%rdi
lea    0xecb(%rip),%rdx
mov    $0x3f,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    %r14,%rbx
jne    116a <ubcstr+0x5a>
jmp    11af <ubcstr+0x9f>
lea    0x2ef1(%rip),%rdi
lea    0xeb4(%rip),%rdx
mov    $0x3f,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    %r14,%rbx
je     11af <ubcstr+0x9f>
cltq
lea    0x2ecd(%rip),%rdi
add    %rax,%rdi
movb   $0x3a,(%rdi)
add    $0x1,%rdi
lea    0x2ebc(%rip),%rsi
sub    %edi,%esi
add    $0x3f,%esi
cmp    %r14,(%r15)
jne    119e <ubcstr+0x8e>
lea    0xe6b(%rip),%rdx
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    11af <ubcstr+0x9f>
lea    0xe65(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2e8a(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ubcstr.str = internal global [64 x i8] zeroinitializer
@LONG_MAX = global i64 0
@.str = [10 x i8] c"unlimited\00"
@.str.1 = [4 x i8] c"%lu\00"
define i8* @ubcstr(i64 %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
store i64 %0, i64* %4
store i64 %1, i64* %5
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0), i8** %6
%8 = load i8*, i8** %6
%9 = getelementptr inbounds i8, i8* %8, i64 64
%10 = getelementptr inbounds i8, i8* %9, i64 -1
store i8* %10, i8** %7
%11 = load i64, i64* %4
%12 = load i64, i64* @LONG_MAX
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = load i8*, i8** %6
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %6
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %6
br label %39
26: ; preds = %2
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = load i8*, i8** %6
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = load i64, i64* %4
%35 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %27, i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %34)
%36 = load i8*, i8** %6
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %6
br label %39
39: ; preds = %26, %14
%40 = load i64, i64* %4
%41 = load i64, i64* %5
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %39
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0), i8** %3
br label %76
44: ; preds = %39
%45 = load i8*, i8** %6
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %6
store i8 58, i8* %45
%47 = load i64, i64* %5
%48 = load i64, i64* @LONG_MAX
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %62
50: ; preds = %44
%51 = load i8*, i8** %6
%52 = load i8*, i8** %7
%53 = load i8*, i8** %6
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = trunc i64 %56 to i32
%58 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %51, i32 %57, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%59 = load i8*, i8** %6
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8, i8* %59, i64 %60
store i8* %61, i8** %6
br label %75
62: ; preds = %44
%63 = load i8*, i8** %6
%64 = load i8*, i8** %7
%65 = load i8*, i8** %6
%66 = ptrtoint i8* %64 to i64
%67 = ptrtoint i8* %65 to i64
%68 = sub i64 %66, %67
%69 = trunc i64 %68 to i32
%70 = load i64, i64* %5
%71 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %63, i32 %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %70)
%72 = load i8*, i8** %6
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %72, i64 %73
store i8* %74, i8** %6
br label %75
75: ; preds = %62, %50
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0), i8** %3
br label %76
76: ; preds = %75, %43
%77 = load i8*, i8** %3
ret i8* %77
}

LLVM IR (-O2):
@ubcstr.str = internal global [64 x i8] zeroinitializer
@LONG_MAX = global i64 0
@.str = [10 x i8] c"unlimited\00"
@.str.1 = [4 x i8] c"%lu\00"
define i8* @ubcstr(i64 %0, i64 %1) {
%3 = load i64, i64* @LONG_MAX
%4 = icmp eq i64 %3, %0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %2
%8 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %0)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 %11
%13 = icmp eq i64 %0, %1
br i1 %13, label %25, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %12, i64 1
store i8 58, i8* %12
%16 = load i64, i64* @LONG_MAX
%17 = icmp eq i64 %16, %1
%18 = ptrtoint i8* %15 to i64
%19 = trunc i64 %18 to i32
%20 = sub i32 ptrtoint (i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 63) to i32), %19
br i1 %17, label %21, label %23
21: ; preds = %14
%22 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %25
23: ; preds = %14
%24 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %25
25: ; preds = %21, %23, %9
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @ubcstr.str, i64 0, i64 0)
}