#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 show_range(char *buf, size_t len, const char *prefix, int start, int end) {
  int n;
  if (start == end)
    n = snprintf(buf, len, "%s%d", prefix, start);
  else
    n = snprintf(buf, len, "%s%d-%d", prefix, start, end);
  if (n < len)
    return n;
  return -1;
}


x86 assembly (clang, -O0):
<show_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    115d <show_range+0x4d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    0xeb2(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
jmp    1182 <show_range+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
lea    0xe8d(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    119b <show_range+0x8b>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <show_range+0x92>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_range>:
push   %rbx
mov    %r8d,%r9d
mov    %ecx,%r8d
mov    %rdx,%rcx
mov    %rsi,%rbx
cmp    %r9d,%r8d
jne    1135 <show_range+0x25>
lea    0xed7(%rip),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1146 <show_range+0x36>
lea    0xec9(%rip),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <snprintf@plt>
cltq
cmp    %rbx,%rax
mov    $0xffffffff,%ecx
cmovae %ecx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s%d\00"
@.str.1 = [8 x i8] c"%s%d-%d\00"
define i32 @show_range(i8* %0, i64 %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %3, %4
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 (i8*, i64, i8*, i8*, i32, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3)
br label %11
9: ; preds = %5
%10 = tail call i32 (i8*, i64, i8*, i8*, i32, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %3, i32 %4)
br label %11
11: ; preds = %9, %7
%12 = phi i32 [ %8, %7 ], [ %10, %9 ]
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, %1
%15 = select i1 %14, i32 %12, i32 -1
ret i32 %15
}