#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 */
scalar_t__ sprintf(char *, char *, ...);
char *vohttpd_code_message(int);
int vohttpd_reply_head(char *d, int code) {
  int size = 0;
  size +=
      sprintf(d + size, "HTTP/1.1 %d %s\r\n", code, vohttpd_code_message(code));
  size += sprintf(d + size, "Server: "
                            "vohttpd v0.2"
                            "\r\n");
  return size;
}


x86 assembly (clang, -O0):
<vohttpd_reply_head>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <vohttpd_code_message@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    %rax,%rcx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vohttpd_reply_head>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <vohttpd_code_message@plt>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
movslq %eax,%rbp
add    %rbp,%rbx
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"HTTP/1.1 %d %s\0D\0A\00"
@.str.1 = [23 x i8] c"Server: vohttpd v0.2\0D\0A\00"
define i32 @vohttpd_reply_head(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = call i8* @vohttpd_code_message(i32 %11)
%13 = call i64 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %12)
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %5
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = call i64 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = add nsw i64 %24, %22
%26 = trunc i64 %25 to i32
store i32 %26, i32* %5
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [17 x i8] c"HTTP/1.1 %d %s\0D\0A\00"
@.str.1 = [23 x i8] c"Server: vohttpd v0.2\0D\0A\00"
define i32 @vohttpd_reply_head(i8* %0, i32 %1) {
%3 = tail call i8* @vohttpd_code_message(i32 %1)
%4 = tail call i64 (i8*, i8*, ...) @sprintf(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %3)
%5 = shl i64 %4, 32
%6 = ashr exact i64 %5, 32
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = tail call i64 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%9 = add i64 %8, %4
%10 = trunc i64 %9 to i32
ret i32 %10
}