#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();
int f6(char login[]) {
  int result;
  char letter;
  if (login[0] == 0)
    return 0;
  result = rand();
  letter = login[0];
  while (--letter) {
    result = rand();
  }
  return ((result & 0xff) ^ 0xe5) & 0x3f;
}


x86 assembly (clang, -O0):
<f6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1138 <f6+0x28>
movl   $0x0,-0x4(%rbp)
jmp    117d <f6+0x6d>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
add    $0xff,%al
mov    %al,-0x15(%rbp)
cmp    $0x0,%al
je     116a <f6+0x5a>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x14(%rbp)
jmp    114b <f6+0x3b>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
xor    $0xe5,%eax
and    $0x3f,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f6>:
push   %rbx
cmpb   $0x0,(%rdi)
je     1144 <f6+0x34>
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <rand@plt>
mov    (%rbx),%bl
add    $0xff,%bl
je     113c <f6+0x2c>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
add    $0xff,%bl
jne    1130 <f6+0x20>
and    $0x3f,%eax
xor    $0x25,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @f6(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %28
12: ; preds = %1
%13 = call i32 (...) @rand()
store i32 %13, i32* %4
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
store i8 %16, i8* %5
br label %17
17: ; preds = %21, %12
%18 = load i8, i8* %5
%19 = add i8 %18, -1
store i8 %19, i8* %5
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @rand()
store i32 %22, i32* %4
br label %17
23: ; preds = %17
%24 = load i32, i32* %4
%25 = and i32 %24, 255
%26 = xor i32 %25, 229
%27 = and i32 %26, 63
store i32 %27, i32* %2
br label %28
28: ; preds = %23, %11
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @f6(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %1
%5 = tail call i32 (...) @rand()
%6 = load i8, i8* %0
%7 = add i8 %6, -1
%8 = icmp eq i8 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %4, %9
%10 = phi i8 [ %12, %9 ], [ %7, %4 ]
%11 = tail call i32 (...) @rand()
%12 = add i8 %10, -1
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %9
14: ; preds = %9, %4
%15 = phi i32 [ %5, %4 ], [ %11, %9 ]
%16 = and i32 %15, 63
%17 = xor i32 %16, 37
br label %18
18: ; preds = %1, %14
%19 = phi i32 [ %17, %14 ], [ 0, %1 ]
ret i32 %19
}