#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ gen_chain(unsigned char *, unsigned char *,
                             int /*<<< orphan*/, int, unsigned char const *,
                             int *);
int /*<<< orphan*/ set_chain_addr(int *, int);
int /*<<< orphan*/ wots_gen_sk(unsigned char *, unsigned char const *, int *);
void wots_gen_pk(unsigned char *pk, const unsigned char *sk_seed,
                 const unsigned char *pub_seed, uint32_t addr[8]) {
  uint32_t i;
  for (i = 0; i < ((8 * 16 / 4) + 3); i++) {
    set_chain_addr(addr, i);
    wots_gen_sk(pk + i * 16, sk_seed, addr);
    gen_chain(pk + i * 16, pk + i * 16, 0, 16 - 1, pub_seed, addr);
  }
}


x86 assembly (clang, -O0):
<wots_gen_pk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x23,-0x24(%rbp)
jge    11c1 <wots_gen_pk+0x91>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <set_chain_addr@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <wots_gen_sk@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rsi
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
xor    %edx,%edx
mov    $0xf,%ecx
call   1030 <gen_chain@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <wots_gen_pk+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wots_gen_pk>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13d,%esi
call   1040 <set_chain_addr@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <wots_gen_sk@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0xf,%ecx
mov    %r14,%r8
mov    %r12,%r9
call   1030 <gen_chain@plt>
add    $0x1,%r13
add    $0x10,%rbx
cmp    $0x23,%r13
jne    1150 <wots_gen_pk+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @wots_gen_pk(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
store i32 0, i32* %9
br label %10
10: ; preds = %38, %4
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 35
br i1 %12, label %13, label %41
13: ; preds = %10
%14 = load i32*, i32** %8
%15 = load i32, i32* %9
%16 = call i32 @set_chain_addr(i32* %14, i32 %15)
%17 = load i8*, i8** %5
%18 = load i32, i32* %9
%19 = mul nsw i32 %18, 16
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i8*, i8** %6
%23 = load i32*, i32** %8
%24 = call i32 @wots_gen_sk(i8* %21, i8* %22, i32* %23)
%25 = load i8*, i8** %5
%26 = load i32, i32* %9
%27 = mul nsw i32 %26, 16
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8*, i8** %5
%31 = load i32, i32* %9
%32 = mul nsw i32 %31, 16
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8*, i8** %7
%36 = load i32*, i32** %8
%37 = call i32 @gen_chain(i8* %29, i8* %34, i32 0, i32 15, i8* %35, i32* %36)
br label %38
38: ; preds = %13
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %10
41: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @wots_gen_pk(i8* %0, i8* %1, i8* %2, i32* %3) {
br label %5
5: ; preds = %4, %5
%6 = phi i64 [ 0, %4 ], [ %13, %5 ]
%7 = trunc i64 %6 to i32
%8 = tail call i32 @set_chain_addr(i32* %3, i32 %7)
%9 = shl nuw nsw i64 %6, 4
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i32 @wots_gen_sk(i8* %10, i8* %1, i32* %3)
%12 = tail call i32 @gen_chain(i8* %10, i8* %10, i32 0, i32 15, i8* %2, i32* %3)
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 35
br i1 %14, label %15, label %5
15: ; preds = %5
ret void
}