#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*/ EXIT_FAILURE;
char *calloc(scalar_t__, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char const *);
scalar_t__ strlen(char *);
char *url_encode(char *);
char *prepare_message(char *message) {
  const char *status_prefix = "status=";
  char *status_string = NULL;
  message = url_encode(message);
  status_string = calloc(strlen(message) + 7 + 1, sizeof(char));
  if (status_string == NULL) {
    exit(EXIT_FAILURE);
  }
  strcat(status_string, status_prefix);
  strcat(status_string, message);
  free(message);
  return status_string;
}


x86 assembly (clang, -O0):
<prepare_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <url_encode@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x7,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c7 <prepare_message+0x67>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_message>:
push   %r14
push   %rbx
push   %rax
call   1060 <url_encode@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x8(%rax),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     11b7 <prepare_message+0x57>
mov    %rax,%rbx
lea    0xe6f(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"status=\00"
@EXIT_FAILURE = global i32 0
define i8* @prepare_message(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3
store i8* null, i8** %4
%5 = load i8*, i8** %2
%6 = call i8* @url_encode(i8* %5)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 7
%10 = add nsw i64 %9, 1
%11 = call i8* @calloc(i64 %10, i32 1)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %1
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %4
%22 = load i8*, i8** %2
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = load i8*, i8** %2
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"status=\00"
@EXIT_FAILURE = global i32 0
define i8* @prepare_message(i8* %0) {
%2 = tail call i8* @url_encode(i8* %0)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = add nsw i64 %3, 8
%5 = tail call i8* @calloc(i64 %4, i32 1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = tail call i32 @strcat(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %5, i8* %2)
%13 = tail call i32 @free(i8* %2)
ret i8* %5
}