#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 */
scalar_t__ cust_hash(unsigned char *, unsigned int, unsigned char *, int);
int cust_verify(unsigned char *data_buf, unsigned int data_len,
                unsigned char *sig_buf, unsigned int sig_len) {
  if ((128) == sig_len) {
    unsigned char sha1sum[(20)] = {0};
    if (cust_hash(data_buf, data_len, sha1sum, (20)) != 0) {
      return -1;
    }
    return -1;
  } else if ((256) == sig_len) {
    unsigned char sha256sum[(32)] = {0};
    if (cust_hash(data_buf, data_len, sha256sum, (32)) != 0) {
      return -1;
    }
    return -1;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<cust_verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    $0x80,%eax
cmp    -0x24(%rbp),%eax
jne    118b <cust_verify+0x6b>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    $0x14,%ecx
call   1040 <cust_hash@plt>
cmp    $0x0,%rax
je     117f <cust_verify+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <cust_verify+0xc7>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <cust_verify+0xc7>
mov    $0x100,%eax
cmp    -0x24(%rbp),%eax
jne    11e0 <cust_verify+0xc0>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rdx
mov    $0x20,%ecx
call   1040 <cust_hash@plt>
cmp    $0x0,%rax
je     11d4 <cust_verify+0xb4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <cust_verify+0xc7>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <cust_verify+0xc7>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cust_verify>:
sub    $0x28,%rsp
cmp    $0x100,%ecx
je     113d <cust_verify+0x2d>
cmp    $0x80,%ecx
jne    1156 <cust_verify+0x46>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rdx
mov    $0x14,%ecx
jmp    1151 <cust_verify+0x41>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
mov    $0x20,%ecx
call   1030 <cust_hash@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @cust_verify(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [20 x i8]
%11 = alloca [32 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i32, i32* %9
%13 = icmp eq i32 128, %12
br i1 %13, label %14, label %23
14: ; preds = %4
%15 = bitcast [20 x i8]* %10 to i8*
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%19 = call i64 @cust_hash(i8* %16, i32 %17, i8* %18, i32 20)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 -1, i32* %5
br label %36
22: ; preds = %14
store i32 -1, i32* %5
br label %36
23: ; preds = %4
%24 = load i32, i32* %9
%25 = icmp eq i32 256, %24
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = bitcast [32 x i8]* %11 to i8*
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%31 = call i64 @cust_hash(i8* %28, i32 %29, i8* %30, i32 32)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 -1, i32* %5
br label %36
34: ; preds = %26
store i32 -1, i32* %5
br label %36
35: ; preds = %23
store i32 -1, i32* %5
br label %36
36: ; preds = %35, %34, %33, %22, %21
%37 = load i32, i32* %5
ret i32 %37
}

LLVM IR (-O2):
define i32 @cust_verify(i8* %0, i32 %1, i8* nocapture readnone %2, i32 %3) {
%5 = alloca [20 x i8]
%6 = alloca [32 x i8]
switch i32 %3, label %13 [
i32 128, label %7
i32 256, label %10
]
7: ; preds = %4
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%9 = call i64 @cust_hash(i8* %0, i32 %1, i8* %8, i32 20)
br label %13
10: ; preds = %4
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = call i64 @cust_hash(i8* %0, i32 %1, i8* %11, i32 32)
br label %13
13: ; preds = %4, %10, %7
ret i32 -1
}