#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__ sec_hash(unsigned char *, unsigned int, unsigned char *, int);
int sec_verify(unsigned char *d_buf, unsigned int d_len, unsigned char *s_buf,
               unsigned int s_len) {
  if (s_len == (128)) {
    unsigned char sha1_buf[(20)] = {0};
    if (sec_hash(d_buf, d_len, sha1_buf, (20)) != 0) {
      return -1;
    }
    return -1;
  } else if (s_len == (256)) {
    unsigned char sha256_buf[(32)] = {0};
    if (sec_hash(d_buf, d_len, sha256_buf, (32)) != 0) {
      return -1;
    }
    return -1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<sec_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)
cmpl   $0x80,-0x24(%rbp)
jne    118a <sec_verify+0x6a>
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 <sec_hash@plt>
cmp    $0x0,%rax
je     117e <sec_verify+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <sec_verify+0xca>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <sec_verify+0xca>
cmpl   $0x100,-0x24(%rbp)
jne    11de <sec_verify+0xbe>
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 <sec_hash@plt>
cmp    $0x0,%rax
je     11d2 <sec_verify+0xb2>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <sec_verify+0xca>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <sec_verify+0xca>
jmp    11e3 <sec_verify+0xc3>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @sec_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 %12, 128
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 @sec_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 %37
22: ; preds = %14
store i32 -1, i32* %5
br label %37
23: ; preds = %4
%24 = load i32, i32* %9
%25 = icmp eq i32 %24, 256
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 @sec_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 %37
34: ; preds = %26
store i32 -1, i32* %5
br label %37
35: ; preds = %23
br label %36
36: ; preds = %35
store i32 -1, i32* %5
br label %37
37: ; preds = %36, %34, %33, %22, %21
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @sec_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 @sec_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 @sec_hash(i8* %0, i32 %1, i8* %11, i32 32)
br label %13
13: ; preds = %4, %10, %7
ret i32 -1
}