#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 */
int rand();
void gera_senha(char senha[5]) {
  int i = 0;
  for (; i < 5 - 1; i++) {
    switch (rand() % 4) {
    case 0:
      senha[i] = 'R';
      break;
    case 1:
      senha[i] = 'G';
      break;
    case 2:
      senha[i] = 'Y';
      break;
    case 3:
      senha[i] = 'B';
      break;
    }
  }
  senha[5 - 1] = '\0';
}


x86 assembly (clang, -O0):
<gera_senha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11ba <gera_senha+0xaa>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11a7 <gera_senha+0x97>
mov    -0x18(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x52,(%rax,%rcx,1)
jmp    11a7 <gera_senha+0x97>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x47,(%rax,%rcx,1)
jmp    11a7 <gera_senha+0x97>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x59,(%rax,%rcx,1)
jmp    11a7 <gera_senha+0x97>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    11ac <gera_senha+0x9c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <gera_senha+0x13>
mov    -0x8(%rbp),%rax
movb   $0x0,0x4(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gera_senha>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     113b <gera_senha+0x2b>
shl    $0x3,%eax
mov    $0x42594752,%edx
mov    %eax,%ecx
shr    %cl,%edx
mov    %dl,(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     1163 <gera_senha+0x53>
shl    $0x3,%eax
mov    $0x42594752,%edx
mov    %eax,%ecx
shr    %cl,%edx
mov    %dl,0x1(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     118b <gera_senha+0x7b>
shl    $0x3,%eax
mov    $0x42594752,%edx
mov    %eax,%ecx
shr    %cl,%edx
mov    %dl,0x2(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     11b3 <gera_senha+0xa3>
shl    $0x3,%eax
mov    $0x42594752,%edx
mov    %eax,%ecx
shr    %cl,%edx
mov    %dl,0x3(%rbx)
movb   $0x0,0x4(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @gera_senha(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %31, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %34
7: ; preds = %4
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 4
switch i32 %9, label %30 [
i32 0, label %10
i32 1, label %15
i32 2, label %20
i32 3, label %25
]
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 82, i8* %14
br label %30
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 71, i8* %19
br label %30
20: ; preds = %7
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 89, i8* %24
br label %30
25: ; preds = %7
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 66, i8* %29
br label %30
30: ; preds = %7, %25, %20, %15, %10
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %4
34: ; preds = %4
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i64 4
store i8 0, i8* %36
ret void
}

LLVM IR (-O2):
define void @gera_senha(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 4
%4 = icmp ult i32 %3, 4
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = shl nsw i32 %3, 3
%7 = lshr i32 1113147218, %6
%8 = trunc i32 %7 to i8
store i8 %8, i8* %0
br label %9
9: ; preds = %1, %5
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 4
%12 = icmp ult i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = shl nsw i32 %11, 3
%15 = lshr i32 1113147218, %14
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %16, i8* %17
br label %18
18: ; preds = %9, %13
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 4
%21 = icmp ult i32 %20, 4
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = shl nsw i32 %20, 3
%24 = lshr i32 1113147218, %23
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %25, i8* %26
br label %27
27: ; preds = %18, %22
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 4
%30 = icmp ult i32 %29, 4
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = shl nsw i32 %29, 3
%33 = lshr i32 1113147218, %32
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %34, i8* %35
br label %36
36: ; preds = %27, %31
%37 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %37
ret void
}