char *nbsencrypt(str, key, result)
char *result;
char *str, *key;
{
  static char buf[20], oldbuf[20];
  register int j;
  result[0] = 0;
  strcpy(oldbuf, key);
  while (*str) {
    for (j = 0; j < 10; j++)
      buf[j] = 0;
    for (j = 0; j < 8 && *str; j++)
      buf[j] = *str++;
    strcat(result, nbs8encrypt(buf, oldbuf));
    strcat(result, "$");
    strcpy(oldbuf, buf);
  }
  return (result);
}


x86 assembly (clang, -O0):
<nbsencrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
lea    0x2f1a(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     124a <nbsencrypt+0x11a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1196 <nbsencrypt+0x66>
movslq -0x1c(%rbp),%rcx
lea    0x2ecc(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <nbsencrypt+0x3f>
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jge    11bc <nbsencrypt+0x8c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11cc <nbsencrypt+0x9c>
jmp    11f9 <nbsencrypt+0xc9>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%dl
movslq -0x1c(%rbp),%rcx
lea    0x2e68(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119d <nbsencrypt+0x6d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0x2e48(%rip),%rdi
lea    0x2e61(%rip),%rsi
mov    $0x0,%al
call   1040 <nbs8encrypt@plt>
mov    -0x28(%rbp),%rdi
movslq %eax,%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xdd3(%rip),%rsi
call   1050 <strcat@plt>
lea    0x2e37(%rip),%rdi
lea    0x2e10(%rip),%rsi
call   1030 <strcpy@plt>
jmp    115b <nbsencrypt+0x2b>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbsencrypt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
movb   $0x0,(%rdx)
lea    0x2f18(%rip),%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,(%rbx)
je     1281 <nbsencrypt+0x141>
lea    0x2ee3(%rip),%r15
lea    0x2efc(%rip),%r12
jmp    11bf <nbsencrypt+0x7f>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <nbs8encrypt@plt>
movslq %eax,%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movw   $0x24,(%r14,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,(%rbx)
je     1281 <nbsencrypt+0x141>
movw   $0x0,0x2e90(%rip)
movq   $0x0,0x2e7d(%rip)
movzbl (%rbx),%eax
test   %al,%al
je     1184 <nbsencrypt+0x44>
mov    %al,0x2e70(%rip)
movzbl 0x1(%rbx),%eax
test   %al,%al
je     1180 <nbsencrypt+0x40>
mov    %al,0x2e63(%rip)
movzbl 0x2(%rbx),%eax
test   %al,%al
je     124b <nbsencrypt+0x10b>
mov    %al,0x2e56(%rip)
movzbl 0x3(%rbx),%eax
test   %al,%al
je     1254 <nbsencrypt+0x114>
mov    %al,0x2e49(%rip)
movzbl 0x4(%rbx),%eax
test   %al,%al
je     125d <nbsencrypt+0x11d>
mov    %al,0x2e3c(%rip)
movzbl 0x5(%rbx),%eax
test   %al,%al
je     1266 <nbsencrypt+0x126>
mov    %al,0x2e2f(%rip)
movzbl 0x6(%rbx),%eax
test   %al,%al
je     126f <nbsencrypt+0x12f>
mov    %al,0x2e22(%rip)
movzbl 0x7(%rbx),%eax
test   %al,%al
je     1278 <nbsencrypt+0x138>
add    $0x8,%rbx
mov    %al,0x2e11(%rip)
jmp    1184 <nbsencrypt+0x44>
add    $0x2,%rbx
jmp    1184 <nbsencrypt+0x44>
add    $0x3,%rbx
jmp    1184 <nbsencrypt+0x44>
add    $0x4,%rbx
jmp    1184 <nbsencrypt+0x44>
add    $0x5,%rbx
jmp    1184 <nbsencrypt+0x44>
add    $0x6,%rbx
jmp    1184 <nbsencrypt+0x44>
add    $0x7,%rbx
jmp    1184 <nbsencrypt+0x44>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@nbsencrypt.buf = internal global [20 x i8] zeroinitializer
@nbsencrypt.oldbuf = internal global [20 x i8] zeroinitializer
@.str = [2 x i8] c"$\00"
define i8* @nbsencrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %5
%11 = call i8* @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %48, %3
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %57
16: ; preds = %12
store i32 0, i32* %7
br label %17
17: ; preds = %24, %16
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %20
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %17
27: ; preds = %17
store i32 0, i32* %7
br label %28
28: ; preds = %45, %27
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 8
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br label %36
36: ; preds = %31, %28
%37 = phi i1 [ false, %28 ], [ %35, %31 ]
br i1 %37, label %38, label %48
38: ; preds = %36
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
%41 = load i8, i8* %39
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 %43
store i8 %41, i8* %44
br label %45
45: ; preds = %38
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %28
48: ; preds = %36
%49 = load i8*, i8** %6
%50 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @nbs8encrypt to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0))
%51 = sext i32 %50 to i64
%52 = inttoptr i64 %51 to i8*
%53 = call i8* @strcat(i8* %49, i8* %52)
%54 = load i8*, i8** %6
%55 = call i8* @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%56 = call i8* @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 0))
br label %12
57: ; preds = %12
%58 = load i8*, i8** %6
ret i8* %58
}

LLVM IR (-O2):
@nbsencrypt.buf = internal global [20 x i8] zeroinitializer
@nbsencrypt.oldbuf = internal global [20 x i8] zeroinitializer
define i8* @nbsencrypt(i8* nocapture %0, i8* nocapture %1, i8* returned %2) {
store i8 0, i8* %2
%4 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0), i8* dereferenceable(1) %1)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %53, label %7
7: ; preds = %3, %41
%8 = phi i8* [ %42, %41 ], [ %0, %3 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %41, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 0)
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %41, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 1)
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %41, label %19
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %8, i64 3
store i8 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 2)
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %41, label %23
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %8, i64 4
store i8 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 3)
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %41, label %27
27: ; preds = %23
%28 = getelementptr inbounds i8, i8* %8, i64 5
store i8 %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 4)
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %41, label %31
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %8, i64 6
store i8 %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 5)
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %31
%36 = getelementptr inbounds i8, i8* %8, i64 7
store i8 %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 6)
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = getelementptr inbounds i8, i8* %8, i64 8
store i8 %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 7)
br label %41
41: ; preds = %39, %35, %31, %27, %23, %19, %15, %11, %7
%42 = phi i8* [ %8, %7 ], [ %12, %11 ], [ %16, %15 ], [ %20, %19 ], [ %24, %23 ], [ %28, %27 ], [ %32, %31 ], [ %36, %35 ], [ %40, %39 ]
%43 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @nbs8encrypt to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0))
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i8*
%46 = tail call i8* @strcat(i8* %2, i8* dereferenceable(1) %45)
%47 = tail call i64 @strlen(i8* %2)
%48 = getelementptr i8, i8* %2, i64 %47
%49 = bitcast i8* %48 to i16*
store i16 36, i16* %49
%50 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.oldbuf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @nbsencrypt.buf, i64 0, i64 0))
%51 = load i8, i8* %42
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %7
53: ; preds = %41, %3
ret i8* %2
}