#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 */
int /*<<< orphan*/ muggle_parity_check_odd(unsigned char);
int openssl_des_check_key_parity(unsigned char *key) {
  for (int i = 0; i < 8; ++i) {
    if (!muggle_parity_check_odd(key[i])) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<openssl_des_check_key_parity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1166 <openssl_des_check_key_parity+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <muggle_parity_check_odd@plt>
cmp    $0x0,%eax
jne    1153 <openssl_des_check_key_parity+0x43>
movl   $0x0,-0x4(%rbp)
jmp    116d <openssl_des_check_key_parity+0x5d>
jmp    1158 <openssl_des_check_key_parity+0x48>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <openssl_des_check_key_parity+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openssl_des_check_key_parity>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <muggle_parity_check_odd@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x1(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x2(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x3(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x4(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x5(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x6(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
test   %eax,%eax
je     1183 <openssl_des_check_key_parity+0x73>
movzbl 0x7(%rbx),%edi
call   1030 <muggle_parity_check_odd@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @openssl_des_check_key_parity(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @muggle_parity_check_odd(i8 zeroext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %8
store i32 0, i32* %2
br label %22
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
store i32 1, i32* %2
br label %22
22: ; preds = %21, %16
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @openssl_des_check_key_parity(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @muggle_parity_check_odd(i8 zeroext %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %41, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @muggle_parity_check_odd(i8 zeroext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %41, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = tail call i32 @muggle_parity_check_odd(i8 zeroext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %41, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %0, i64 3
%17 = load i8, i8* %16
%18 = tail call i32 @muggle_parity_check_odd(i8 zeroext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %41, label %20
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %0, i64 4
%22 = load i8, i8* %21
%23 = tail call i32 @muggle_parity_check_odd(i8 zeroext %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %41, label %25
25: ; preds = %20
%26 = getelementptr inbounds i8, i8* %0, i64 5
%27 = load i8, i8* %26
%28 = tail call i32 @muggle_parity_check_odd(i8 zeroext %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %41, label %30
30: ; preds = %25
%31 = getelementptr inbounds i8, i8* %0, i64 6
%32 = load i8, i8* %31
%33 = tail call i32 @muggle_parity_check_odd(i8 zeroext %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %30
%36 = getelementptr inbounds i8, i8* %0, i64 7
%37 = load i8, i8* %36
%38 = tail call i32 @muggle_parity_check_odd(i8 zeroext %37)
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i32
br label %41
41: ; preds = %35, %30, %25, %20, %15, %10, %5, %1
%42 = phi i32 [ 0, %1 ], [ 0, %5 ], [ 0, %10 ], [ 0, %15 ], [ 0, %20 ], [ 0, %25 ], [ 0, %30 ], [ %40, %35 ]
ret i32 %42
}