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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int palindrome_permutation(const char *str) {
  static char freq[26];
  memset(freq, 0, sizeof(freq));
  size_t i;
  for (i = 0; str[i] != '\0'; i++) {
    size_t idx = (unsigned char)str[i] - 'a';
    freq[idx] = (freq[idx] + 1) % 2;
  }
  int odd_occurrences = 0;
  for (i = 0; i < sizeof(freq) && odd_occurrences < 2; i++) {
    if (freq[i] == 1) {
      odd_occurrences++;
    }
  }
  return odd_occurrences < 2;
}


x86 assembly (clang, -O0):
<palindrome_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1030 <memset@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119a <palindrome_permutation+0x8a>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
lea    0x2ed4(%rip),%rax
movsbl (%rax,%rcx,1),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rcx
lea    0x2eba(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <palindrome_permutation+0x27>
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x1a,-0x10(%rbp)
mov    %al,-0x1d(%rbp)
jae    11c3 <palindrome_permutation+0xb3>
cmpl   $0x2,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11d3 <palindrome_permutation+0xc3>
jmp    120a <palindrome_permutation+0xfa>
mov    -0x10(%rbp),%rcx
lea    0x2e62(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    11f4 <palindrome_permutation+0xe4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f9 <palindrome_permutation+0xe9>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a9 <palindrome_permutation+0x99>
cmpl   $0x2,-0x1c(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindrome_permutation>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0x2f21(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1030 <memset@plt>
mov    (%r15),%al
test   %al,%al
je     116f <palindrome_permutation+0x5f>
add    $0x1,%r15
nopl   0x0(%rax,%rax,1)
movzbl %al,%eax
movsbl -0x61(%rax,%r14,1),%ecx
add    $0x1,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
add    %ecx,%edx
and    $0xfe,%edx
sub    %edx,%ecx
mov    %cl,-0x61(%rax,%r14,1)
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    1140 <palindrome_permutation+0x30>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ecx
xor    %ebx,%ebx
cmpb   $0x1,(%rax,%r14,1)
sete   %bl
add    %ecx,%ebx
cmp    $0x18,%rax
ja     119d <palindrome_permutation+0x8d>
add    $0x1,%rax
cmp    $0x2,%ebx
jb     1180 <palindrome_permutation+0x70>
xor    %eax,%eax
cmp    $0x2,%ebx
setb   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@palindrome_permutation.freq = internal global [26 x i8] zeroinitializer
define i32 @palindrome_permutation(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @memset(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 0), i32 0, i32 26)
store i64 0, i64* %3
br label %7
7: ; preds = %31, %1
%8 = load i8*, i8** %2
%9 = load i64, i64* %3
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = load i64, i64* %3
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = sub nsw i32 %19, 97
%21 = sext i32 %20 to i64
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = getelementptr inbounds [26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = add nsw i32 %25, 1
%27 = srem i32 %26, 2
%28 = trunc i32 %27 to i8
%29 = load i64, i64* %4
%30 = getelementptr inbounds [26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 %29
store i8 %28, i8* %30
br label %31
31: ; preds = %14
%32 = load i64, i64* %3
%33 = add i64 %32, 1
store i64 %33, i64* %3
br label %7
34: ; preds = %7
store i32 0, i32* %5
store i64 0, i64* %3
br label %35
35: ; preds = %53, %34
%36 = load i64, i64* %3
%37 = icmp ult i64 %36, 26
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %5
%40 = icmp slt i32 %39, 2
br label %41
41: ; preds = %38, %35
%42 = phi i1 [ false, %35 ], [ %40, %38 ]
br i1 %42, label %43, label %56
43: ; preds = %41
%44 = load i64, i64* %3
%45 = getelementptr inbounds [26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %52
49: ; preds = %43
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %52
52: ; preds = %49, %43
br label %53
53: ; preds = %52
%54 = load i64, i64* %3
%55 = add i64 %54, 1
store i64 %55, i64* %3
br label %35
56: ; preds = %41
%57 = load i32, i32* %5
%58 = icmp slt i32 %57, 2
%59 = zext i1 %58 to i32
ret i32 %59
}

LLVM IR (-O2):
@palindrome_permutation.freq = internal global [26 x i8] zeroinitializer
define i32 @palindrome_permutation(i8* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 0), i32 0, i32 26)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %18, %5 ], [ %3, %1 ]
%7 = phi i64 [ %16, %5 ], [ 0, %1 ]
%8 = zext i8 %6 to i64
%9 = add nsw i64 %8, -97
%10 = getelementptr inbounds [26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i16
%13 = add nsw i16 %12, 1
%14 = srem i16 %13, 2
%15 = trunc i16 %14 to i8
store i8 %15, i8* %10
%16 = add i64 %7, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %5
20: ; preds = %5, %1
br label %21
21: ; preds = %20, %21
%22 = phi i32 [ %28, %21 ], [ 0, %20 ]
%23 = phi i64 [ %29, %21 ], [ 0, %20 ]
%24 = getelementptr inbounds [26 x i8], [26 x i8]* @palindrome_permutation.freq, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 1
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %22, %27
%29 = add nuw nsw i64 %23, 1
%30 = icmp ult i64 %23, 25
%31 = icmp ult i32 %28, 2
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %21, label %33
33: ; preds = %21
%34 = zext i1 %31 to i32
ret i32 %34
}