#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 /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncat(char *, char const *, size_t);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
void http_field(void *data, const char *field, size_t flen, const char *value,
                size_t vlen) {
  char buff[4096] = {0};
  strncpy(buff, field, flen);
  strcat(buff, ": ");
  strncat(buff, value, vlen);
  printf("HEADER: \"%s\"\n", buff);
}


x86 assembly (clang, -O0):
<http_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
lea    -0x1030(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <strncat@plt>
lea    -0x1030(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_field>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rsp,%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <strncpy@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <strncat@plt>
lea    0xe53(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c": \00"
@.str.1 = [14 x i8] c"HEADER: \22%s\22\0A\00"
define void @http_field(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [4096 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%12 = bitcast [4096 x i8]* %11 to i8*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%14 = load i8*, i8** %7
%15 = load i64, i64* %8
%16 = call i32 @strncpy(i8* %13, i8* %14, i64 %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%20 = load i8*, i8** %9
%21 = load i64, i64* %10
%22 = call i32 @strncat(i8* %19, i8* %20, i64 %21)
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c": \00"
@.str.1 = [14 x i8] c"HEADER: \22%s\22\0A\00"
define void @http_field(i8* nocapture readnone %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = call i32 @strncpy(i8* %7, i8* %1, i64 %2)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strncat(i8* %7, i8* %3, i64 %4)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
ret void
}