#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 */
typedef int /*<<< orphan*/ DES_cblock;

/* Variables and functions */
int /*<<< orphan*/ afs_cmu_StringToKey(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ afs_transarc_StringToKey(char *, char *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ mklower(char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void afs_string_to_key(char *str, char *cell, DES_cblock *key) {
  char realm[40 + 1];
  strncpy(realm, cell, 40);
  realm[40] = 0;
  mklower(realm);
  if (strlen(str) > 8)
    afs_transarc_StringToKey(str, realm, key);
  else
    afs_cmu_StringToKey(str, realm, key);
}


x86 assembly (clang, -O0):
<afs_string_to_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x28,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
call   1050 <mklower@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x8,%eax
jle    11ab <afs_string_to_key+0x5b>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <afs_transarc_StringToKey@plt>
jmp    11bc <afs_string_to_key+0x6c>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <afs_cmu_StringToKey@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<afs_string_to_key>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x28,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x28(%rsp)
mov    %r15,%rdi
call   1050 <mklower@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
cmp    $0x9,%eax
jl     1199 <afs_string_to_key+0x49>
call   1070 <afs_transarc_StringToKey@plt>
jmp    119e <afs_string_to_key+0x4e>
call   1060 <afs_cmu_StringToKey@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @afs_string_to_key(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [41 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %5
%10 = call i32 @strncpy(i8* %8, i8* %9, i32 40)
%11 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 40
store i8 0, i8* %11
%12 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%13 = call i32 @mklower(i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = icmp sgt i32 %15, 8
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%20 = load i32*, i32** %6
%21 = call i32 @afs_transarc_StringToKey(i8* %18, i8* %19, i32* %20)
br label %27
22: ; preds = %3
%23 = load i8*, i8** %4
%24 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %6
%26 = call i32 @afs_cmu_StringToKey(i8* %23, i8* %24, i32* %25)
br label %27
27: ; preds = %22, %17
ret void
}

LLVM IR (-O2):
define void @afs_string_to_key(i8* %0, i8* %1, i32* %2) {
%4 = alloca [41 x i8]
%5 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%6 = call i32 @strncpy(i8* %5, i8* %1, i32 40)
%7 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 40
store i8 0, i8* %7
%8 = call i32 @mklower(i8* %5)
%9 = call i32 @strlen(i8* %0)
%10 = icmp sgt i32 %9, 8
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @afs_transarc_StringToKey(i8* %0, i8* %5, i32* %2)
br label %15
13: ; preds = %3
%14 = call i32 @afs_cmu_StringToKey(i8* %0, i8* %5, i32* %2)
br label %15
15: ; preds = %13, %11
ret void
}