#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ send(int, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char const *, ...);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
void response(int client, const char *header1, const char *header2,
              char *content) {
  char *buf;
  buf = malloc(1024);
  sprintf(buf, "%s", header1);
  send(client, buf, strlen(buf), 0);
  sprintf(buf, header2, (int)strlen(content));
  send(client, buf, strlen(buf), 0);
  if (strcmp(content, "") != 0) {
    sprintf(buf, content);
    send(client, buf, strlen(buf), 0);
  }
  free(buf);
}


x86 assembly (clang, -O0):
<response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x20(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1266 <response+0x106>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<response>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%r14d
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    0xe16(%rip),%rsi
mov    %r12,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121c <response+0xac>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [1 x i8] zeroinitializer
define void @response(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = call i8* @malloc(i32 1024)
store i8* %10, i8** %9
%11 = load i8*, i8** %9
%12 = load i8*, i8** %6
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %5
%15 = load i8*, i8** %9
%16 = load i8*, i8** %9
%17 = call i64 @strlen(i8* %16)
%18 = call i32 @send(i32 %14, i8* %15, i64 %17, i32 0)
%19 = load i8*, i8** %9
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i64 @strlen(i8* %21)
%23 = trunc i64 %22 to i32
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* %20, i32 %23)
%25 = load i32, i32* %5
%26 = load i8*, i8** %9
%27 = load i8*, i8** %9
%28 = call i64 @strlen(i8* %27)
%29 = call i32 @send(i32 %25, i8* %26, i64 %28, i32 0)
%30 = load i8*, i8** %8
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %4
%34 = load i8*, i8** %9
%35 = load i8*, i8** %8
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* %35)
%37 = load i32, i32* %5
%38 = load i8*, i8** %9
%39 = load i8*, i8** %9
%40 = call i64 @strlen(i8* %39)
%41 = call i32 @send(i32 %37, i8* %38, i64 %40, i32 0)
br label %42
42: ; preds = %33, %4
%43 = load i8*, i8** %9
%44 = call i32 @free(i8* %43)
ret void
}

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
define void @response(i32 %0, i8* nocapture %1, i8* nocapture %2, i8* %3) {
%5 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%6 = tail call i8* @strcpy(i8* dereferenceable(1) %5, i8* dereferenceable(1) %1)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%8 = tail call i32 @send(i32 %0, i8* %5, i64 %7, i32 0)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%10 = trunc i64 %9 to i32
%11 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) %2, i32 %10)
%12 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%13 = tail call i32 @send(i32 %0, i8* %5, i64 %12, i32 0)
%14 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %4
%17 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) %3)
%18 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%19 = tail call i32 @send(i32 %0, i8* %5, i64 %18, i32 0)
br label %20
20: ; preds = %16, %4
%21 = tail call i32 @free(i8* %5)
ret void
}