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

/* Variables and functions */
int /*<<< orphan*/ NID_md5;
int /*<<< orphan*/ NID_sha1;
int ssl3_handshake_mac(int /*<<< orphan*/ *, int /*<<< orphan*/, char const *,
                       int, unsigned char *);
int ssl3_final_finish_mac(SSL *s, const char *sender, int len,
                          unsigned char *p) {
  int ret, sha1len;
  ret = ssl3_handshake_mac(s, NID_md5, sender, len, p);
  if (ret == 0)
    return 0;
  p += ret;
  sha1len = ssl3_handshake_mac(s, NID_sha1, sender, len, p);
  if (sha1len == 0)
    return 0;
  ret += sha1len;
  return (ret);
}


x86 assembly (clang, -O0):
<ssl3_final_finish_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2eb6(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1030 <ssl3_handshake_mac@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    115d <ssl3_final_finish_mac+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <ssl3_final_finish_mac+0xa3>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1030 <ssl3_handshake_mac@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    11a4 <ssl3_final_finish_mac+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <ssl3_final_finish_mac+0xa3>
mov    -0x30(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl3_final_finish_mac>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0x2ebd(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14,%r8
call   1030 <ssl3_handshake_mac@plt>
test   %eax,%eax
je     1169 <ssl3_final_finish_mac+0x59>
mov    %eax,%ebx
cltq
add    %rax,%r14
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14,%r8
call   1030 <ssl3_handshake_mac@plt>
add    %eax,%ebx
test   %eax,%eax
cmove  %eax,%ebx
jmp    116b <ssl3_final_finish_mac+0x5b>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NID_md5 = global i32 0
@NID_sha1 = global i32 0
define i32 @ssl3_final_finish_mac(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%12 = load i32*, i32** %6
%13 = load i32, i32* @NID_md5
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %9
%17 = call i32 @ssl3_handshake_mac(i32* %12, i32 %13, i8* %14, i32 %15, i8* %16)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %4
store i32 0, i32* %5
br label %40
21: ; preds = %4
%22 = load i32, i32* %10
%23 = load i8*, i8** %9
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %9
%26 = load i32*, i32** %6
%27 = load i32, i32* @NID_sha1
%28 = load i8*, i8** %7
%29 = load i32, i32* %8
%30 = load i8*, i8** %9
%31 = call i32 @ssl3_handshake_mac(i32* %26, i32 %27, i8* %28, i32 %29, i8* %30)
store i32 %31, i32* %11
%32 = load i32, i32* %11
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %21
store i32 0, i32* %5
br label %40
35: ; preds = %21
%36 = load i32, i32* %11
%37 = load i32, i32* %10
%38 = add nsw i32 %37, %36
store i32 %38, i32* %10
%39 = load i32, i32* %10
store i32 %39, i32* %5
br label %40
40: ; preds = %35, %34, %20
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
@NID_md5 = global i32 0
@NID_sha1 = global i32 0
define i32 @ssl3_final_finish_mac(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = load i32, i32* @NID_md5
%6 = tail call i32 @ssl3_handshake_mac(i32* %0, i32 %5, i8* %1, i32 %2, i8* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds i8, i8* %3, i64 %9
%11 = load i32, i32* @NID_sha1
%12 = tail call i32 @ssl3_handshake_mac(i32* %0, i32 %11, i8* %1, i32 %2, i8* %10)
%13 = icmp eq i32 %12, 0
%14 = add nsw i32 %12, %6
%15 = select i1 %13, i32 0, i32 %14
br label %16
16: ; preds = %8, %4
%17 = phi i32 [ 0, %4 ], [ %15, %8 ]
ret i32 %17
}