#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);
char *Get_Location_Symbol(int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *Create_Campaign_Arrive_Objective(int current_location,
                                       int next_location) {
  char *buffer;
  char *location_name;
  buffer = (char *)calloc(512, sizeof(char));
  if (!buffer)
    return NULL;
  strcpy(buffer, "mission_objective_new arrive\n");
  strcat(buffer, "mission_objective_time_left 0.0\n");
  strcat(buffer, "mission_objective_arrive_at ");
  location_name = Get_Location_Symbol(current_location);
  if (location_name) {
    strcat(buffer, location_name);
    free(location_name);
  }
  strcat(buffer, "\n");
  strcat(buffer, "mission_objective_message_success Welcome!");
  location_name = Get_Location_Name(next_location);
  if (location_name) {
    strcat(buffer, " Next head for ");
    strcat(buffer, location_name);
    free(location_name);
  }
  strcat(buffer,
         "\nmission_objective_message_fail You did not arrive safely.\n");
  return buffer;
}


x86 assembly (clang, -O0):
<Create_Campaign_Arrive_Objective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1199 <Create_Campaign_Arrive_Objective+0x39>
movq   $0x0,-0x8(%rbp)
jmp    126b <Create_Campaign_Arrive_Objective+0x10b>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <strcat@plt>
mov    -0xc(%rbp),%edi
call   1060 <Get_Location_Symbol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f6 <Create_Campaign_Arrive_Objective+0x96>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xed0(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x10(%rbp),%edi
call   1030 <Get_Location_Name@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1253 <Create_Campaign_Arrive_Objective+0xf3>
mov    -0x18(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1080 <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_Arrive_Objective>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x200,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
test   %rax,%rax
je     1234 <Create_Campaign_Arrive_Objective+0xd4>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %ebp,%edi
call   1060 <Get_Location_Symbol@plt>
test   %rax,%rax
je     11d3 <Create_Campaign_Arrive_Objective+0x73>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
lea    0xef7(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %r14d,%edi
call   1030 <Get_Location_Name@plt>
test   %rax,%rax
je     1223 <Create_Campaign_Arrive_Objective+0xc3>
mov    %rax,%rbp
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <strcat@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
jmp    1236 <Create_Campaign_Arrive_Objective+0xd6>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"mission_objective_new arrive\0A\00"
@.str.1 = [33 x i8] c"mission_objective_time_left 0.0\0A\00"
@.str.2 = [29 x i8] c"mission_objective_arrive_at \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [43 x i8] c"mission_objective_message_success Welcome!\00"
@.str.5 = [16 x i8] c" Next head for \00"
@.str.6 = [60 x i8] c"\0Amission_objective_message_fail You did not arrive safely.\0A\00"
define i8* @Create_Campaign_Arrive_Objective(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = call i64 @calloc(i32 512, i32 1)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %51
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %6
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %6
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %4
%21 = call i8* @Get_Location_Symbol(i32 %20)
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %30
24: ; preds = %13
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %24, %13
%31 = load i8*, i8** %6
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %6
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* %5
%36 = call i8* @Get_Location_Name(i32 %35)
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %47
39: ; preds = %30
%40 = load i8*, i8** %6
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @free(i8* %45)
br label %47
47: ; preds = %39, %30
%48 = load i8*, i8** %6
%49 = call i32 @strcat(i8* %48, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%50 = load i8*, i8** %6
store i8* %50, i8** %3
br label %51
51: ; preds = %47, %12
%52 = load i8*, i8** %3
ret i8* %52
}

LLVM IR (-O2):
@.str = [30 x i8] c"mission_objective_new arrive\0A\00"
@.str.1 = [33 x i8] c"mission_objective_time_left 0.0\0A\00"
@.str.2 = [29 x i8] c"mission_objective_arrive_at \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [43 x i8] c"mission_objective_message_success Welcome!\00"
@.str.5 = [16 x i8] c" Next head for \00"
@.str.6 = [60 x i8] c"\0Amission_objective_message_fail You did not arrive safely.\0A\00"
define i8* @Create_Campaign_Arrive_Objective(i32 %0, i32 %1) {
%3 = tail call i64 @calloc(i32 512, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %26, label %6
6: ; preds = %2
%7 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i8* @Get_Location_Symbol(i32 %0)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = tail call i32 @strcat(i8* %4, i8* %10)
%14 = tail call i32 @free(i8* %10)
br label %15
15: ; preds = %12, %6
%16 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i8* @Get_Location_Name(i32 %1)
%19 = icmp eq i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%22 = tail call i32 @strcat(i8* %4, i8* %18)
%23 = tail call i32 @free(i8* %18)
br label %24
24: ; preds = %20, %15
%25 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %26
26: ; preds = %2, %24
%27 = phi i8* [ %4, %24 ], [ null, %2 ]
ret i8* %27
}