#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*/ free(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sprintf(char *, char const *, char const *);
scalar_t__ strlen(char const *);
void usage_fmt_s(const char *fmt, const char *arg1) {
  char *usage_complete = malloc(strlen(fmt) + strlen(arg1) + 1);
  if (usage_complete == NULL)
    return;
  sprintf(usage_complete, fmt, arg1);
  puts(usage_complete);
  free(usage_complete);
}


x86 assembly (clang, -O0):
<usage_fmt_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <usage_fmt_s+0x4a>
jmp    11bd <usage_fmt_s+0x6d>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage_fmt_s>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     11a3 <usage_fmt_s+0x53>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @usage_fmt_s(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %7, %9
%11 = add nsw i64 %10, 1
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
br label %25
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 @sprintf(i8* %17, i8* %18, i8* %19)
%21 = load i8*, i8** %5
%22 = call i32 @puts(i8* %21)
%23 = load i8*, i8** %5
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %16, %15
ret void
}

LLVM IR (-O2):
define void @usage_fmt_s(i8* nocapture %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 1
%6 = add i64 %5, %4
%7 = tail call i8* @malloc(i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = tail call i32 @sprintf(i8* %7, i8* dereferenceable(1) %0, i8* %1)
%11 = tail call i32 @puts(i8* %7)
%12 = tail call i32 @free(i8* %7)
br label %13
13: ; preds = %2, %9
ret void
}