#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 check_certificate(char const *, char const *);
int check_krb5(char const *, char const *);
int checkpass_crypt(char const *, char const *);
int checkpass_md5(char const *, char const *);
int checkpass_pam(char const *, char const *);
int checkpass_sha(char const *, char const *);
int strlen(char *);
scalar_t__ strncmp(char const *, char *, int);
int check_auth(const char *user, const char *data, const char *challenge) {
  if (!user || !challenge)
    return 0;
  if (strncmp(challenge, "$1$", strlen("$1$")) == 0)
    return checkpass_md5(data, challenge + strlen("$1$"));
  if (strncmp(challenge, "{SHA}", strlen("{SHA}")) == 0)
    return checkpass_sha(data, challenge + strlen("{SHA}"));
  if (strncmp(challenge, "{pam}", strlen("{pam}")) == 0)
    return checkpass_pam(user, data);
  if (strncmp(challenge, "{cert}", strlen("{cert}")) == 0)
    return check_certificate(user, challenge + strlen("{cert}"));
  if (strncmp(challenge, "{kerberos}", strlen("{kerberos}")) == 0)
    return check_krb5(user, challenge + strlen("{kerberos}"));
  return checkpass_crypt(data, challenge);
  return 0;
}


x86 assembly (clang, -O0):
<check_auth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ad <check_auth+0x2d>
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <check_auth+0x39>
movl   $0x0,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe38(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe26(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    121f <check_auth+0x9f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe00(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rsi
call   1060 <checkpass_md5@plt>
mov    %eax,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xdd6(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
lea    0xdc4(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1285 <check_auth+0x105>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xd9e(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdi
cltq
add    %rax,%rsi
call   10a0 <checkpass_sha@plt>
mov    %eax,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xd76(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
lea    0xd64(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ca <check_auth+0x14a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <checkpass_pam@plt>
mov    %eax,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xd37(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xd25(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1330 <check_auth+0x1b0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xcff(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    -0x68(%rbp),%rdi
cltq
add    %rax,%rsi
call   1080 <check_certificate@plt>
mov    %eax,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    0xcd8(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%edx
lea    0xcc6(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    139c <check_auth+0x21c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    0xc9d(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rsi
mov    -0x80(%rbp),%rdi
cltq
add    %rax,%rsi
call   1070 <check_krb5@plt>
mov    %eax,-0x4(%rbp)
jmp    13ac <check_auth+0x22c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <checkpass_crypt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_auth>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1272 <check_auth+0xf2>
mov    %rdx,%rbx
test   %rdx,%rdx
je     1272 <check_auth+0xf2>
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe56(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1280 <check_auth+0x100>
lea    0xe35(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12a7 <check_auth+0x127>
lea    0xe16(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12ce <check_auth+0x14e>
lea    0xdf7(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12e4 <check_auth+0x164>
lea    0xdd9(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     130b <check_auth+0x18b>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <checkpass_crypt@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd79(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <checkpass_md5@plt>
lea    0xd56(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    10a0 <checkpass_sha@plt>
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1090 <checkpass_pam@plt>
lea    0xd25(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <check_certificate@plt>
lea    0xd05(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <check_krb5@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"$1$\00"
@.str.1 = [6 x i8] c"{SHA}\00"
@.str.2 = [6 x i8] c"{pam}\00"
@.str.3 = [7 x i8] c"{cert}\00"
@.str.4 = [11 x i8] c"{kerberos}\00"
define i32 @check_auth(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %3
store i32 0, i32* %4
br label %75
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = call i32 @checkpass_md5(i8* %20, i8* %24)
store i32 %25, i32* %4
br label %75
26: ; preds = %14
%27 = load i8*, i8** %7
%28 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%29 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load i8*, i8** %6
%33 = load i8*, i8** %7
%34 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = call i32 @checkpass_sha(i8* %32, i8* %36)
store i32 %37, i32* %4
br label %75
38: ; preds = %26
%39 = load i8*, i8** %7
%40 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%41 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = load i8*, i8** %5
%45 = load i8*, i8** %6
%46 = call i32 @checkpass_pam(i8* %44, i8* %45)
store i32 %46, i32* %4
br label %75
47: ; preds = %38
%48 = load i8*, i8** %7
%49 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%50 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %47
%53 = load i8*, i8** %5
%54 = load i8*, i8** %7
%55 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = call i32 @check_certificate(i8* %53, i8* %57)
store i32 %58, i32* %4
br label %75
59: ; preds = %47
%60 = load i8*, i8** %7
%61 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%62 = call i64 @strncmp(i8* %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %59
%65 = load i8*, i8** %5
%66 = load i8*, i8** %7
%67 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = call i32 @check_krb5(i8* %65, i8* %69)
store i32 %70, i32* %4
br label %75
71: ; preds = %59
%72 = load i8*, i8** %6
%73 = load i8*, i8** %7
%74 = call i32 @checkpass_crypt(i8* %72, i8* %73)
store i32 %74, i32* %4
br label %75
75: ; preds = %71, %64, %52, %43, %31, %19, %13
%76 = load i32, i32* %4
ret i32 %76
}

LLVM IR (-O2):
@.str = [4 x i8] c"$1$\00"
@.str.1 = [6 x i8] c"{SHA}\00"
@.str.2 = [6 x i8] c"{pam}\00"
@.str.3 = [7 x i8] c"{cert}\00"
@.str.4 = [11 x i8] c"{kerberos}\00"
define i32 @check_auth(i8* %0, i8* %1, i8* %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %2, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %51
7: ; preds = %3
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %2, i64 %13
%15 = tail call i32 @checkpass_md5(i8* %1, i8* %14)
br label %51
16: ; preds = %7
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %2, i64 %22
%24 = tail call i32 @checkpass_sha(i8* %1, i8* %23)
br label %51
25: ; preds = %16
%26 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 @checkpass_pam(i8* %0, i8* %1)
br label %51
31: ; preds = %25
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %2, i64 %37
%39 = tail call i32 @check_certificate(i8* %0, i8* %38)
br label %51
40: ; preds = %31
%41 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%42 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %2, i64 %46
%48 = tail call i32 @check_krb5(i8* %0, i8* %47)
br label %51
49: ; preds = %40
%50 = tail call i32 @checkpass_crypt(i8* %1, i8* %2)
br label %51
51: ; preds = %3, %49, %44, %35, %29, %20, %11
%52 = phi i32 [ %15, %11 ], [ %24, %20 ], [ %30, %29 ], [ %39, %35 ], [ %48, %44 ], [ %50, %49 ], [ 0, %3 ]
ret i32 %52
}