#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*/ eto_log_add_entry(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int);
scalar_t__ strlen(char const *);
void eto_log_add_entry_i(const char *entry, int val) {
  unsigned int size = sizeof(char) * (unsigned int)strlen(entry) + 20;
  char *txt = (char *)malloc(size);
  sprintf(txt, "%s %i", entry, val);
  eto_log_add_entry(txt);
  free(txt);
}


x86 assembly (clang, -O0):
<eto_log_add_entry_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%eax
shl    $0x0,%rax
add    $0x14,%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe6d(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <eto_log_add_entry@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eto_log_add_entry_i>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1050 <strlen@plt>
lea    0x14(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
lea    0xe8f(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <eto_log_add_entry@plt>
mov    %rbp,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s %i\00"
define void @eto_log_add_entry_i(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
%10 = zext i32 %9 to i64
%11 = mul i64 1, %10
%12 = add i64 %11, 20
%13 = trunc i64 %12 to i32
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
%21 = load i8*, i8** %6
%22 = call i32 @eto_log_add_entry(i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %i\00"
define void @eto_log_add_entry_i(i8* %0, i32 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = add i32 %4, 20
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%9 = tail call i32 @eto_log_add_entry(i8* %7)
%10 = tail call i32 @free(i8* %7)
ret void
}