#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*/ strlen(char *);
int /*<<< orphan*/ strncasecmp(char *, char *, int /*<<< orphan*/);
int keynote_get_key_algorithm(char *key, int *encoding, int *internalencoding) {
  if (!strncasecmp("binary-hex:", key, strlen("binary-hex:"))) {
    *internalencoding = 0;
    *encoding = 1;
    return 4;
  }
  if (!strncasecmp("binary-base64:", key, strlen("binary-base64:"))) {
    *internalencoding = 0;
    *encoding = 2;
    return 4;
  }
  *internalencoding = 0;
  *encoding = 0;
  return 0;
}


x86 assembly (clang, -O0):
<keynote_get_key_algorithm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xeab(%rip),%rdi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1183 <keynote_get_key_algorithm+0x63>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x4,-0x4(%rbp)
jmp    11ed <keynote_get_key_algorithm+0xcd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xe68(%rip),%rdi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11d2 <keynote_get_key_algorithm+0xb2>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x4,-0x4(%rbp)
jmp    11ed <keynote_get_key_algorithm+0xcd>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keynote_get_key_algorithm>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec8(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     1185 <keynote_get_key_algorithm+0x65>
lea    0xeb4(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
movl   $0x0,(%r15)
lea    (%rax,%rax,1),%ecx
shl    $0x2,%eax
jmp    1196 <keynote_get_key_algorithm+0x76>
movl   $0x0,(%r15)
mov    $0x4,%eax
mov    $0x1,%ecx
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"binary-hex:\00"
@.str.1 = [15 x i8] c"binary-base64:\00"
define i32 @keynote_get_key_algorithm(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strncasecmp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32*, i32** %7
store i32 0, i32* %13
%14 = load i32*, i32** %6
store i32 1, i32* %14
store i32 4, i32* %4
br label %26
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @strncasecmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32*, i32** %7
store i32 0, i32* %21
%22 = load i32*, i32** %6
store i32 2, i32* %22
store i32 4, i32* %4
br label %26
23: ; preds = %15
%24 = load i32*, i32** %7
store i32 0, i32* %24
%25 = load i32*, i32** %6
store i32 0, i32* %25
store i32 0, i32* %4
br label %26
26: ; preds = %23, %20, %12
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [12 x i8] c"binary-hex:\00"
@.str.1 = [15 x i8] c"binary-base64:\00"
define i32 @keynote_get_key_algorithm(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %3
store i32 0, i32* %2
br label %14
8: ; preds = %3
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %9)
%11 = icmp eq i32 %10, 0
store i32 0, i32* %2
%12 = select i1 %11, i32 2, i32 0
%13 = select i1 %11, i32 4, i32 0
br label %14
14: ; preds = %8, %7
%15 = phi i32 [ 1, %7 ], [ %12, %8 ]
%16 = phi i32 [ 4, %7 ], [ %13, %8 ]
store i32 %15, i32* %1
ret i32 %16
}