#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 channel {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ch_write(struct channel *, char const *, int);
int strlen(char const *);
void httpd_header(struct channel *ch, const char *name, const char *value) {
  ch_write(ch, name, strlen(name));
  ch_write(ch, ": ", 2);
  ch_write(ch, value, strlen(value));
  ch_write(ch, "\r\n", 2);
}


x86 assembly (clang, -O0):
<httpd_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1040 <ch_write@plt>
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x2,%edx
call   1040 <ch_write@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <ch_write@plt>
mov    -0x8(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x2,%edx
call   1040 <ch_write@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_header>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <ch_write@plt>
lea    0xeb6(%rip),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1040 <ch_write@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <ch_write@plt>
lea    0xe90(%rip),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <ch_write@plt>

LLVM IR (-O0):
%struct.channel = type { i32 }
@.str = [3 x i8] c": \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @httpd_header(%struct.channel* %0, i8* %1, i8* %2) {
%4 = alloca %struct.channel*
%5 = alloca i8*
%6 = alloca i8*
store %struct.channel* %0, %struct.channel** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load %struct.channel*, %struct.channel** %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @ch_write(%struct.channel* %7, i8* %8, i32 %10)
%12 = load %struct.channel*, %struct.channel** %4
%13 = call i32 @ch_write(%struct.channel* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = load %struct.channel*, %struct.channel** %4
%15 = load i8*, i8** %6
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @ch_write(%struct.channel* %14, i8* %15, i32 %17)
%19 = load %struct.channel*, %struct.channel** %4
%20 = call i32 @ch_write(%struct.channel* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
ret void
}

LLVM IR (-O2):
%struct.channel = type { i32 }
@.str = [3 x i8] c": \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @httpd_header(%struct.channel* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @ch_write(%struct.channel* %0, i8* %1, i32 %4)
%6 = tail call i32 @ch_write(%struct.channel* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = tail call i32 @strlen(i8* %2)
%8 = tail call i32 @ch_write(%struct.channel* %0, i8* %2, i32 %7)
%9 = tail call i32 @ch_write(%struct.channel* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
ret void
}