#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 *pnm_js(char *content, int size) {
  const char _pnm_header[19] = {0x50, 0x36, 0x2f, 0x2a, 0x0a, 0x32, 0x20,
                                0x32, 0x0a, 0x32, 0x35, 0x35, 0x0a, 0x2a,
                                0x2f, 0x3d, 0x30, 0x3b, 0x0a};
  char *buffer = (char *)malloc(19 + size);
  memcpy(buffer, _pnm_header, 19);
  memcpy(&buffer[19], content, size);
  return buffer;
}


x86 assembly (clang, -O0):
<pnm_js>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xebc(%rip),%al
mov    %al,-0xe(%rbp)
mov    -0xc(%rbp),%edi
add    $0x13,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x13,%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rdi
add    $0x13,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnm_js>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
movaps 0xeca(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa3b303d,0xf(%rsp)
0a
lea    0x13(%r15),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x13,%edx
call   1030 <memcpy@plt>
lea    0x13(%rbx),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.pnm_js._pnm_header = [19 x i8] c"P6/*\0A2 2\0A255\0A*/=0;\0A"
define i8* @pnm_js(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [19 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [19 x i8]* %5 to i8*
%8 = load i32, i32* %4
%9 = add nsw i32 19, %8
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = getelementptr inbounds [19 x i8], [19 x i8]* %5, i64 0, i64 0
%14 = call i32 @memcpy(i8* %12, i8* %13, i32 19)
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 19
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @memcpy(i8* %16, i8* %17, i32 %18)
%20 = load i8*, i8** %6
ret i8* %20
}

LLVM IR (-O2):
@__const.pnm_js._pnm_header = [19 x i8] c"P6/*\0A2 2\0A255\0A*/=0;\0A"
define i8* @pnm_js(i8* %0, i32 %1) {
%3 = alloca [19 x i8]
%4 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%5 = add nsw i32 %1, 19
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = call i32 @memcpy(i8* %7, i8* %4, i32 19)
%9 = getelementptr inbounds i8, i8* %7, i64 19
%10 = call i32 @memcpy(i8* %9, i8* %0, i32 %1)
ret i8* %7
}