#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*/ sprintf(char *, char *, char *, char *);
char *strchr(char *, char);
int strlen(char *);
char *create_image(char *title, char *href) {
  char *_str = NULL, *format = "<img src=\"%s\" title=\"%s\">", *pos = NULL;
  pos = strchr(href, ' ');
  if (pos != NULL) {
    *pos = '\0';
  }
  _str = (char *)malloc(strlen(title) + strlen(format) - 4 + strlen(href) + 1);
  sprintf(_str, format, href, title);
  return _str;
}


x86 assembly (clang, -O0):
<create_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118f <create_image+0x4f>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
sub    $0x4,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_image>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1163 <create_image+0x23>
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
lea    0xe8b(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %r12d,%ebp
lea    (%rax,%rbp,1),%edi
add    $0xfffffffd,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <sprintf@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"<img src=\22%s\22 title=\22%s\22>\00"
define i8* @create_image(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* null, i8** %7
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 32)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %7
store i8 0, i8* %13
br label %14
14: ; preds = %12, %2
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
%19 = add nsw i32 %16, %18
%20 = sub nsw i32 %19, 4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %20, %22
%24 = add nsw i32 %23, 1
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %5
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = load i8*, i8** %4
%30 = load i8*, i8** %3
%31 = call i32 @sprintf(i8* %27, i8* %28, i8* %29, i8* %30)
%32 = load i8*, i8** %5
ret i8* %32
}

LLVM IR (-O2):
@.str = [26 x i8] c"<img src=\22%s\22 title=\22%s\22>\00"
define i8* @create_image(i8* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 32)
%4 = icmp eq i8* %3, null
br i1 %4, label %6, label %5
5: ; preds = %2
store i8 0, i8* %3
br label %6
6: ; preds = %5, %2
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @strlen(i8* %1)
%10 = add i32 %7, -3
%11 = add i32 %10, %8
%12 = add i32 %11, %9
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
ret i8* %14
}