#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*/ BTCrackStep2(unsigned char *, unsigned char *,
                                unsigned char *);
int GetPIN(unsigned char *in_bdaddr_a, unsigned char *in_bdaddr_b,
           unsigned char *in_lkrand_a, unsigned char *in_lkrand_b,
           unsigned char *out_kab) {
  unsigned char lk_ka[16], lk_kb[16];
  int i;
  BTCrackStep2(in_lkrand_a, in_bdaddr_a, lk_ka);
  BTCrackStep2(in_lkrand_b, in_bdaddr_b, lk_kb);
  for (i = 0; i < 16; i++) {
    out_kab[i] = lk_ka[i] ^ lk_kb[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<GetPIN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <BTCrackStep2@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1030 <BTCrackStep2@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    118e <GetPIN+0x7e>
movslq -0x54(%rbp),%rax
movzbl -0x40(%rbp,%rax,1),%eax
movslq -0x54(%rbp),%rcx
movzbl -0x50(%rbp,%rcx,1),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1155 <GetPIN+0x45>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetPIN>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rax
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1030 <BTCrackStep2@plt>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <BTCrackStep2@plt>
movaps (%rsp),%xmm0
xorps  0x10(%rsp),%xmm0
movups %xmm0,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @GetPIN(i8* %0, i8* %1, i8* %2, i8* %3, i8* nocapture writeonly %4) {
%6 = alloca <16 x i8>
%7 = alloca <16 x i8>
%8 = getelementptr inbounds <16 x i8>, <16 x i8>* %6, i64 0, i64 0
%9 = getelementptr inbounds <16 x i8>, <16 x i8>* %7, i64 0, i64 0
%10 = call i32 @BTCrackStep2(i8* %2, i8* %0, i8* %8)
%11 = call i32 @BTCrackStep2(i8* %3, i8* %1, i8* %9)
%12 = load <16 x i8>, <16 x i8>* %6
%13 = load <16 x i8>, <16 x i8>* %7
%14 = xor <16 x i8> %13, %12
%15 = bitcast i8* %4 to <16 x i8>*
store <16 x i8> %14, <16 x i8>* %15
ret i32 0
}