#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int, ...);
char *xstrdup(char *);
char *gen_cdda_url(const char *disc_id, int start_track, int end_track) {
  char buf[256];
  if (end_track != -1)
    snprintf(buf, sizeof(buf), "cdda://%s/%d-%d", disc_id, start_track,
             end_track);
  else
    snprintf(buf, sizeof(buf), "cdda://%s/%d", disc_id, start_track);
  return xstrdup(buf);
}


x86 assembly (clang, -O0):
<gen_cdda_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
je     116a <gen_cdda_url+0x4a>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%r9d
mov    $0x100,%esi
lea    0xea2(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    118c <gen_cdda_url+0x6c>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    $0x100,%esi
lea    0xe8b(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <xstrdup@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_cdda_url>:
sub    $0x108,%rsp
mov    %esi,%r8d
mov    %rdi,%rcx
cmp    $0xffffffff,%edx
je     114d <gen_cdda_url+0x2d>
mov    %edx,%r9d
lea    0xec4(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1163 <gen_cdda_url+0x43>
lea    0xebc(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rsp,%rdi
call   1040 <xstrdup@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"cdda://%s/%d-%d\00"
@.str.1 = [13 x i8] c"cdda://%s/%d\00"
define i8* @gen_cdda_url(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %11, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13, i32 %14)
br label %21
16: ; preds = %3
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %17, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %19)
br label %21
21: ; preds = %16, %10
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = call i8* @xstrdup(i8* %22)
ret i8* %23
}

LLVM IR (-O2):
@.str = [16 x i8] c"cdda://%s/%d-%d\00"
@.str.1 = [13 x i8] c"cdda://%s/%d\00"
define i8* @gen_cdda_url(i8* %0, i32 %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp eq i32 %2, -1
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %2)
br label %11
9: ; preds = %3
%10 = call i32 (i8*, i32, i8*, i8*, i32, ...) @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
br label %11
11: ; preds = %9, %7
%12 = call i8* @xstrdup(i8* %5)
ret i8* %12
}