#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 *malloc(int);
int rand();
int /*<<< orphan*/ strcpy(char *, char *);
char *dress() {
  int random_index;
  char *dress;
  dress = malloc(5 * sizeof(char));
  char *dresses[6] = {"d++", "d+", "d", "d-", "d--", "d---"};
  random_index = rand() % 6;
  strcpy(dress, dresses[random_index]);
  return dress;
}


x86 assembly (clang, -O0):
<dress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x5,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xe93(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe8c(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe84(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe7b(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe73(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe6c(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x4(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dress>:
push   %rbx
sub    $0x30,%rsp
mov    $0x5,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rax
mov    %rax,(%rsp)
lea    0xeb0(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xea7(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe9d(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe94(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe8c(%rip),%rax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cltq
mov    (%rsp,%rax,8),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"d++\00"
@.str.1 = [3 x i8] c"d+\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [3 x i8] c"d-\00"
@.str.4 = [4 x i8] c"d--\00"
@.str.5 = [5 x i8] c"d---\00"
define i8* @dress() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [6 x i8*]
%4 = call i8* @malloc(i32 5)
store i8* %4, i8** %2
%5 = bitcast [6 x i8*]* %3 to i8*
%6 = bitcast i8* %5 to [6 x i8*]*
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %12
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 6
store i32 %14, i32* %1
%15 = load i8*, i8** %2
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %15, i8* %19)
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"d++\00"
@.str.1 = [3 x i8] c"d+\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [3 x i8] c"d-\00"
@.str.4 = [4 x i8] c"d--\00"
@.str.5 = [5 x i8] c"d---\00"
define i8* @dress() {
%1 = alloca [6 x i8*]
%2 = tail call dereferenceable_or_null(5) i8* @malloc(i32 5)
%3 = bitcast [6 x i8*]* %1 to i8*
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %9
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strcpy(i8* %2, i8* %14)
ret i8* %2
}