#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 */
scalar_t__ calloc(int, int);
int rand();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *Create_Campaign_Aircraft(int all_arrivals) {
  char *craft_name;
  int aircraft_number;
  craft_name = (char *)calloc(128, sizeof(char));
  if (!craft_name)
    return NULL;
  strcpy(craft_name, "player_model_file aircrafts/");
  if (all_arrivals)
    aircraft_number = rand() % 8;
  else
    aircraft_number = rand() % 4;
  switch (aircraft_number) {
  case 0:
    strcat(craft_name, "hh60.3d");
    break;
  case 1:
    strcat(craft_name, "hh65.3d");
    break;
  case 2:
    strcat(craft_name, "ka27.3d");
    break;
  case 3:
    strcat(craft_name, "v22.3d");
    break;
  case 4:
    strcat(craft_name, "as350.3d");
    break;
  case 5:
    strcat(craft_name, "b47.3d");
    break;
  case 6:
    strcat(craft_name, "s64.3d");
    break;
  case 7:
    strcat(craft_name, "uh1d.3d");
    break;
  }
  return craft_name;
}


x86 assembly (clang, -O0):
<Create_Campaign_Aircraft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    $0x80,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1176 <Create_Campaign_Aircraft+0x36>
movq   $0x0,-0x8(%rbp)
jmp    1289 <Create_Campaign_Aircraft+0x149>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a7 <Create_Campaign_Aircraft+0x67>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
jmp    11b9 <Create_Campaign_Aircraft+0x79>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x7,%rax
ja     1281 <Create_Campaign_Aircraft+0x141>
mov    -0x28(%rbp),%rax
lea    0xe2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcat@plt>
jmp    1281 <Create_Campaign_Aircraft+0x141>
mov    -0x18(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Create_Campaign_Aircraft>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x80,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     11a7 <Create_Campaign_Aircraft+0x67>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
xor    %ebp,%ebp
test   %r14d,%r14d
setne  %bpl
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x4(,%rbp,4),%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
ja     11a9 <Create_Campaign_Aircraft+0x69>
movslq %edx,%rax
lea    0xec6(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
jmp    11a9 <Create_Campaign_Aircraft+0x69>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"player_model_file aircrafts/\00"
@.str.1 = [8 x i8] c"hh60.3d\00"
@.str.2 = [8 x i8] c"hh65.3d\00"
@.str.3 = [8 x i8] c"ka27.3d\00"
@.str.4 = [7 x i8] c"v22.3d\00"
@.str.5 = [9 x i8] c"as350.3d\00"
@.str.6 = [7 x i8] c"b47.3d\00"
@.str.7 = [7 x i8] c"s64.3d\00"
@.str.8 = [8 x i8] c"uh1d.3d\00"
define i8* @Create_Campaign_Aircraft(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
%6 = call i64 @calloc(i32 128, 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 %50
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 8
store i32 %18, i32* %5
br label %22
19: ; preds = %11
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 4
store i32 %21, i32* %5
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %5
switch i32 %23, label %48 [
i32 0, label %24
i32 1, label %27
i32 2, label %30
i32 3, label %33
i32 4, label %36
i32 5, label %39
i32 6, label %42
i32 7, label %45
]
24: ; preds = %22
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %48
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %48
30: ; preds = %22
%31 = load i8*, i8** %4
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %48
33: ; preds = %22
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %48
36: ; preds = %22
%37 = load i8*, i8** %4
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %48
39: ; preds = %22
%40 = load i8*, i8** %4
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %48
42: ; preds = %22
%43 = load i8*, i8** %4
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %48
45: ; preds = %22
%46 = load i8*, i8** %4
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %48
48: ; preds = %22, %45, %42, %39, %36, %33, %30, %27, %24
%49 = load i8*, i8** %4
store i8* %49, i8** %2
br label %50
50: ; preds = %48, %10
%51 = load i8*, i8** %2
ret i8* %51
}

LLVM IR (-O2):
@.str = [29 x i8] c"player_model_file aircrafts/\00"
@.str.1 = [8 x i8] c"hh60.3d\00"
@.str.2 = [8 x i8] c"hh65.3d\00"
@.str.3 = [8 x i8] c"ka27.3d\00"
@.str.4 = [7 x i8] c"v22.3d\00"
@.str.5 = [9 x i8] c"as350.3d\00"
@.str.6 = [7 x i8] c"b47.3d\00"
@.str.7 = [7 x i8] c"s64.3d\00"
@.str.8 = [8 x i8] c"uh1d.3d\00"
@reltable.Create_Campaign_Aircraft = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Aircraft to i64)) to i32)]
define i8* @Create_Campaign_Aircraft(i32 %0) {
%2 = tail call i64 @calloc(i32 128, i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %0, 0
%8 = tail call i32 (...) @rand()
%9 = select i1 %7, i32 4, i32 8
%10 = srem i32 %8, %9
%11 = icmp ult i32 %10, 8
br i1 %11, label %12, label %17
12: ; preds = %5
%13 = sext i32 %10 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.Create_Campaign_Aircraft to i8*), i64 %14)
%16 = tail call i32 @strcat(i8* %3, i8* %15)
br label %17
17: ; preds = %5, %12, %1
%18 = phi i8* [ null, %1 ], [ %3, %5 ], [ %3, %12 ]
ret i8* %18
}