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


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

x86 assembly (clang, -O2):
<eto_log_add_entry_s>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rax,%r15,1),%edi
add    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <eto_log_add_entry@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
define void @eto_log_add_entry_s(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %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 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
%15 = zext i32 %14 to i64
%16 = add i64 %11, %15
%17 = add i64 %16, 2
%18 = trunc i64 %17 to i32
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i8*, i8** %6
%27 = call i32 @eto_log_add_entry(i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
ret void
}

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