#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__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
char *webp_js_i(char *content, int csize, char *image, int isize) {
  const char _webp_header[12] = {0x52, 0x49, 0x46, 0x46, 0x2f, 0x2a,
                                 0x00, 0x00, 0x57, 0x45, 0x42, 0x50};
  const char _webp_header_end[6] = {0x2a, 0x2f, 0x3d, 0x30, 0x3b, 0x0a};
  char *buffer = (char *)malloc(isize + csize + 6);
  memcpy(buffer, _webp_header, 12);
  memcpy(&buffer[12], &image[12], isize - 12);
  memcpy(&buffer[isize], _webp_header_end, 6);
  memcpy(&buffer[isize + 6], content, csize);
  return buffer;
}


x86 assembly (clang, -O0):
<webp_js_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x2e(%rbp)
mov    0xeb6(%rip),%ax
mov    %ax,-0x2a(%rbp)
mov    -0x1c(%rbp),%edi
add    -0xc(%rbp),%edi
add    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
add    $0xc,%rdi
mov    -0x18(%rbp),%rsi
add    $0xc,%rsi
mov    -0x1c(%rbp),%edx
sub    $0xc,%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    -0x2e(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x6,%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<webp_js_i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %esi,%r15d
mov    %rdi,%r14
movabs $0x2a2f46464952,%rax
mov    %rax,0x8(%rsp)
movl   $0x50424557,0x10(%rsp)
50
movw   $0xa3b,0x4(%rsp)
movl   $0x303d2f2a,(%rsp)
lea    0x6(%r12),%ebp
lea    (%r12,%r15,1),%edi
add    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xc,%edx
call   1030 <memcpy@plt>
lea    0xc(%rbx),%rdi
add    $0xc,%r13
lea    -0xc(%r12),%edx
mov    %r13,%rsi
call   1030 <memcpy@plt>
movslq %r12d,%rdi
add    %rbx,%rdi
mov    %rsp,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
movslq %ebp,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.webp_js_i._webp_header = [12 x i8] c"RIFF/*\00\00WEBP"
@__const.webp_js_i._webp_header_end = [6 x i8] c"*/=0;\0A"
define i8* @webp_js_i(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [12 x i8]
%10 = alloca [6 x i8]
%11 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = bitcast [12 x i8]* %9 to i8*
%13 = bitcast [6 x i8]* %10 to i8*
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = add nsw i32 %14, %15
%17 = add nsw i32 %16, 6
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %11
%20 = load i8*, i8** %11
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%22 = call i32 @memcpy(i8* %20, i8* %21, i32 12)
%23 = load i8*, i8** %11
%24 = getelementptr inbounds i8, i8* %23, i64 12
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 12
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 12
%29 = call i32 @memcpy(i8* %24, i8* %26, i32 %28)
%30 = load i8*, i8** %11
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 6)
%36 = load i8*, i8** %11
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8*, i8** %5
%42 = load i32, i32* %6
%43 = call i32 @memcpy(i8* %40, i8* %41, i32 %42)
%44 = load i8*, i8** %11
ret i8* %44
}

LLVM IR (-O2):
@__const.webp_js_i._webp_header = [12 x i8] c"RIFF/*\00\00WEBP"
@__const.webp_js_i._webp_header_end = [6 x i8] c"*/=0;\0A"
define i8* @webp_js_i(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [12 x i8]
%6 = alloca [6 x i8]
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%9 = add i32 %3, 6
%10 = add i32 %9, %1
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = call i32 @memcpy(i8* %12, i8* %7, i32 12)
%14 = getelementptr inbounds i8, i8* %12, i64 12
%15 = getelementptr inbounds i8, i8* %2, i64 12
%16 = add nsw i32 %3, -12
%17 = call i32 @memcpy(i8* %14, i8* %15, i32 %16)
%18 = sext i32 %3 to i64
%19 = getelementptr inbounds i8, i8* %12, i64 %18
%20 = call i32 @memcpy(i8* %19, i8* %8, i32 6)
%21 = sext i32 %9 to i64
%22 = getelementptr inbounds i8, i8* %12, i64 %21
%23 = call i32 @memcpy(i8* %22, i8* %0, i32 %1)
ret i8* %12
}