#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*/ const uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ memcmp(int /*<<< orphan*/ const *, int /*<<< orphan*/ const *, int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *const, int);
int /*<<< orphan*/ printf(char *);
int recompute(scalar_t__, scalar_t__, int /*<<< orphan*/ const *const *, size_t,
              int /*<<< orphan*/ const *);
int recompute_rec(scalar_t__, scalar_t__, int /*<<< orphan*/ const *const *,
                  size_t, int, int /*<<< orphan*/ const *, int /*<<< orphan*/);
int verify(uint32_t offset, uint32_t i, uint32_t n, uint8_t *const *path,
           size_t path_len, const uint8_t *root) {
  uint8_t acc_rec[32], acc_itr[32];
  memcpy(acc_rec, path[0], 32);
  int r1 = recompute_rec(i - offset, n - offset, path, path_len, 1, acc_rec, 0);
  int r2 = recompute(i - offset, n - offset, path, path_len, acc_itr);
  if (r1 != 0 || r2 != 0) {
    printf("Recomputation error\n");
    return 1;
  }
  assert(memcmp(acc_rec, acc_itr, 32) == 0);
  return memcmp(acc_itr, root, 32) != 0;
}


x86 assembly (clang, -O0):
<verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
mov    $0x20,%edx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rdi
sub    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    -0xc0(%rbp),%r9
mov    $0x1,%r8d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1080 <recompute_rec@plt>
mov    %eax,-0x144(%rbp)
mov    -0x18(%rbp),%rdi
sub    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    -0x140(%rbp),%r8
call   1070 <recompute@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x0,-0x144(%rbp)
jne    1218 <verify+0xb8>
cmpl   $0x0,-0x148(%rbp)
je     1230 <verify+0xd0>
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    127d <verify+0x11d>
lea    -0xc0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x140(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r12
mov    (%rcx),%rsi
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    $0x20,%edx
call   1060 <memcpy@plt>
sub    %r12,%rbx
sub    %r12,%rbp
movl   $0x0,(%rsp)
mov    $0x1,%r12d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    $0x1,%r8d
mov    %r14,%r9
call   1080 <recompute_rec@plt>
mov    %eax,%r14d
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1070 <recompute@plt>
or     %r14d,%eax
je     11f6 <verify+0x96>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
jmp    123a <verify+0xda>
lea    0x90(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    $0x20,%edx
call   1040 <memcmp@plt>
xor    %r12d,%r12d
test   %rax,%rax
setne  %r12b
mov    %r12d,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Recomputation error\0A\00"
define i32 @verify(i64 %0, i64 %1, i64 %2, i32** %3, i64 %4, i32* %5) {
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32**
%12 = alloca i64
%13 = alloca i32*
%14 = alloca [32 x i32]
%15 = alloca [32 x i32]
%16 = alloca i32
%17 = alloca i32
store i64 %0, i64* %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i32** %3, i32*** %11
store i64 %4, i64* %12
store i32* %5, i32** %13
%18 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 0
%19 = load i32**, i32*** %11
%20 = getelementptr inbounds i32*, i32** %19, i64 0
%21 = load i32*, i32** %20
%22 = call i32 @memcpy(i32* %18, i32* %21, i32 32)
%23 = load i64, i64* %9
%24 = load i64, i64* %8
%25 = sub nsw i64 %23, %24
%26 = load i64, i64* %10
%27 = load i64, i64* %8
%28 = sub nsw i64 %26, %27
%29 = load i32**, i32*** %11
%30 = load i64, i64* %12
%31 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 0
%32 = call i32 @recompute_rec(i64 %25, i64 %28, i32** %29, i64 %30, i32 1, i32* %31, i32 0)
store i32 %32, i32* %16
%33 = load i64, i64* %9
%34 = load i64, i64* %8
%35 = sub nsw i64 %33, %34
%36 = load i64, i64* %10
%37 = load i64, i64* %8
%38 = sub nsw i64 %36, %37
%39 = load i32**, i32*** %11
%40 = load i64, i64* %12
%41 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%42 = call i32 @recompute(i64 %35, i64 %38, i32** %39, i64 %40, i32* %41)
store i32 %42, i32* %17
%43 = load i32, i32* %16
%44 = icmp ne i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %6
%46 = load i32, i32* %17
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45, %6
%49 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %7
br label %62
50: ; preds = %45
%51 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 0
%52 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%53 = call i64 @memcmp(i32* %51, i32* %52, i32 32)
%54 = icmp eq i64 %53, 0
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%58 = load i32*, i32** %13
%59 = call i64 @memcmp(i32* %57, i32* %58, i32 32)
%60 = icmp ne i64 %59, 0
%61 = zext i1 %60 to i32
store i32 %61, i32* %7
br label %62
62: ; preds = %50, %48
%63 = load i32, i32* %7
ret i32 %63
}

LLVM IR (-O2):
@str = [20 x i8] c"Recomputation error\00"
define i32 @verify(i64 %0, i64 %1, i64 %2, i32** %3, i64 %4, i32* %5) {
%7 = alloca [32 x i32]
%8 = alloca [32 x i32]
%9 = bitcast [32 x i32]* %7 to i8*
%10 = bitcast [32 x i32]* %8 to i8*
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32 @memcpy(i32* %11, i32* %12, i32 32)
%14 = sub nsw i64 %1, %0
%15 = sub nsw i64 %2, %0
%16 = call i32 @recompute_rec(i64 %14, i64 %15, i32** %3, i64 %4, i32 1, i32* %11, i32 0)
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %8, i64 0, i64 0
%18 = call i32 @recompute(i64 %14, i64 %15, i32** %3, i64 %4, i32* %17)
%19 = icmp ne i32 %16, 0
%20 = icmp ne i32 %18, 0
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %24
22: ; preds = %6
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %32
24: ; preds = %6
%25 = call i64 @memcmp(i32* %11, i32* %17, i32 32)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i64 @memcmp(i32* %17, i32* %5, i32 32)
%30 = icmp ne i64 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %24, %22
%33 = phi i32 [ 1, %22 ], [ %31, %24 ]
ret i32 %33
}