#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 */
char *malloc(size_t);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *, char const *);
int strlen(char const *);
char *__make_command(const char *tag, const char *path, int fdel) {
  size_t n;
  char *p;
  n = strlen(tag) + strlen(path) + 11;
  p = malloc(n);
  if (!p) {
    perror("comlogger: malloc");
    return NULL;
  }
  snprintf(p, n, "OPEN -d %s %s\r\n", tag, path);
  return p;
}


x86 assembly (clang, -O0):
<__make_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0xb,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a9 <__make_command+0x69>
lea    0xe69(%rip),%rdi
call   1060 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11cd <__make_command+0x8d>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe52(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__make_command>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0xb,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     119c <__make_command+0x5c>
lea    0xe96(%rip),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe5d(%rip),%rdi
call   1060 <perror@plt>
jmp    118d <__make_command+0x4d>

LLVM IR (-O0):
@.str = [18 x i8] c"comlogger: malloc\00"
@.str.1 = [16 x i8] c"OPEN -d %s %s\0D\0A\00"
define i8* @__make_command(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = add nsw i32 %14, 11
%16 = sext i32 %15 to i64
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %9
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %3
%22 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %4
br label %30
23: ; preds = %3
%24 = load i8*, i8** %9
%25 = load i64, i64* %8
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i32 @snprintf(i8* %24, i64 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %27)
%29 = load i8*, i8** %9
store i8* %29, i8** %4
br label %30
30: ; preds = %23, %21
%31 = load i8*, i8** %4
ret i8* %31
}

LLVM IR (-O2):
@.str = [18 x i8] c"comlogger: malloc\00"
@.str.1 = [16 x i8] c"OPEN -d %s %s\0D\0A\00"
define i8* @__make_command(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 11
%7 = add i32 %6, %5
%8 = sext i32 %7 to i64
%9 = tail call i8* @malloc(i64 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %3
%14 = tail call i32 @snprintf(i8* %9, i64 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %15
15: ; preds = %13, %11
ret i8* %9
}