#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 */
struct http_connection {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
size_t SIZE_MAX;
int /*<<< orphan*/ send_header(struct http_connection *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, size_t, ...);
void send_range_header(struct http_connection *conn, size_t first,
                       size_t last) {
  char buf[32];
  if (last != SIZE_MAX)
    snprintf(buf, sizeof(buf), "bytes=%zu-%zu", first, last);
  else
    snprintf(buf, sizeof(buf), "bytes=%zu-", first);
  send_header(conn, "Range", buf);
}


x86 assembly (clang, -O0):
<send_range_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%rax
je     116c <send_range_header+0x4c>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x20,%esi
lea    0xea0(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1187 <send_range_header+0x67>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x20,%esi
lea    0xe8e(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1040 <send_header@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_range_header>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rcx
mov    %rdi,%rbx
mov    0x2ea6(%rip),%rax
cmp    %rdx,(%rax)
jne    114f <send_range_header+0x2f>
lea    0xed0(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1168 <send_range_header+0x48>
mov    %rdx,%r8
lea    0xea7(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0xeaa(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1040 <send_header@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.http_connection = type { i32 }
@SIZE_MAX = global i64 0
@.str = [14 x i8] c"bytes=%zu-%zu\00"
@.str.1 = [11 x i8] c"bytes=%zu-\00"
@.str.2 = [6 x i8] c"Range\00"
define void @send_range_header(%struct.http_connection* %0, i64 %1, i64 %2) {
%4 = alloca %struct.http_connection*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [32 x i8]
store %struct.http_connection* %0, %struct.http_connection** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = load i64, i64* @SIZE_MAX
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %12, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %14)
br label %20
16: ; preds = %3
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%18 = load i64, i64* %5
%19 = call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %17, i32 32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %16, %11
%21 = load %struct.http_connection*, %struct.http_connection** %4
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%23 = call i32 @send_header(%struct.http_connection* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %22)
ret void
}

LLVM IR (-O2):
%struct.http_connection = type { i32 }
@SIZE_MAX = global i64 0
@.str = [14 x i8] c"bytes=%zu-%zu\00"
@.str.1 = [11 x i8] c"bytes=%zu-\00"
@.str.2 = [6 x i8] c"Range\00"
define void @send_range_header(%struct.http_connection* %0, i64 %1, i64 %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = load i64, i64* @SIZE_MAX
%7 = icmp eq i64 %6, %2
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %5, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %1, i64 %2)
br label %12
10: ; preds = %3
%11 = call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %5, i32 32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %12
12: ; preds = %10, %8
%13 = call i32 @send_header(%struct.http_connection* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret void
}