#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 /*<<< orphan*/ sprintf(char *, char *, unsigned long, unsigned long);
char *mysql3_crypt(unsigned char *password) {
  static char hex_format[17];
  register unsigned long nr = 1345345333L, add = 7, nr2 = 0x12345671L;
  unsigned long tmp, result[2];
  for (; *password; password++) {
    if (*password == ' ' || *password == '\t')
      continue;
    tmp = (unsigned long)*password;
    nr ^= (((nr & 63) + add) * tmp) + (nr << 8);
    nr2 += (nr2 << 8) ^ nr;
    add += tmp;
  }
  result[0] = nr & (((unsigned long)1L << 31) - 1L);
  ;
  result[1] = nr2 & (((unsigned long)1L << 31) - 1L);
  sprintf(hex_format, "%08lx%08lx", result[0], result[1]);
  hex_format[16] = '\0';
  return hex_format;
}


x86 assembly (clang, -O0):
<mysql3_crypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x50305735,-0x10(%rbp)
50
movq   $0x7,-0x18(%rbp)
movq   $0x12345671,-0x20(%rbp)
12
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c6 <mysql3_crypt+0xb6>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
je     1161 <mysql3_crypt+0x51>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x9,%eax
jne    1166 <mysql3_crypt+0x56>
jmp    11b5 <mysql3_crypt+0xa5>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
and    $0x3f,%rax
add    -0x18(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
xor    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <mysql3_crypt+0x24>
mov    -0x10(%rbp),%rax
and    $0x7fffffff,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
and    $0x7fffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
lea    0x2e4f(%rip),%rdi
lea    0xe08(%rip),%rsi
call   1030 <sprintf@plt>
movb   $0x0,0x2e4c(%rip)
lea    0x2e35(%rip),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysql3_crypt>:
push   %rbx
mov    $0x50305735,%edx
mov    $0x7,%r8d
mov    $0x12345671,%ecx
jmp    1134 <mysql3_crypt+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
movzbl (%rdi),%esi
cmp    $0x9,%rsi
je     1130 <mysql3_crypt+0x20>
cmp    $0x20,%sil
je     1130 <mysql3_crypt+0x20>
test   %sil,%sil
je     1173 <mysql3_crypt+0x63>
mov    %edx,%ebx
and    $0x3f,%ebx
add    %r8,%rbx
imul   %rsi,%rbx
mov    %rdx,%rax
shl    $0x8,%rax
add    %rbx,%rax
xor    %rax,%rdx
mov    %rcx,%rax
shl    $0x8,%rax
xor    %rdx,%rax
add    %rax,%rcx
add    %rsi,%r8
jmp    1130 <mysql3_crypt+0x20>
and    $0x7fffffff,%edx
and    $0x7fffffff,%ecx
lea    0x2eba(%rip),%rbx
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
movb   $0x0,0x2eb4(%rip)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@mysql3_crypt.hex_format = internal global [17 x i8] zeroinitializer
@.str = [11 x i8] c"%08lx%08lx\00"
define i8* @mysql3_crypt(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca [2 x i64]
store i8* %0, i8** %2
store i64 1345345333, i64* %3
store i64 7, i64* %4
store i64 305419889, i64* %5
br label %8
8: ; preds = %47, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = icmp eq i32 %20, 9
br i1 %21, label %22, label %23
22: ; preds = %17, %12
br label %47
23: ; preds = %17
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i64
store i64 %26, i64* %6
%27 = load i64, i64* %3
%28 = and i64 %27, 63
%29 = load i64, i64* %4
%30 = add i64 %28, %29
%31 = load i64, i64* %6
%32 = mul i64 %30, %31
%33 = load i64, i64* %3
%34 = shl i64 %33, 8
%35 = add i64 %32, %34
%36 = load i64, i64* %3
%37 = xor i64 %36, %35
store i64 %37, i64* %3
%38 = load i64, i64* %5
%39 = shl i64 %38, 8
%40 = load i64, i64* %3
%41 = xor i64 %39, %40
%42 = load i64, i64* %5
%43 = add i64 %42, %41
store i64 %43, i64* %5
%44 = load i64, i64* %6
%45 = load i64, i64* %4
%46 = add i64 %45, %44
store i64 %46, i64* %4
br label %47
47: ; preds = %23, %22
%48 = load i8*, i8** %2
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %2
br label %8
50: ; preds = %8
%51 = load i64, i64* %3
%52 = and i64 %51, 2147483647
%53 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
store i64 %52, i64* %53
%54 = load i64, i64* %5
%55 = and i64 %54, 2147483647
%56 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 %55, i64* %56
%57 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%58 = load i64, i64* %57
%59 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
%60 = load i64, i64* %59
%61 = call i32 @sprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %58, i64 %60)
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 16)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 0)
}

LLVM IR (-O2):
@mysql3_crypt.hex_format = internal global [17 x i8] zeroinitializer
@.str = [11 x i8] c"%08lx%08lx\00"
define i8* @mysql3_crypt(i8* nocapture %0) {
br label %2
2: ; preds = %20, %1
%3 = phi i64 [ 305419889, %1 ], [ %21, %20 ]
%4 = phi i64 [ 7, %1 ], [ %22, %20 ]
%5 = phi i64 [ 1345345333, %1 ], [ %23, %20 ]
%6 = phi i8* [ %0, %1 ], [ %24, %20 ]
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 0, label %25
i8 32, label %20
i8 9, label %20
]
8: ; preds = %2
%9 = zext i8 %7 to i64
%10 = and i64 %5, 63
%11 = add i64 %10, %4
%12 = mul i64 %11, %9
%13 = shl i64 %5, 8
%14 = add i64 %12, %13
%15 = xor i64 %14, %5
%16 = shl i64 %3, 8
%17 = xor i64 %15, %16
%18 = add i64 %17, %3
%19 = add i64 %4, %9
br label %20
20: ; preds = %2, %2, %8
%21 = phi i64 [ %18, %8 ], [ %3, %2 ], [ %3, %2 ]
%22 = phi i64 [ %19, %8 ], [ %4, %2 ], [ %4, %2 ]
%23 = phi i64 [ %15, %8 ], [ %5, %2 ], [ %5, %2 ]
%24 = getelementptr inbounds i8, i8* %6, i64 1
br label %2
25: ; preds = %2
%26 = and i64 %5, 2147483647
%27 = and i64 %3, 2147483647
%28 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %26, i64 %27)
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 16)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @mysql3_crypt.hex_format, i64 0, i64 0)
}