#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 /*<<< orphan*/ memcpy(char *, void const *, size_t);
int /*<<< orphan*/ printf(char *, ...);
int process_chunk(const void *buf, size_t len, void *arg) {
  char tmp[len + 1];
  memcpy(tmp, buf, len);
  tmp[len] = '\0';
  printf("log contains:\n");
  printf("%s\n", tmp);
  return 1;
}


x86 assembly (clang, -O0):
<process_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    $0x1,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_chunk>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
lea    0x10(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <memcpy@plt>
movb   $0x0,(%r14,%rbx,1)
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"log contains:\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @process_chunk(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%9 = load i64, i64* %5
%10 = add i64 %9, 1
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i8, i64 %10
store i64 %10, i64* %8
%13 = load i8*, i8** %4
%14 = load i64, i64* %5
%15 = call i32 @memcpy(i8* %12, i8* %13, i64 %14)
%16 = load i64, i64* %5
%17 = getelementptr inbounds i8, i8* %12, i64 %16
store i8 0, i8* %17
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%20 = load i8*, i8** %7
ret i32 1
}

LLVM IR (-O2):
@str = [14 x i8] c"log contains:\00"
define i32 @process_chunk(i8* %0, i64 %1, i8* nocapture readnone %2) {
%4 = add i64 %1, 1
%5 = alloca i8, i64 %4
%6 = call i32 @memcpy(i8* %5, i8* %0, i64 %1)
%7 = getelementptr inbounds i8, i8* %5, i64 %1
store i8 0, i8* %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%9 = call i32 @puts(i8* %5)
ret i32 1
}