#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 */
struct fmt_main {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strlwr(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *split(char *ciphertext, int index, struct fmt_main *self) {
  static char out[(sizeof("$SHA256$") - 1) + 64 + 1];
  if (!strncmp(ciphertext, "$SHA256$", (sizeof("$SHA256$") - 1)))
    return ciphertext;
  memcpy(out, "$SHA256$", (sizeof("$SHA256$") - 1));
  memcpy(out + (sizeof("$SHA256$") - 1), ciphertext, 64 + 1);
  strlwr(out + (sizeof("$SHA256$") - 1));
  return out;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    116e <split+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <split+0x86>
lea    0x2edb(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rsi
lea    0x2ec7(%rip),%rdi
mov    $0x41,%edx
call   1050 <memcpy@plt>
lea    0x2eae(%rip),%rdi
add    $0x8,%rdi
call   1030 <strlwr@plt>
lea    0x2e9e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     118a <split+0x5a>
lea    0x2efc(%rip),%r14
lea    0xea5(%rip),%rsi
mov    %r14,%rdi
mov    $0x8,%edx
call   1050 <memcpy@plt>
lea    0x2ee9(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x41,%edx
call   1050 <memcpy@plt>
mov    %r15,%rdi
call   1030 <strlwr@plt>
mov    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.fmt_main = type { i32 }
@split.out = internal global [73 x i8] zeroinitializer
@.str = [9 x i8] c"$SHA256$\00"
define i8* @split(i8* %0, i32 %1, %struct.fmt_main* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.fmt_main*
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.fmt_main* %2, %struct.fmt_main** %7
%8 = load i8*, i8** %5
%9 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = load i8*, i8** %5
store i8* %12, i8** %4
br label %18
13: ; preds = %3
%14 = call i32 @memcpy(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%15 = load i8*, i8** %5
%16 = call i32 @memcpy(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 8), i8* %15, i32 65)
%17 = call i32 @strlwr(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 8))
store i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 0), i8** %4
br label %18
18: ; preds = %13, %11
%19 = load i8*, i8** %4
ret i8* %19
}

LLVM IR (-O2):
%struct.fmt_main = type { i32 }
@split.out = internal global [73 x i8] zeroinitializer
@.str = [9 x i8] c"$SHA256$\00"
define i8* @split(i8* %0, i32 %1, %struct.fmt_main* nocapture readnone %2) {
%4 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @memcpy(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%8 = tail call i32 @memcpy(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 8), i8* %0, i32 65)
%9 = tail call i32 @strlwr(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 8))
br label %10
10: ; preds = %3, %6
%11 = phi i8* [ getelementptr inbounds ([73 x i8], [73 x i8]* @split.out, i64 0, i64 0), %6 ], [ %0, %3 ]
ret i8* %11
}