#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(int);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *create_read_message(const char *file_gid) {
  char *msg =
      malloc(sizeof(char) *
             (1 + strlen(((const char *)"read")) + strlen(((const char *)"|")) +
              strlen(((const char *)"filegid")) + strlen(((const char *)"::")) +
              strlen(file_gid)));
  strcpy(msg, ((const char *)"read"));
  strcat(msg, ((const char *)"|"));
  strcat(msg, ((const char *)"filegid"));
  strcat(msg, ((const char *)"::"));
  strcat(msg, file_gid);
  return msg;
}


x86 assembly (clang, -O0):
<create_read_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xea0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
lea    0xe8c(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
lea    0xe7e(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_read_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeab(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xea2(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
add    %ebp,%ebx
lea    0xe91(%rip),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    %ebx,%ebp
lea    0xe86(%rip),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbx,1),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [8 x i8] c"filegid\00"
@.str.3 = [3 x i8] c"::\00"
define i8* @create_read_message(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = add nsw i32 1, %4
%6 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = add nsw i32 %5, %6
%8 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = add nsw i32 %7, %8
%10 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%11 = add nsw i32 %9, %10
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%21 = load i8*, i8** %3
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i8*, i8** %3
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%25 = load i8*, i8** %3
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%27 = load i8*, i8** %3
%28 = load i8*, i8** %2
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [8 x i8] c"filegid\00"
@.str.3 = [3 x i8] c"::\00"
define i8* @create_read_message(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = add nsw i32 %2, 1
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = add nsw i32 %3, %4
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = add nsw i32 %5, %6
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = add nsw i32 %7, %8
%10 = tail call i32 @strlen(i8* %0)
%11 = add nsw i32 %9, %10
%12 = tail call i8* @malloc(i32 %11)
%13 = tail call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @strcat(i8* %12, i8* %0)
ret i8* %12
}