#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*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
char *crypt(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int time(int /*<<< orphan*/ *);
void new_pwd(char *src, char *encd) {
  int i, x, c;
  char xx[3];
  char *cr;
  if (encd == NULL)
    encd = src;
  if (strcmp(src, "") == 0) {
    bzero(encd, 16);
    return;
  }
  x = time((time_t *)NULL);
  xx[0] = x & 0x3f;
  xx[1] = (x & 0x3f00) >> 8;
  xx[2] = '\0';
  for (i = 0; i < 2; i++) {
    c = xx[i] + '.';
    if (c > '9')
      c += 7;
    if (c > 'Z')
      c += 6;
    xx[i] = c;
  }
  cr = crypt(src, xx);
  bzero(encd, 16);
  strncpy(encd, cr, 16);
}


x86 assembly (clang, -O0):
<new_pwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <new_pwd+0x23>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <new_pwd+0x50>
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <bzero@plt>
jmp    1259 <new_pwd+0x109>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x3f,%eax
mov    %al,-0x1f(%rbp)
mov    -0x18(%rbp),%eax
and    $0x3f00,%eax
sar    $0x8,%eax
mov    %al,-0x1e(%rbp)
movb   $0x0,-0x1d(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1228 <new_pwd+0xd8>
movslq -0x14(%rbp),%rax
movsbl -0x1f(%rbp,%rax,1),%eax
add    $0x2e,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x39,-0x1c(%rbp)
jle    11fa <new_pwd+0xaa>
mov    -0x1c(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x5a,-0x1c(%rbp)
jle    120d <new_pwd+0xbd>
mov    -0x1c(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1f(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <new_pwd+0x7e>
mov    -0x8(%rbp),%rdi
lea    -0x1f(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <bzero@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_pwd>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
cmove  %rdi,%rbx
lea    0xe98(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1206 <new_pwd+0xb6>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edx
and    $0x3f,%dl
mov    %eax,%ecx
shr    $0x8,%ecx
mov    %ecx,%esi
and    $0x3f,%sil
movb   $0x0,0x7(%rsp)
and    $0x3f,%eax
lea    0x2e(%rax),%edi
add    $0x35,%eax
cmp    $0xc,%dl
cmovb  %edi,%eax
lea    0x6(%rax),%edx
cmp    $0x5b,%eax
movzbl %dl,%edx
cmovb  %eax,%edx
mov    %dl,0x5(%rsp)
and    $0x3f,%ecx
lea    0x2e(%rcx),%eax
add    $0x35,%ecx
cmp    $0xc,%sil
cmovb  %eax,%ecx
lea    0x6(%rcx),%eax
cmp    $0x5b,%ecx
movzbl %al,%eax
cmovb  %ecx,%eax
mov    %al,0x6(%rsp)
lea    0x5(%rsp),%rsi
mov    %r14,%rdi
call   1040 <crypt@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <bzero@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    $0x10,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <bzero@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @new_pwd(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [3 x i8]
%9 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %3
store i8* %13, i8** %4
br label %14
14: ; preds = %12, %2
%15 = load i8*, i8** %3
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = call i32 @bzero(i8* %19, i32 16)
br label %72
21: ; preds = %14
%22 = call i32 @time(i32* null)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = and i32 %23, 63
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
store i8 %25, i8* %26
%27 = load i32, i32* %6
%28 = and i32 %27, 16128
%29 = ashr i32 %28, 8
%30 = trunc i32 %29 to i8
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 1
store i8 %30, i8* %31
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 2
store i8 0, i8* %32
store i32 0, i32* %5
br label %33
33: ; preds = %60, %21
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 2
br i1 %35, label %36, label %63
36: ; preds = %33
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = add nsw i32 %41, 46
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp sgt i32 %43, 57
br i1 %44, label %45, label %48
45: ; preds = %36
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 7
store i32 %47, i32* %7
br label %48
48: ; preds = %45, %36
%49 = load i32, i32* %7
%50 = icmp sgt i32 %49, 90
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 6
store i32 %53, i32* %7
br label %54
54: ; preds = %51, %48
%55 = load i32, i32* %7
%56 = trunc i32 %55 to i8
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 %58
store i8 %56, i8* %59
br label %60
60: ; preds = %54
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %33
63: ; preds = %33
%64 = load i8*, i8** %3
%65 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%66 = call i8* @crypt(i8* %64, i8* %65)
store i8* %66, i8** %9
%67 = load i8*, i8** %4
%68 = call i32 @bzero(i8* %67, i32 16)
%69 = load i8*, i8** %4
%70 = load i8*, i8** %9
%71 = call i32 @strncpy(i8* %69, i8* %70, i32 16)
br label %72
72: ; preds = %63, %18
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @new_pwd(i8* %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
%6 = select i1 %5, i8* %0, i8* %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @bzero(i8* %6, i32 16)
br label %39
11: ; preds = %2
%12 = tail call i32 @time(i32* null)
%13 = trunc i32 %12 to i8
%14 = and i8 %13, 63
%15 = lshr i32 %12, 8
%16 = trunc i32 %15 to i8
%17 = and i8 %16, 63
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %19
%20 = zext i8 %14 to i32
%21 = icmp ugt i8 %14, 11
%22 = select i1 %21, i32 53, i32 46
%23 = add nuw nsw i32 %22, %20
%24 = icmp ugt i32 %23, 90
%25 = add nuw nsw i32 %23, 6
%26 = select i1 %24, i32 %25, i32 %23
%27 = trunc i32 %26 to i8
store i8 %27, i8* %4
%28 = zext i8 %17 to i32
%29 = icmp ugt i8 %17, 11
%30 = select i1 %29, i32 53, i32 46
%31 = add nuw nsw i32 %30, %28
%32 = icmp ugt i32 %31, 90
%33 = add nuw nsw i32 %31, 6
%34 = select i1 %32, i32 %33, i32 %31
%35 = trunc i32 %34 to i8
store i8 %35, i8* %18
%36 = call i8* @crypt(i8* %0, i8* %4)
%37 = call i32 @bzero(i8* %6, i32 16)
%38 = call i32 @strncpy(i8* %6, i8* %36, i32 16)
br label %39
39: ; preds = %11, %9
ret void
}