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

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sha256_Raw(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ utils_uint8_to_hex(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wallet_report_xpub(char *, char *);
void wallet_report_id(char *id) {
  uint8_t h[32];
  char xpub[112] = {0};
  wallet_report_xpub("m/151'/144'", xpub);
  if (xpub[0]) {
    sha256_Raw((uint8_t *)xpub, 112, h);
    sha256_Raw(h, 32, h);
    memcpy(id, utils_uint8_to_hex(h, 32), 64);
  }
}


x86 assembly (clang, -O0):
<wallet_report_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0x70,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1070 <wallet_report_xpub@plt>
cmpb   $0x0,-0x100(%rbp)
je     11f1 <wallet_report_id+0xa1>
lea    -0x100(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    $0x70,%esi
call   1030 <sha256_Raw@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    $0x20,%esi
call   1030 <sha256_Raw@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x108(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
call   1040 <utils_uint8_to_hex@plt>
mov    -0x108(%rbp),%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1060 <memcpy@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wallet_report_id>:
push   %r14
push   %rbx
sub    $0xf8,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe87(%rip),%rdi
mov    %rsp,%rsi
call   1060 <wallet_report_xpub@plt>
cmpb   $0x0,(%rsp)
je     11c8 <wallet_report_id+0x88>
mov    %rsp,%rdi
lea    0x70(%rsp),%rbx
mov    $0x70,%esi
mov    %rbx,%rdx
call   1030 <sha256_Raw@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1030 <sha256_Raw@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <utils_uint8_to_hex@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1050 <memcpy@plt>
add    $0xf8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"m/151'/144'\00"
define void @wallet_report_id(i8* %0) {
%2 = alloca i8*
%3 = alloca [32 x i32]
%4 = alloca [112 x i8]
store i8* %0, i8** %2
%5 = bitcast [112 x i8]* %4 to i8*
%6 = getelementptr inbounds [112 x i8], [112 x i8]* %4, i64 0, i64 0
%7 = call i32 @wallet_report_xpub(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [112 x i8], [112 x i8]* %4, i64 0, i64 0
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %1
%12 = getelementptr inbounds [112 x i8], [112 x i8]* %4, i64 0, i64 0
%13 = bitcast i8* %12 to i32*
%14 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%15 = call i32 @sha256_Raw(i32* %13, i32 112, i32* %14)
%16 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%18 = call i32 @sha256_Raw(i32* %16, i32 32, i32* %17)
%19 = load i8*, i8** %2
%20 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%21 = call i32 @utils_uint8_to_hex(i32* %20, i32 32)
%22 = call i32 @memcpy(i8* %19, i32 %21, i32 64)
br label %23
23: ; preds = %11, %1
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"m/151'/144'\00"
define void @wallet_report_id(i8* %0) {
%2 = alloca [32 x i32]
%3 = alloca [112 x i8]
%4 = bitcast [32 x i32]* %2 to i8*
%5 = getelementptr inbounds [112 x i8], [112 x i8]* %3, i64 0, i64 0
%6 = call i32 @wallet_report_xpub(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %1
%10 = bitcast [112 x i8]* %3 to i32*
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
%12 = call i32 @sha256_Raw(i32* %10, i32 112, i32* %11)
%13 = call i32 @sha256_Raw(i32* %11, i32 32, i32* %11)
%14 = call i32 @utils_uint8_to_hex(i32* %11, i32 32)
%15 = call i32 @memcpy(i8* %0, i32 %14, i32 64)
br label %16
16: ; preds = %9, %1
ret void
}