#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_Description(int first_objective) {
  char *buffer;
  char *place_name;
  buffer = (char *)calloc(1024, sizeof(char));
  if (!buffer)
    return NULL;
  strcpy(buffer, "name Mission: Patrol\n");
  strcat(buffer, "description ");
  if (first_objective == 6)
    strcat(buffer, "Search the local area for an accident victim.\n");
  else {
    place_name = Get_Location_Name(first_objective);
    if (place_name) {
      strcat(buffer, "Fly to ");
      strcat(buffer, place_name);
      strcat(buffer, ".\n");
      free(place_name);
    }
  }
  return buffer;
}


x86 assembly (clang, -O0):
<Create_Campaign_Description>:
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_Description+0x36>
movq   $0x0,-0x8(%rbp)
jmp    121f <Create_Campaign_Description+0xcf>
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1070 <strcat@plt>
cmpl   $0x6,-0xc(%rbp)
jne    11c5 <Create_Campaign_Description+0x75>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1070 <strcat@plt>
jmp    1217 <Create_Campaign_Description+0xc7>
mov    -0xc(%rbp),%edi
call   1030 <Get_Location_Name@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1212 <Create_Campaign_Description+0xc2>
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
jmp    1217 <Create_Campaign_Description+0xc7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Create_Campaign_Description>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x400,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     11a0 <Create_Campaign_Description+0x50>
mov    %rax,%rbx
lea    0xe8d(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
cmp    $0x6,%ebp
jne    11a4 <Create_Campaign_Description+0x54>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
jmp    11e4 <Create_Campaign_Description+0x94>
xor    %ebx,%ebx
jmp    11e4 <Create_Campaign_Description+0x94>
mov    %ebp,%edi
call   1030 <Get_Location_Name@plt>
test   %rax,%rax
je     11e4 <Create_Campaign_Description+0x94>
mov    %rax,%rbp
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"name Mission: Patrol\0A\00"
@.str.1 = [13 x i8] c"description \00"
@.str.2 = [47 x i8] c"Search the local area for an accident victim.\0A\00"
@.str.3 = [8 x i8] c"Fly to \00"
@.str.4 = [3 x i8] c".\0A\00"
define i8* @Create_Campaign_Description(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 %39
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %4
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 6
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i8*, i8** %4
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %37
21: ; preds = %11
%22 = load i32, i32* %3
%23 = call i8* @Get_Location_Name(i32 %22)
store i8* %23, i8** %5
%24 = load i8*, i8** %5
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = load i8*, i8** %4
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%34 = load i8*, i8** %5
%35 = call i32 @free(i8* %34)
br label %36
36: ; preds = %26, %21
br label %37
37: ; preds = %36, %18
%38 = load i8*, i8** %4
store i8* %38, i8** %2
br label %39
39: ; preds = %37, %10
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
@.str = [22 x i8] c"name Mission: Patrol\0A\00"
@.str.1 = [13 x i8] c"description \00"
@.str.2 = [47 x i8] c"Search the local area for an accident victim.\0A\00"
@.str.3 = [8 x i8] c"Fly to \00"
@.str.4 = [3 x i8] c".\0A\00"
define i8* @Create_Campaign_Description(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 %19, label %5
5: ; preds = %1
%6 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %0, 6
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %19
11: ; preds = %5
%12 = tail call i8* @Get_Location_Name(i32 %0)
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @strcat(i8* %3, i8* %12)
%17 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 @free(i8* %12)
br label %19
19: ; preds = %9, %14, %11, %1
%20 = phi i8* [ null, %1 ], [ %3, %11 ], [ %3, %14 ], [ %3, %9 ]
ret i8* %20
}