#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 */
scalar_t__ memcmp(char const *, char *, int);
int signkey_type_from_name(const char *name, int namelen) {
  if (namelen == 7 && memcmp(name, "ssh-rsa", 7) == 0) {
    return 1;
  }
  if (namelen == 7 && memcmp(name, "ssh-dss", 7) == 0) {
    return 2;
  }
  return 3;
}


x86 assembly (clang, -O0):
<signkey_type_from_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jne    1154 <signkey_type_from_name+0x44>
mov    -0x10(%rbp),%rdi
lea    0xecc(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    1154 <signkey_type_from_name+0x44>
movl   $0x1,-0x4(%rbp)
jmp    1190 <signkey_type_from_name+0x80>
cmpl   $0x7,-0x14(%rbp)
jne    1189 <signkey_type_from_name+0x79>
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    1189 <signkey_type_from_name+0x79>
movl   $0x2,-0x4(%rbp)
jmp    1190 <signkey_type_from_name+0x80>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signkey_type_from_name>:
push   %rbx
cmp    $0x7,%esi
jne    1148 <signkey_type_from_name+0x38>
mov    %rdi,%rbx
lea    0xee0(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     114f <signkey_type_from_name+0x3f>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1156 <signkey_type_from_name+0x46>
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ssh-rsa\00"
@.str.1 = [8 x i8] c"ssh-dss\00"
define i32 @signkey_type_from_name(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 7
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i64 @memcmp(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %3
br label %22
13: ; preds = %8, %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 7
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = call i64 @memcmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 2, i32* %3
br label %22
21: ; preds = %16, %13
store i32 3, i32* %3
br label %22
22: ; preds = %21, %20, %12
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [8 x i8] c"ssh-rsa\00"
@.str.1 = [8 x i8] c"ssh-dss\00"
define i32 @signkey_type_from_name(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 7
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %2, %7
br label %11
11: ; preds = %7, %4, %10
%12 = phi i32 [ 3, %10 ], [ 1, %4 ], [ 2, %7 ]
ret i32 %12
}