#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
int do_rounding(int);
void genpass599(uint32_t x, unsigned char *psk) {
  static const char CHARSET[] = "abcdefghijkmnpqrstuvwxyz23456789#%+=?";
  int i;
  uint64_t key = x;
  key <<= 32;
  key += x << 1;
  key = do_rounding(key);
  psk[13 - 1] = 0;
  for (i = 1; i < 13; i++, key /= 37) {
    psk[13 - 1 - i] = CHARSET[key % 37];
  }
}


x86 assembly (clang, -O0):
<genpass599>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <do_rounding@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,0xc(%rax)
movl   $0x1,-0x14(%rbp)
cmpl   $0xd,-0x14(%rbp)
jge    11a8 <genpass599+0x98>
mov    -0x18(%rbp),%eax
mov    $0x25,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xe89(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    $0xc,%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x25,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1158 <genpass599+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genpass599>:
push   %rbx
mov    %rsi,%rbx
call   1030 <do_rounding@plt>
movb   $0x0,0xc(%rbx)
mov    $0xc,%ecx
lea    0xed7(%rip),%r8
nopl   0x0(%rax)
movslq %eax,%rsi
imul   $0xffffffffdd67c8a7,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x5,%eax
add    %edi,%eax
lea    (%rax,%rax,8),%edi
lea    (%rax,%rdi,4),%edi
sub    %edi,%esi
movslq %esi,%rsi
movzbl (%rsi,%r8,1),%edx
mov    %dl,-0x1(%rbx,%rcx,1)
add    $0xffffffffffffffff,%rcx
jne    1130 <genpass599+0x20>
pop    %rbx
ret

LLVM IR (-O0):
@genpass599.CHARSET = internal constant [38 x i8] c"abcdefghijkmnpqrstuvwxyz23456789#%+=?\00"
define void @genpass599(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i32, i32* %3
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = shl i32 %8, 32
store i32 %9, i32* %6
%10 = load i32, i32* %3
%11 = shl i32 %10, 1
%12 = load i32, i32* %6
%13 = add nsw i32 %12, %11
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @do_rounding(i32 %14)
store i32 %15, i32* %6
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 12
store i8 0, i8* %17
store i32 1, i32* %5
br label %18
18: ; preds = %32, %2
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 13
br i1 %20, label %21, label %37
21: ; preds = %18
%22 = load i32, i32* %6
%23 = srem i32 %22, 37
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [38 x i8], [38 x i8]* @genpass599.CHARSET, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = sub nsw i32 12, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 %26, i8* %31
br label %32
32: ; preds = %21
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
%35 = load i32, i32* %6
%36 = sdiv i32 %35, 37
store i32 %36, i32* %6
br label %18
37: ; preds = %18
ret void
}

LLVM IR (-O2):
@genpass599.CHARSET = internal unnamed_addr constant [38 x i8] c"abcdefghijkmnpqrstuvwxyz23456789#%+=?\00"
define void @genpass599(i32 %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @do_rounding(i32 poison)
%4 = getelementptr inbounds i8, i8* %1, i64 12
store i8 0, i8* %4
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 1, %2 ], [ %14, %5 ]
%7 = phi i32 [ %3, %2 ], [ %15, %5 ]
%8 = srem i32 %7, 37
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [38 x i8], [38 x i8]* @genpass599.CHARSET, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sub nuw nsw i64 12, %6
%13 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %11, i8* %13
%14 = add nuw nsw i64 %6, 1
%15 = sdiv i32 %7, 37
%16 = icmp eq i64 %14, 13
br i1 %16, label %17, label %5
17: ; preds = %5
ret void
}