#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 snprintf(char *, int, char *);
int make_ls_resp(char *buf, int bufsz) {
  int hdrlen, bodylen;
  hdrlen =
      snprintf(buf, bufsz - 1,
               "HTTP/1.1 200 OK\r\nDate: Fri, 02 Jan 1970 11:23:09 "
               "GMT\r\nServer: Unknown/0.0 UPnP/1.0 Virata-EmWeb/R6_0_1\r\n"
               "Transfer-Encoding: chunked\r\nContent-Type: "
               "text/xml\r\nExpires: Fri, 02 Jan 1970 11:23:09 GMT\r\n"
               "Last-Modified: Fri, 02 Jan 1970 11:23:09 GMT\r\nCache-Control: "
               "no-cache\r\nPragma: no-cache\r\n\r\n");
  bodylen =
      snprintf(buf + hdrlen, bufsz - hdrlen, "00000002\r\n0\n\r\n0\r\n\r\n");
  return (hdrlen + bodylen);
}


x86 assembly (clang, -O0):
<make_ls_resp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
lea    0xed0(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xfd0(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_ls_resp>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    -0x1(%r14),%esi
lea    0xeda(%rip),%rdx
call   1030 <snprintf@plt>
movslq %eax,%r15
add    %r15,%rbx
sub    %r15d,%r14d
lea    0xfe5(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <snprintf@plt>
add    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [288 x i8] c"HTTP/1.1 200 OK\0D\0ADate: Fri, 02 Jan 1970 11:23:09 GMT\0D\0AServer: Unknown/0.0 UPnP/1.0 Virata-EmWeb/R6_0_1\0D\0ATransfer-Encoding: chunked\0D\0AContent-Type: text/xml\0D\0AExpires: Fri, 02 Jan 1970 11:23:09 GMT\0D\0ALast-Modified: Fri, 02 Jan 1970 11:23:09 GMT\0D\0ACache-Control: no-cache\0D\0APragma: no-cache\0D\0A\0D\0A\00"
@.str.1 = [20 x i8] c"00000002\0D\0A0\0A\0D\0A0\0D\0A\0D\0A\00"
define i32 @make_ls_resp(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = call i32 @snprintf(i8* %7, i32 %9, i8* getelementptr inbounds ([288 x i8], [288 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %5
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = sub nsw i32 %15, %16
%18 = call i32 @snprintf(i8* %14, i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %6
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
ret i32 %21
}

LLVM IR (-O2):
@.str = [288 x i8] c"HTTP/1.1 200 OK\0D\0ADate: Fri, 02 Jan 1970 11:23:09 GMT\0D\0AServer: Unknown/0.0 UPnP/1.0 Virata-EmWeb/R6_0_1\0D\0ATransfer-Encoding: chunked\0D\0AContent-Type: text/xml\0D\0AExpires: Fri, 02 Jan 1970 11:23:09 GMT\0D\0ALast-Modified: Fri, 02 Jan 1970 11:23:09 GMT\0D\0ACache-Control: no-cache\0D\0APragma: no-cache\0D\0A\0D\0A\00"
@.str.1 = [20 x i8] c"00000002\0D\0A0\0A\0D\0A0\0D\0A\0D\0A\00"
define i32 @make_ls_resp(i8* %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = tail call i32 @snprintf(i8* %0, i32 %3, i8* getelementptr inbounds ([288 x i8], [288 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = sub nsw i32 %1, %4
%8 = tail call i32 @snprintf(i8* %6, i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%9 = add nsw i32 %8, %4
ret i32 %9
}