#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ printf(char *, char *, int);
bool itcb(void *arg, const char *key, int ksize, const char *val, int vsize,
          uint32_t expire, uint64_t oid) {
  char buf[4096];
  char *kvbuf = buf;
  if (ksize + vsize + 2 > 4096)
    kvbuf = (char *)malloc(ksize + vsize + 2);
  memcpy(kvbuf, key, ksize);
  kvbuf[ksize] = '\t';
  memcpy(kvbuf + ksize + 1, val, vsize);
  kvbuf[ksize + vsize + 1] = '\0';
  printf("%s\t%u\n", kvbuf, expire);
  if (kvbuf != buf)
    free(kvbuf);
  return true;
}


x86 assembly (clang, -O0):
<itcb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
add    $0x2,%eax
cmp    $0x1000,%eax
jle    119c <itcb+0x5c>
mov    -0x14(%rbp),%edi
add    -0x24(%rbp),%edi
add    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,-0x1038(%rbp)
mov    -0x1038(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x1038(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x9,(%rax,%rcx,1)
mov    -0x1038(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x1038(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1038(%rbp),%rsi
mov    -0x28(%rbp),%edx
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1038(%rbp),%rax
lea    -0x1030(%rbp),%rcx
cmp    %rcx,%rax
je     122c <itcb+0xec>
mov    -0x1038(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itcb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%r13
lea    0x10(%rsp),%rbx
lea    (%r12,%rbp,1),%r14d
cmp    $0xfff,%r14d
jl     117f <itcb+0x3f>
lea    0x2(%r14),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1050 <memcpy@plt>
movslq %ebp,%rax
movb   $0x9,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1050 <memcpy@plt>
movslq %r14d,%rax
movb   $0x0,0x1(%rax,%rbx,1)
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
mov    0xc(%rsp),%edx
call   1040 <printf@plt>
lea    0x10(%rsp),%rax
cmp    %rax,%rbx
je     11d3 <itcb+0x93>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s\09%u\0A\00"
define i32 @itcb(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [4096 x i8]
%16 = alloca i8*
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
store i8* %17, i8** %16
%18 = load i32, i32* %10
%19 = load i32, i32* %12
%20 = add nsw i32 %18, %19
%21 = add nsw i32 %20, 2
%22 = icmp sgt i32 %21, 4096
br i1 %22, label %23, label %30
23: ; preds = %7
%24 = load i32, i32* %10
%25 = load i32, i32* %12
%26 = add nsw i32 %24, %25
%27 = add nsw i32 %26, 2
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %16
br label %30
30: ; preds = %23, %7
%31 = load i8*, i8** %16
%32 = load i8*, i8** %9
%33 = load i32, i32* %10
%34 = call i32 @memcpy(i8* %31, i8* %32, i32 %33)
%35 = load i8*, i8** %16
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 9, i8* %38
%39 = load i8*, i8** %16
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8*, i8** %11
%45 = load i32, i32* %12
%46 = call i32 @memcpy(i8* %43, i8* %44, i32 %45)
%47 = load i8*, i8** %16
%48 = load i32, i32* %10
%49 = load i32, i32* %12
%50 = add nsw i32 %48, %49
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %47, i64 %52
store i8 0, i8* %53
%54 = load i8*, i8** %16
%55 = load i32, i32* %13
%56 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %54, i32 %55)
%57 = load i8*, i8** %16
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%59 = icmp ne i8* %57, %58
br i1 %59, label %60, label %63
60: ; preds = %30
%61 = load i8*, i8** %16
%62 = call i32 @free(i8* %61)
br label %63
63: ; preds = %60, %30
ret i32 1
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s\09%u\0A\00"
define i32 @itcb(i8* nocapture readnone %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca [4096 x i8]
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%10 = add nsw i32 %4, %2
%11 = icmp sgt i32 %10, 4094
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = add nuw nsw i32 %10, 2
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
br label %16
16: ; preds = %12, %7
%17 = phi i8* [ %15, %12 ], [ %9, %7 ]
%18 = call i32 @memcpy(i8* %17, i8* %1, i32 %2)
%19 = sext i32 %2 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 9, i8* %20
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i32 @memcpy(i8* %21, i8* %3, i32 %4)
%23 = add nsw i32 %10, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %17, i64 %24
store i8 0, i8* %25
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %5)
%27 = icmp eq i8* %17, %9
br i1 %27, label %30, label %28
28: ; preds = %16
%29 = call i32 @free(i8* %17)
br label %30
30: ; preds = %28, %16
ret i32 1
}