#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 const *Z_NULL;
unsigned long crc32(unsigned long, char const *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ trio_sprintf(char *, char *, unsigned long);
char *str_CRC32(const char *str) {
  unsigned long int crc = crc32(0L, Z_NULL, 0);
  char *buff = NULL;
  crc = crc32(crc, str, strlen(str));
  buff = (char *)malloc(sizeof(char) * (20));
  trio_sprintf(buff, "%zu", crc);
  return buff;
}


x86 assembly (clang, -O0):
<str_CRC32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
call   1030 <crc32@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <crc32@plt>
mov    %rax,-0x10(%rbp)
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1060 <trio_sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_CRC32>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%rax
mov    (%rax),%rsi
xor    %edi,%edi
xor    %edx,%edx
call   1030 <crc32@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <crc32@plt>
mov    %rax,%r14
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe77(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <trio_sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@Z_NULL = global i8* null
@.str = [4 x i8] c"%zu\00"
define i8* @str_CRC32(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** @Z_NULL
%6 = call i64 @crc32(i64 0, i8* %5, i32 0)
store i64 %6, i64* %3
store i8* null, i8** %4
%7 = load i64, i64* %3
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = call i64 @crc32(i64 %7, i8* %8, i32 %10)
store i64 %11, i64* %3
%12 = call i64 @malloc(i32 20)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = load i64, i64* %3
%16 = call i32 @trio_sprintf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %15)
%17 = load i8*, i8** %4
ret i8* %17
}

LLVM IR (-O2):
@Z_NULL = global i8* null
@.str = [4 x i8] c"%zu\00"
define i8* @str_CRC32(i8* %0) {
%2 = load i8*, i8** @Z_NULL
%3 = tail call i64 @crc32(i64 0, i8* %2, i32 0)
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i64 @crc32(i64 %3, i8* %0, i32 %4)
%6 = tail call i64 @malloc(i32 20)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @trio_sprintf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %5)
ret i8* %7
}