#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 send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int sendHeaders(int serversocket, char *mountpoint, int metadata) {
  int ret = 0;
  char headers[256 + sizeof("cPige/1.5") + 16 + 11 + 4];
  if (mountpoint == NULL)
    snprintf(headers, 255, "GET / HTTP/1.0\r\n");
  else
    snprintf(headers, 255, "GET %s HTTP/1.0\r\n", mountpoint);
  if (metadata != 0)
    strncat(headers, "Icy-MetaData:1\r\n", 16);
  else
    strncat(headers, "Icy-MetaData:0\r\n", 16);
  strncat(headers, "User-Agent:", 11);
  strncat(headers, "cPige/1.5", sizeof("cPige/1.5"));
  strncat(headers, "\r\n\r\n", 4);
  ret = send(serversocket, headers, strlen(headers), 0);
  return ret;
}


x86 assembly (clang, -O0):
<sendHeaders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1186 <sendHeaders+0x46>
lea    -0x150(%rbp),%rdi
mov    $0xff,%esi
lea    0xe86(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    11a4 <sendHeaders+0x64>
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xff,%esi
lea    0xe74(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11cb <sendHeaders+0x8b>
lea    -0x150(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x10,%edx
call   1060 <strncat@plt>
jmp    11e3 <sendHeaders+0xa3>
lea    -0x150(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x10,%edx
call   1060 <strncat@plt>
lea    -0x150(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0xb,%edx
call   1060 <strncat@plt>
lea    -0x150(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0xa,%edx
call   1060 <strncat@plt>
lea    -0x150(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x4,%edx
call   1060 <strncat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x15c(%rbp)
lea    -0x150(%rbp),%rax
mov    %rax,-0x158(%rbp)
lea    -0x150(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x15c(%rbp),%edi
mov    -0x158(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendHeaders>:
push   %rbp
push   %rbx
sub    $0x138,%rsp
mov    %edx,%ebx
mov    %edi,%ebp
test   %rsi,%rsi
je     116d <sendHeaders+0x2d>
mov    %rsi,%rcx
lea    0xeb5(%rip),%rdx
mov    %rsp,%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1183 <sendHeaders+0x43>
lea    0xe8c(%rip),%rdx
mov    %rsp,%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
test   %ebx,%ebx
lea    0xea8(%rip),%rax
lea    0xe90(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10,%edx
call   1060 <strncat@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
mov    $0xb,%edx
call   1060 <strncat@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1060 <strncat@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1060 <strncat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x138,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"GET / HTTP/1.0\0D\0A\00"
@.str.1 = [18 x i8] c"GET %s HTTP/1.0\0D\0A\00"
@.str.2 = [17 x i8] c"Icy-MetaData:1\0D\0A\00"
@.str.3 = [17 x i8] c"Icy-MetaData:0\0D\0A\00"
@.str.4 = [12 x i8] c"User-Agent:\00"
@.str.5 = [10 x i8] c"cPige/1.5\00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
define i32 @sendHeaders(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [297 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%13 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 255, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %3
%15 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 255, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %11
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%23 = call i32 @strncat(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 16)
br label %27
24: ; preds = %18
%25 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%26 = call i32 @strncat(i8* %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 16)
br label %27
27: ; preds = %24, %21
%28 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%29 = call i32 @strncat(i8* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%30 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%31 = call i32 @strncat(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 10)
%32 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%33 = call i32 @strncat(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%34 = load i32, i32* %4
%35 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds [297 x i8], [297 x i8]* %8, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = call i32 @send(i32 %34, i8* %35, i32 %37, i32 0)
store i32 %38, i32* %7
%39 = load i32, i32* %7
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"GET / HTTP/1.0\0D\0A\00"
@.str.1 = [18 x i8] c"GET %s HTTP/1.0\0D\0A\00"
@.str.2 = [17 x i8] c"Icy-MetaData:1\0D\0A\00"
@.str.3 = [17 x i8] c"Icy-MetaData:0\0D\0A\00"
@.str.4 = [12 x i8] c"User-Agent:\00"
@.str.5 = [10 x i8] c"cPige/1.5\00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
define i32 @sendHeaders(i32 %0, i8* %1, i32 %2) {
%4 = alloca [297 x i8]
%5 = getelementptr inbounds [297 x i8], [297 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %1, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 255, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %3
%10 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 255, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %11
11: ; preds = %9, %7
%12 = icmp eq i32 %2, 0
%13 = select i1 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0)
%14 = call i32 @strncat(i8* %5, i8* %13, i32 16)
%15 = call i32 @strncat(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%16 = call i32 @strncat(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 10)
%17 = call i32 @strncat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%18 = call i32 @strlen(i8* %5)
%19 = call i32 @send(i32 %0, i8* %5, i32 %18, i32 0)
ret i32 %19
}