#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ hex_scan(char *, unsigned char *, size_t);
size_t read_hex_input(unsigned char *, size_t);
int /*<<< orphan*/ stderr;
void load_bytes(char *string_in, unsigned char *buf, size_t n, char *message) {
  if (!message)
    message = "Please enter %lu bytes\n";
  if (!string_in || *string_in == '-') {
    fprintf(stderr, message, n);
    if (read_hex_input(buf, n) != n) {
      fprintf(stderr, "Input must be %lu bytes long\n", n);
      exit(EXIT_FAILURE);
    }
  } else if (!hex_scan(string_in, buf, n)) {
    fprintf(stderr, "Input must be %lu bytes long\n", n);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<load_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116e <load_bytes+0x2e>
lea    0xe96(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1189 <load_bytes+0x49>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e2 <load_bytes+0xa2>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <read_hex_input@plt>
cmp    -0x18(%rbp),%rax
je     11dd <load_bytes+0x9d>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe4e(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1228 <load_bytes+0xe8>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <hex_scan@plt>
cmp    $0x0,%eax
jne    1223 <load_bytes+0xe3>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe08(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1228 <load_bytes+0xe8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_bytes>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
test   %rcx,%rcx
lea    0xeab(%rip),%rsi
cmovne %rcx,%rsi
test   %rdi,%rdi
je     1163 <load_bytes+0x23>
cmpb   $0x2d,(%rdi)
jne    118a <load_bytes+0x4a>
mov    0x2e76(%rip),%r15
mov    (%r15),%edi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <read_hex_input@plt>
cmp    %rbx,%rax
je     1199 <load_bytes+0x59>
mov    (%r15),%edi
jmp    11a8 <load_bytes+0x68>
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <hex_scan@plt>
test   %eax,%eax
je     119f <load_bytes+0x5f>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Please enter %lu bytes\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Input must be %lu bytes long\0A\00"
@EXIT_FAILURE = global i32 0
define void @load_bytes(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %4
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %8
br label %12
12: ; preds = %11, %4
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 45
br i1 %19, label %20, label %37
20: ; preds = %15, %12
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %8
%23 = load i64, i64* %7
%24 = call i32 @fprintf(i32 %21, i8* %22, i64 %23)
%25 = load i8*, i8** %6
%26 = load i64, i64* %7
%27 = call i64 @read_hex_input(i8* %25, i64 %26)
%28 = load i64, i64* %7
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %20
%31 = load i32, i32* @stderr
%32 = load i64, i64* %7
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %20
br label %50
37: ; preds = %15
%38 = load i8*, i8** %5
%39 = load i8*, i8** %6
%40 = load i64, i64* %7
%41 = call i32 @hex_scan(i8* %38, i8* %39, i64 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = load i64, i64* %7
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %37
br label %50
50: ; preds = %49, %36
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please enter %lu bytes\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Input must be %lu bytes long\0A\00"
@EXIT_FAILURE = global i32 0
define void @load_bytes(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = icmp eq i8* %3, null
%6 = select i1 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %3
%7 = icmp eq i8* %0, null
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %21
11: ; preds = %8, %4
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* %6, i64 %2)
%14 = tail call i64 @read_hex_input(i8* %1, i64 %2)
%15 = icmp eq i64 %14, %2
br i1 %15, label %29, label %16
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %2)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %8
%22 = tail call i32 @hex_scan(i8* %0, i8* %1, i64 %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i64 %2)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %21, %11
ret void
}