#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 */
unsigned int calc_crc(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void msg_crc_concat(char *msg_in, char *str_out) {
  unsigned int crc_actual = calc_crc(msg_in, strlen(msg_in));
  char crc_actual_str[8];
  sprintf(crc_actual_str, "%u", crc_actual);
  strcpy(str_out, msg_in);
  strcat(str_out, "|");
  strcat(str_out, crc_actual_str);
}


x86 assembly (clang, -O0):
<msg_crc_concat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1050 <calc_crc@plt>
mov    %eax,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe73(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_crc_concat>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <calc_crc@plt>
lea    0xe8b(%rip),%rsi
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [2 x i8] c"|\00"
define void @msg_crc_concat(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [8 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @calc_crc(i8* %7, i32 %9)
store i32 %10, i32* %5
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %5
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %4
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcat(i8* %19, i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [2 x i8] c"|\00"
define void @msg_crc_concat(i8* %0, i8* %1) {
%3 = alloca [8 x i8]
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @calc_crc(i8* %0, i32 %4)
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%8 = tail call i32 @strcpy(i8* %1, i8* %0)
%9 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strcat(i8* %1, i8* %6)
ret void
}