#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 *CRYPT_FUNC(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  char *enc;
  int md5, sha;
  md5 = sha = 0;
  enc = CRYPT_FUNC("abc", "$6$");
  if (enc && !strcmp(enc, "$6$$"
                          "K7EQl9xnonG1x970hnNPqFQKlunsvbFHwzYLnbANzfHjxbphBMjL"
                          "ilW7SKO5EQOidBzcHseqkDOBCSPD8a3CR0"))
    sha = 1;
  enc = CRYPT_FUNC("password", "$1$XX");
  if (enc && !strcmp(enc, "$1$XX$HxaXRcnpWZWDaXxMy1Rfn0"))
    md5 = 1;
  if (sha)
    write(1, "SHA", 3);
  if (md5)
    write(1, "MD5", 3);
  write(1, "\n", 1);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeac(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1050 <CRYPT_FUNC@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118f <main+0x5f>
mov    -0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118f <main+0x5f>
movl   $0x1,-0x18(%rbp)
lea    0xecd(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1050 <CRYPT_FUNC@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d1 <main+0xa1>
mov    -0x10(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d1 <main+0xa1>
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11f1 <main+0xc1>
mov    $0x1,%edi
lea    0xea8(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
cmpl   $0x0,-0x14(%rbp)
je     1211 <main+0xe1>
mov    $0x1,%edi
lea    0xe8c(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe7a(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <CRYPT_FUNC@plt>
mov    $0x1,%bpl
mov    $0x1,%bl
test   %rax,%rax
je     1164 <main+0x34>
lea    0xeb1(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
setne  %bl
lea    0xef8(%rip),%rdi
lea    0xefa(%rip),%rsi
call   1050 <CRYPT_FUNC@plt>
test   %rax,%rax
je     1191 <main+0x61>
lea    0xeef(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
setne  %bpl
test   %bl,%bl
jne    11ab <main+0x7b>
lea    0xef3(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <write@plt>
test   %bpl,%bpl
jne    11c6 <main+0x96>
lea    0xedc(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <write@plt>
lea    0xeca(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [4 x i8] c"$6$\00"
@.str.2 = [91 x i8] c"$6$$K7EQl9xnonG1x970hnNPqFQKlunsvbFHwzYLnbANzfHjxbphBMjLilW7SKO5EQOidBzcHseqkDOBCSPD8a3CR0\00"
@.str.3 = [9 x i8] c"password\00"
@.str.4 = [6 x i8] c"$1$XX\00"
@.str.5 = [29 x i8] c"$1$XX$HxaXRcnpWZWDaXxMy1Rfn0\00"
@.str.6 = [4 x i8] c"SHA\00"
@.str.7 = [4 x i8] c"MD5\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %3
%5 = call i8* @CRYPT_FUNC(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 1, i32* %4
br label %13
13: ; preds = %12, %8, %0
%14 = call i8* @CRYPT_FUNC(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i8* %14, i8** %2
%15 = load i8*, i8** %2
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8*, i8** %2
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i32 1, i32* %3
br label %22
22: ; preds = %21, %17, %13
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %32
32: ; preds = %30, %27
%33 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [4 x i8] c"$6$\00"
@.str.2 = [91 x i8] c"$6$$K7EQl9xnonG1x970hnNPqFQKlunsvbFHwzYLnbANzfHjxbphBMjLilW7SKO5EQOidBzcHseqkDOBCSPD8a3CR0\00"
@.str.3 = [9 x i8] c"password\00"
@.str.4 = [6 x i8] c"$1$XX\00"
@.str.5 = [29 x i8] c"$1$XX$HxaXRcnpWZWDaXxMy1Rfn0\00"
@.str.6 = [4 x i8] c"SHA\00"
@.str.7 = [4 x i8] c"MD5\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i8* @CRYPT_FUNC(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(91) getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp ne i32 %4, 0
br label %6
6: ; preds = %3, %0
%7 = phi i1 [ true, %0 ], [ %5, %3 ]
%8 = tail call i8* @CRYPT_FUNC(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(29) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br label %13
13: ; preds = %10, %6
%14 = phi i1 [ true, %6 ], [ %12, %10 ]
br i1 %7, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
br label %17
17: ; preds = %15, %13
br i1 %14, label %20, label %18
18: ; preds = %17
%19 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %20
20: ; preds = %18, %17
%21 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
ret i32 0
}