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


x86 assembly (clang, -O0):
<to_http_js_var_array_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1030 <to_http_js_string@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_http_js_var_array_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %rdi,%r15
lea    0xec6(%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    0xea5(%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"%s[%u]='\00"
@.str.1 = [4 x i8] c"';\0A\00"
define i32 @to_http_js_var_array_string(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
%10 = load i8*, i8** %5
%11 = load i32, i32* %9
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i64 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i32, i32* %9
%18 = zext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %9
%21 = load i8*, i8** %5
%22 = load i32, i32* %9
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8*, i8** %8
%26 = call i64 @to_http_js_string(i8* %24, i8* %25)
%27 = load i32, i32* %9
%28 = zext i32 %27 to i64
%29 = add nsw i64 %28, %26
%30 = trunc i64 %29 to i32
store i32 %30, i32* %9
%31 = load i8*, i8** %5
%32 = load i32, i32* %9
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = call i64 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = add nsw i64 %37, %35
%39 = trunc i64 %38 to i32
store i32 %39, i32* %9
%40 = load i32, i32* %9
ret i32 %40
}

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