#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 *, ...);
scalar_t__ to_http_js_string(char *, char const *);
unsigned int to_http_js_var_string(char *buffer, const char *name,
                                   const char *value) {
  unsigned int offset = 0;
  offset += sprintf(buffer + offset, "var %s=\'", name);
  offset += to_http_js_string(buffer + offset, value);
  offset += sprintf(buffer + offset, "\';\n");
  return offset;
}


x86 assembly (clang, -O0):
<to_http_js_var_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <to_http_js_string@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_http_js_var_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%r15
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rax,%r12
mov    %r12d,%edi
add    %r15,%rdi
mov    %r14,%rsi
call   1030 <to_http_js_string@plt>
mov    %rax,%rbx
add    %r12,%rbx
mov    %ebx,%edi
add    %r15,%rdi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"var %s='\00"
@.str.1 = [4 x i8] c"';\0A\00"
define i32 @to_http_js_var_string(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = load i32, i32* %7
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8*, i8** %5
%13 = call i64 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %7
%18 = load i8*, i8** %4
%19 = load i32, i32* %7
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8*, i8** %6
%23 = call i64 @to_http_js_string(i8* %21, i8* %22)
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %7
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = call i64 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* %7
%34 = zext i32 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %7
%37 = load i32, i32* %7
ret i32 %37
}

LLVM IR (-O2):
@.str = [9 x i8] c"var %s='\00"
@.str.1 = [4 x i8] c"';\0A\00"
define i32 @to_http_js_var_string(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 (i8*, i8*, ...) @sprintf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = and i64 %4, 4294967295
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i64 @to_http_js_string(i8* %6, i8* %2)
%8 = add i64 %7, %4
%9 = and i64 %8, 4294967295
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i64 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = add i64 %8, %11
%13 = trunc i64 %12 to i32
ret i32 %13
}