#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 *, char const *, int);
char *sha256crypt(char const *, char const *, char *);
char *__crypt_sha256(const char *key, const char *setting, char *output) {
  static const char testkey[] = "Xy01@#\x01\x02\x80\x7f\xff\r\n\x81\t !";
  static const char testsetting[] = "$5$rounds=1234$abc0123456789$";
  static const char testhash[] = "$5$rounds=1234$abc0123456789$"
                                 "3VfDjPt05VHFn47C/ojFZ6KRPYrOjj1lLbH.dkF3bZ6";
  char testbuf[128];
  char *p, *q;
  p = sha256crypt(key, setting, output);
  q = sha256crypt(testkey, testsetting, testbuf);
  if (!p || q != testbuf || memcmp(testbuf, testhash, sizeof testhash))
    return "*";
  return p;
}


x86 assembly (clang, -O0):
<__crypt_sha256>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <sha256crypt@plt>
mov    %rax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdx
lea    0xea3(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1030 <sha256crypt@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     11b7 <__crypt_sha256+0x97>
mov    -0xb0(%rbp),%rax
lea    -0xa0(%rbp),%rcx
cmp    %rcx,%rax
jne    11b7 <__crypt_sha256+0x97>
lea    -0xa0(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x49,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11c7 <__crypt_sha256+0xa7>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d2 <__crypt_sha256+0xb2>
mov    -0xa8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__crypt_sha256>:
push   %r14
push   %rbx
sub    $0x88,%rsp
call   1030 <sha256crypt@plt>
mov    %rax,%rbx
lea    0xec7(%rip),%rdi
lea    0xee0(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
call   1030 <sha256crypt@plt>
mov    %rax,%rcx
lea    0xf34(%rip),%rax
test   %rbx,%rbx
je     1181 <__crypt_sha256+0x61>
cmp    %r14,%rcx
jne    1181 <__crypt_sha256+0x61>
lea    0xeda(%rip),%rsi
mov    %rsp,%rdi
mov    $0x49,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
lea    0xf0c(%rip),%rax
cmove  %rbx,%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__crypt_sha256.testkey = internal constant [18 x i8] c"Xy01@#\01\02\80\7F\FF\0D\0A\81\09 !\00"
@__crypt_sha256.testsetting = internal constant [30 x i8] c"$5$rounds=1234$abc0123456789$\00"
@__crypt_sha256.testhash = internal constant [73 x i8] c"$5$rounds=1234$abc0123456789$3VfDjPt05VHFn47C/ojFZ6KRPYrOjj1lLbH.dkF3bZ6\00"
@.str = [2 x i8] c"*\00"
define i8* @__crypt_sha256(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [128 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = call i8* @sha256crypt(i8* %11, i8* %12, i8* %13)
store i8* %14, i8** %9
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%16 = call i8* @sha256crypt(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__crypt_sha256.testkey, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__crypt_sha256.testsetting, i64 0, i64 0), i8* %15)
store i8* %16, i8** %10
%17 = load i8*, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %3
%20 = load i8*, i8** %10
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%22 = icmp ne i8* %20, %21
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%25 = call i64 @memcmp(i8* %24, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @__crypt_sha256.testhash, i64 0, i64 0), i32 73)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19, %3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4
br label %30
28: ; preds = %23
%29 = load i8*, i8** %9
store i8* %29, i8** %4
br label %30
30: ; preds = %28, %27
%31 = load i8*, i8** %4
ret i8* %31
}

LLVM IR (-O2):
@__crypt_sha256.testkey = internal constant [18 x i8] c"Xy01@#\01\02\80\7F\FF\0D\0A\81\09 !\00"
@__crypt_sha256.testsetting = internal constant [30 x i8] c"$5$rounds=1234$abc0123456789$\00"
@__crypt_sha256.testhash = internal constant [73 x i8] c"$5$rounds=1234$abc0123456789$3VfDjPt05VHFn47C/ojFZ6KRPYrOjj1lLbH.dkF3bZ6\00"
@.str = [2 x i8] c"*\00"
define i8* @__crypt_sha256(i8* %0, i8* %1, i8* %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @sha256crypt(i8* %0, i8* %1, i8* %2)
%7 = call i8* @sha256crypt(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__crypt_sha256.testkey, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__crypt_sha256.testsetting, i64 0, i64 0), i8* %5)
%8 = icmp eq i8* %6, null
%9 = icmp ne i8* %7, %5
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @__crypt_sha256.testhash, i64 0, i64 0), i32 73)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
br label %15
15: ; preds = %11, %3
%16 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %3 ], [ %14, %11 ]
ret i8* %16
}