#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*/ strcpy(char *, char *);
char *Create_Campaign_Weather() {
  char *weather_string;
  int random_num;
  weather_string = (char *)calloc(64, sizeof(char));
  if (!weather_string)
    return NULL;
  random_num = rand() % 8;
  switch (random_num) {
  case 0:
    strcpy(weather_string, "weather Clear");
    break;
  case 1:
    strcpy(weather_string, "weather Hazy");
    break;
  case 2:
    strcpy(weather_string, "weather Scattered");
    break;
  case 3:
    strcpy(weather_string, "weather Cloudy");
    break;
  case 4:
    strcpy(weather_string, "weather Overcast");
    break;
  case 5:
    strcpy(weather_string, "weather Foggy");
    break;
  case 6:
    strcpy(weather_string, "weather Stormy Sparse");
    break;
  case 7:
    strcpy(weather_string, "weather Stormy Dense");
    break;
  }
  return weather_string;
}


x86 assembly (clang, -O0):
<Create_Campaign_Weather>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x40,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <Create_Campaign_Weather+0x33>
movq   $0x0,-0x8(%rbp)
jmp    124e <Create_Campaign_Weather+0x11e>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%edx
add    $0x7,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x7,%rax
ja     1246 <Create_Campaign_Weather+0x116>
mov    -0x20(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1246 <Create_Campaign_Weather+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Create_Campaign_Weather>:
push   %rbx
mov    $0x40,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     117b <Create_Campaign_Weather+0x4b>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
cmp    $0x7,%eax
ja     117d <Create_Campaign_Weather+0x4d>
cltq
lea    0xf1e(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    117d <Create_Campaign_Weather+0x4d>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"weather Clear\00"
@.str.1 = [13 x i8] c"weather Hazy\00"
@.str.2 = [18 x i8] c"weather Scattered\00"
@.str.3 = [15 x i8] c"weather Cloudy\00"
@.str.4 = [17 x i8] c"weather Overcast\00"
@.str.5 = [14 x i8] c"weather Foggy\00"
@.str.6 = [22 x i8] c"weather Stormy Sparse\00"
@.str.7 = [21 x i8] c"weather Stormy Dense\00"
define i8* @Create_Campaign_Weather() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = call i64 @calloc(i32 64, i32 1)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i8* null, i8** %1
br label %39
9: ; preds = %0
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 8
store i32 %11, i32* %3
%12 = load i32, i32* %3
switch i32 %12, label %37 [
i32 0, label %13
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %25
i32 5, label %28
i32 6, label %31
i32 7, label %34
]
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %37
16: ; preds = %9
%17 = load i8*, i8** %2
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %37
19: ; preds = %9
%20 = load i8*, i8** %2
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %37
22: ; preds = %9
%23 = load i8*, i8** %2
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %37
25: ; preds = %9
%26 = load i8*, i8** %2
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %37
28: ; preds = %9
%29 = load i8*, i8** %2
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %37
31: ; preds = %9
%32 = load i8*, i8** %2
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %37
34: ; preds = %9
%35 = load i8*, i8** %2
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %37
37: ; preds = %9, %34, %31, %28, %25, %22, %19, %16, %13
%38 = load i8*, i8** %2
store i8* %38, i8** %1
br label %39
39: ; preds = %37, %8
%40 = load i8*, i8** %1
ret i8* %40
}

LLVM IR (-O2):
@.str = [14 x i8] c"weather Clear\00"
@.str.1 = [13 x i8] c"weather Hazy\00"
@.str.2 = [18 x i8] c"weather Scattered\00"
@.str.3 = [15 x i8] c"weather Cloudy\00"
@.str.4 = [17 x i8] c"weather Overcast\00"
@.str.5 = [14 x i8] c"weather Foggy\00"
@.str.6 = [22 x i8] c"weather Stormy Sparse\00"
@.str.7 = [21 x i8] c"weather Stormy Dense\00"
@reltable.Create_Campaign_Weather = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.Create_Campaign_Weather to i64)) to i32)]
define i8* @Create_Campaign_Weather() {
%1 = tail call i64 @calloc(i32 64, i32 1)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %13, label %4
4: ; preds = %0
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 8
%7 = icmp ult i32 %6, 8
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = sext i32 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.Create_Campaign_Weather to i8*), i64 %10)
%12 = tail call i32 @strcpy(i8* %2, i8* %11)
br label %13
13: ; preds = %4, %8, %0
%14 = phi i8* [ null, %0 ], [ %2, %4 ], [ %2, %8 ]
ret i8* %14
}