#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int parsehex(char *, unsigned char *, int);
int /*<<< orphan*/ stderr;
void parsesha256(char *s, unsigned char *sha256) {
  if (!*s) {
    memset(sha256, 0, 32);
    return;
  }
  if (parsehex(s, sha256, 32) != 32) {
    fprintf(stderr, "parsesha256: bad sha256\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<parsesha256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1172 <parsesha256+0x32>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
jmp    11ac <parsesha256+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1050 <parsehex@plt>
cmp    $0x20,%eax
je     11ac <parsesha256+0x6c>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsesha256>:
push   %rax
cmpb   $0x0,(%rdi)
je     1157 <parsesha256+0x17>
mov    $0x20,%edx
call   1050 <parsehex@plt>
cmp    $0x20,%eax
jne    1167 <parsesha256+0x27>
pop    %rax
ret
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x20,%edx
pop    %rax
jmp    1030 <memset@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"parsesha256: bad sha256\0A\00"
define void @parsesha256(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @memset(i8* %9, i32 0, i32 32)
br label %20
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @parsehex(i8* %12, i8* %13, i32 32)
%15 = icmp ne i32 %14, 32
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %8, %11
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"parsesha256: bad sha256\0A\00"
define void @parsesha256(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @memset(i8* %1, i32 0, i32 32)
br label %14
7: ; preds = %2
%8 = tail call i32 @parsehex(i8* %0, i8* %1, i32 32)
%9 = icmp eq i32 %8, 32
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %5, %7
ret void
}