#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 msrp_add_line(char *, char *, int, ...);
int msrp_add_byterange_line(char *buffer, int start, int end, int total) {
  if (!buffer)
    return -1;
  if ((end < 0) || (total < 0))
    return msrp_add_line(buffer, "Byte-Range: %d-*/*", start);
  else
    return msrp_add_line(buffer, "Byte-Range: %d-%d/%d", start, end, total);
}


x86 assembly (clang, -O0):
<msrp_add_byterange_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113c <msrp_add_byterange_line+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    118c <msrp_add_byterange_line+0x7c>
cmpl   $0x0,-0x18(%rbp)
jl     1150 <msrp_add_byterange_line+0x40>
cmpl   $0x0,-0x1c(%rbp)
jge    116d <msrp_add_byterange_line+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <msrp_add_line@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <msrp_add_byterange_line+0x7c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <msrp_add_line@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msrp_add_byterange_line>:
test   %rdi,%rdi
je     1131 <msrp_add_byterange_line+0x21>
mov    %ecx,%r8d
mov    %edx,%ecx
mov    %esi,%edx
mov    %r8d,%eax
or     %ecx,%eax
js     1137 <msrp_add_byterange_line+0x27>
lea    0xee9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <msrp_add_line@plt>
mov    $0xffffffff,%eax
ret
lea    0xec2(%rip),%rsi
xor    %eax,%eax
jmp    1030 <msrp_add_line@plt>

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

LLVM IR (-O2):
@.str = [19 x i8] c"Byte-Range: %d-*/*\00"
@.str.1 = [21 x i8] c"Byte-Range: %d-%d/%d\00"
define i32 @msrp_add_byterange_line(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = or i32 %3, %2
%8 = icmp sgt i32 %7, -1
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 (i8*, i8*, i32, ...) @msrp_add_line(i8* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %13
11: ; preds = %6
%12 = tail call i32 (i8*, i8*, i32, ...) @msrp_add_line(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 %3)
br label %13
13: ; preds = %4, %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ], [ -1, %4 ]
ret i32 %14
}