#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 *Get_Location_Name(int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *Create_Campaign_Pickup_Objective(int next_location) {
  char *buffer;
  char *location_name;
  buffer = (char *)calloc(1024, sizeof(char));
  if (!buffer)
    return NULL;
  strcpy(buffer, "mission_objective_new pick_up\n");
  strcat(buffer, "mission_objective_time_left 0.0\n");
  strcat(buffer, "mission_objective_humans_tally 1 1\n");
  strcat(buffer, "mission_objective_message_success ");
  location_name = Get_Location_Name(next_location);
  if (location_name) {
    strcat(buffer, "Pick up complete. Head for ");
    strcat(buffer, location_name);
    free(location_name);
  }
  strcat(buffer, "\nmission_objective_message_fail You were unable to complete "
                 "pick-up.\n");
  return buffer;
}


x86 assembly (clang, -O0):
<Create_Campaign_Pickup_Objective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1186 <Create_Campaign_Pickup_Objective+0x36>
movq   $0x0,-0x8(%rbp)
jmp    121b <Create_Campaign_Pickup_Objective+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1070 <strcat@plt>
mov    -0xc(%rbp),%edi
call   1030 <Get_Location_Name@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1203 <Create_Campaign_Pickup_Objective+0xb3>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Create_Campaign_Pickup_Objective>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x400,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     11ee <Create_Campaign_Pickup_Objective+0x9e>
mov    %rax,%rbx
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %ebp,%edi
call   1030 <Get_Location_Name@plt>
test   %rax,%rax
je     11dd <Create_Campaign_Pickup_Objective+0x8d>
mov    %rax,%rbp
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
jmp    11f0 <Create_Campaign_Pickup_Objective+0xa0>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"mission_objective_new pick_up\0A\00"
@.str.1 = [33 x i8] c"mission_objective_time_left 0.0\0A\00"
@.str.2 = [36 x i8] c"mission_objective_humans_tally 1 1\0A\00"
@.str.3 = [35 x i8] c"mission_objective_message_success \00"
@.str.4 = [28 x i8] c"Pick up complete. Head for \00"
@.str.5 = [70 x i8] c"\0Amission_objective_message_fail You were unable to complete pick-up.\0A\00"
define i8* @Create_Campaign_Pickup_Objective(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
%6 = call i64 @calloc(i32 1024, i32 1)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* null, i8** %2
br label %36
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %4
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %4
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = call i8* @Get_Location_Name(i32 %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %32
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%27 = load i8*, i8** %4
%28 = load i8*, i8** %5
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %24, %11
%33 = load i8*, i8** %4
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.5, i64 0, i64 0))
%35 = load i8*, i8** %4
store i8* %35, i8** %2
br label %36
36: ; preds = %32, %10
%37 = load i8*, i8** %2
ret i8* %37
}

LLVM IR (-O2):
@.str = [31 x i8] c"mission_objective_new pick_up\0A\00"
@.str.1 = [33 x i8] c"mission_objective_time_left 0.0\0A\00"
@.str.2 = [36 x i8] c"mission_objective_humans_tally 1 1\0A\00"
@.str.3 = [35 x i8] c"mission_objective_message_success \00"
@.str.4 = [28 x i8] c"Pick up complete. Head for \00"
@.str.5 = [70 x i8] c"\0Amission_objective_message_fail You were unable to complete pick-up.\0A\00"
define i8* @Create_Campaign_Pickup_Objective(i32 %0) {
%2 = tail call i64 @calloc(i32 1024, i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %18, label %5
5: ; preds = %1
%6 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i8* @Get_Location_Name(i32 %0)
%11 = icmp eq i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %5
%13 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @strcat(i8* %3, i8* %10)
%15 = tail call i32 @free(i8* %10)
br label %16
16: ; preds = %12, %5
%17 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %1, %16
%19 = phi i8* [ %3, %16 ], [ null, %1 ]
ret i8* %19
}