#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 */
char *lock_strip_alpha(char *, char *);
int /*<<< orphan*/ md5_verify(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sha_verify(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
void checker(char *key, char *lock) {
  int r;
  char *rawkey, *rawlock;
  char keytype[512], locktype[512];
  printf("L %s K %s ", lock, key);
  rawkey = lock_strip_alpha(key, keytype);
  rawlock = lock_strip_alpha(lock, locktype);
  if (!strcmp(keytype, locktype)) {
    if (!strcmp(keytype, "md5")) {
      if (!md5_verify(rawkey, rawlock))
        printf("md5 OK\n");
      else
        printf("md5 no\n");
    } else if (!strcmp(keytype, "sha1")) {
      if (!sha_verify(rawkey, rawlock))
        printf("sha1 OK\n");
      else
        printf("sha1 no\n");
    } else
      printf("unknown\n");
  } else {
    printf("Mismatch %s %s\n", keytype, locktype);
  }
}


x86 assembly (clang, -O0):
<checker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1030 <lock_strip_alpha@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1030 <lock_strip_alpha@plt>
mov    %rax,-0x28(%rbp)
lea    -0x230(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <checker+0x135>
lea    -0x230(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1215 <checker+0xc5>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <md5_verify@plt>
cmp    $0x0,%eax
jne    1202 <checker+0xb2>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1210 <checker+0xc0>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <checker+0x130>
lea    -0x230(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    126d <checker+0x11d>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <sha_verify@plt>
cmp    $0x0,%eax
jne    125a <checker+0x10a>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1268 <checker+0x118>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127b <checker+0x12b>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <checker+0x130>
jmp    12a1 <checker+0x151>
lea    -0x230(%rbp),%rsi
lea    -0x430(%rbp),%rdx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checker>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe85(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <lock_strip_alpha@plt>
mov    %rax,%r14
lea    0x200(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <lock_strip_alpha@plt>
mov    %rax,%r15
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11e3 <checker+0x83>
lea    0xe4e(%rip),%rdi
mov    %rsp,%rsi
lea    0x200(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
cmpl   $0x35646d,(%rsp)
jne    1209 <checker+0xa9>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <md5_verify@plt>
test   %eax,%eax
je     1228 <checker+0xc8>
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <checker+0x74>
mov    $0x31616873,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     1236 <checker+0xd6>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <checker+0x74>
lea    0xdf1(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <checker+0x74>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <sha_verify@plt>
test   %eax,%eax
je     1253 <checker+0xf3>
lea    0xdea(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <checker+0x74>
lea    0xdd4(%rip),%rdi
call   1040 <puts@plt>
jmp    11d4 <checker+0x74>

LLVM IR (-O0):
@.str = [11 x i8] c"L %s K %s \00"
@.str.1 = [4 x i8] c"md5\00"
@.str.2 = [8 x i8] c"md5 OK\0A\00"
@.str.3 = [8 x i8] c"md5 no\0A\00"
@.str.4 = [5 x i8] c"sha1\00"
@.str.5 = [9 x i8] c"sha1 OK\0A\00"
@.str.6 = [9 x i8] c"sha1 no\0A\00"
@.str.7 = [9 x i8] c"unknown\0A\00"
@.str.8 = [16 x i8] c"Mismatch %s %s\0A\00"
define void @checker(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%15 = call i8* @lock_strip_alpha(i8* %13, i8* %14)
store i8* %15, i8** %6
%16 = load i8*, i8** %4
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%18 = call i8* @lock_strip_alpha(i8* %16, i8* %17)
store i8* %18, i8** %7
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%21 = call i32 @strcmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %55, label %23
23: ; preds = %2
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %37, label %27
27: ; preds = %23
%28 = load i8*, i8** %6
%29 = load i8*, i8** %7
%30 = call i32 @md5_verify(i8* %28, i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %36
34: ; preds = %27
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %54
37: ; preds = %23
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %51, label %41
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = call i32 @sha_verify(i8* %42, i8* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %50
48: ; preds = %41
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %48, %46
br label %53
51: ; preds = %37
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %53
53: ; preds = %51, %50
br label %54
54: ; preds = %53, %36
br label %59
55: ; preds = %2
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %56, i8* %57)
br label %59
59: ; preds = %55, %54
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"L %s K %s \00"
@.str.4 = [5 x i8] c"sha1\00"
@.str.8 = [16 x i8] c"Mismatch %s %s\0A\00"
@str = [7 x i8] c"md5 OK\00"
@str.9 = [7 x i8] c"md5 no\00"
@str.10 = [8 x i8] c"sha1 OK\00"
@str.11 = [8 x i8] c"sha1 no\00"
@str.12 = [8 x i8] c"unknown\00"
define void @checker(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%8 = call i8* @lock_strip_alpha(i8* %0, i8* %5)
%9 = call i8* @lock_strip_alpha(i8* %1, i8* %6)
%10 = call i32 @strcmp(i8* %5, i8* %6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %35
12: ; preds = %2
%13 = bitcast [512 x i8]* %3 to i32*
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 3499117
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = call i32 @md5_verify(i8* %8, i8* %9)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %37
21: ; preds = %16
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.9, i64 0, i64 0))
br label %37
23: ; preds = %12
%24 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 5)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = call i32 @sha_verify(i8* %8, i8* %9)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
br label %37
31: ; preds = %26
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
br label %37
33: ; preds = %23
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
br label %37
35: ; preds = %2
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %5, i8* %6)
br label %37
37: ; preds = %21, %19, %29, %31, %33, %35
ret void
}