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

/* Variables and functions */
int /*<<< orphan*/ EVP_MD_type(int /*<<< orphan*/ const *);
int RSA_NO_PADDING;
int /*<<< orphan*/ RSA_R_INVALID_PADDING_MODE;
int /*<<< orphan*/ RSA_R_INVALID_X931_DIGEST;
int RSA_X931_PADDING;
int RSA_X931_hash_id(int /*<<< orphan*/);
int /*<<< orphan*/ RSAerror(int /*<<< orphan*/);
int check_padding_md(const EVP_MD *md, int padding) {
  if (!md)
    return 1;
  if (padding == RSA_NO_PADDING) {
    RSAerror(RSA_R_INVALID_PADDING_MODE);
    return 0;
  }
  if (padding == RSA_X931_PADDING) {
    if (RSA_X931_hash_id(EVP_MD_type(md)) == -1) {
      RSAerror(RSA_R_INVALID_X931_DIGEST);
      return 0;
    }
    return 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_padding_md>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <check_padding_md+0x26>
movl   $0x1,-0x4(%rbp)
jmp    11da <check_padding_md+0xaa>
mov    -0x14(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    1182 <check_padding_md+0x52>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1050 <RSAerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    11da <check_padding_md+0xaa>
mov    -0x14(%rbp),%eax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%eax
jne    11d3 <check_padding_md+0xa3>
mov    -0x10(%rbp),%rdi
call   1040 <EVP_MD_type@plt>
mov    %eax,%edi
call   1030 <RSA_X931_hash_id@plt>
cmp    $0xffffffff,%eax
jne    11c7 <check_padding_md+0x97>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1050 <RSAerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    11da <check_padding_md+0xaa>
movl   $0x1,-0x4(%rbp)
jmp    11da <check_padding_md+0xaa>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_padding_md>:
push   %rbx
mov    $0x1,%ebx
test   %rdi,%rdi
je     1174 <check_padding_md+0x44>
mov    0x2e9e(%rip),%rax
cmp    %esi,(%rax)
jne    1158 <check_padding_md+0x28>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <RSAerror@plt>
xor    %ebx,%ebx
jmp    1174 <check_padding_md+0x44>
mov    0x2e89(%rip),%rax
cmp    %esi,(%rax)
jne    1174 <check_padding_md+0x44>
call   1040 <EVP_MD_type@plt>
mov    %eax,%edi
call   1030 <RSA_X931_hash_id@plt>
cmp    $0xffffffff,%eax
je     1178 <check_padding_md+0x48>
mov    %ebx,%eax
pop    %rbx
ret
mov    0x2e49(%rip),%rax
jmp    114d <check_padding_md+0x1d>

LLVM IR (-O0):
@RSA_NO_PADDING = global i32 0
@RSA_R_INVALID_PADDING_MODE = global i32 0
@RSA_X931_PADDING = global i32 0
@RSA_R_INVALID_X931_DIGEST = global i32 0
define i32 @check_padding_md(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 1, i32* %3
br label %30
9: ; preds = %2
%10 = load i32, i32* %5
%11 = load i32, i32* @RSA_NO_PADDING
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* @RSA_R_INVALID_PADDING_MODE
%15 = call i32 @RSAerror(i32 %14)
store i32 0, i32* %3
br label %30
16: ; preds = %9
%17 = load i32, i32* %5
%18 = load i32, i32* @RSA_X931_PADDING
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i32*, i32** %4
%22 = call i32 @EVP_MD_type(i32* %21)
%23 = call i32 @RSA_X931_hash_id(i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @RSA_R_INVALID_X931_DIGEST
%27 = call i32 @RSAerror(i32 %26)
store i32 0, i32* %3
br label %30
28: ; preds = %20
store i32 1, i32* %3
br label %30
29: ; preds = %16
store i32 1, i32* %3
br label %30
30: ; preds = %29, %28, %25, %13, %8
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@RSA_NO_PADDING = global i32 0
@RSA_R_INVALID_PADDING_MODE = global i32 0
@RSA_X931_PADDING = global i32 0
@RSA_R_INVALID_X931_DIGEST = global i32 0
define i32 @check_padding_md(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = load i32, i32* @RSA_NO_PADDING
%6 = icmp eq i32 %5, %1
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = load i32, i32* @RSA_X931_PADDING
%9 = icmp eq i32 %8, %1
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = tail call i32 @EVP_MD_type(i32* %0)
%12 = tail call i32 @RSA_X931_hash_id(i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %10, %4
%15 = phi i32* [ @RSA_R_INVALID_PADDING_MODE, %4 ], [ @RSA_R_INVALID_X931_DIGEST, %10 ]
%16 = load i32, i32* %15
%17 = tail call i32 @RSAerror(i32 %16)
br label %18
18: ; preds = %14, %7, %10, %2
%19 = phi i32 [ 1, %2 ], [ 1, %10 ], [ 1, %7 ], [ 0, %14 ]
ret i32 %19
}