#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ srec_get_hex4(int /*<<< orphan*/ *, unsigned char *);
int srec_get_hex8(FILE *fp, unsigned char *val) {
  unsigned char v1, v2;
  if (srec_get_hex4(fp, &v1) || srec_get_hex4(fp, &v2)) {
    return (1);
  }
  *val = ((v1 & 0x0f) << 4) | (v2 & 0x0f);
  return (0);
}


x86 assembly (clang, -O0):
<srec_get_hex8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1030 <srec_get_hex4@plt>
cmp    $0x0,%rax
jne    114e <srec_get_hex8+0x3e>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <srec_get_hex4@plt>
cmp    $0x0,%rax
je     115a <srec_get_hex8+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    117c <srec_get_hex8+0x6c>
movzbl -0x19(%rbp),%eax
and    $0xf,%eax
shl    $0x4,%eax
movzbl -0x1a(%rbp),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srec_get_hex8>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xf(%rsp),%rsi
call   1030 <srec_get_hex4@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1159 <srec_get_hex8+0x49>
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <srec_get_hex4@plt>
test   %rax,%rax
jne    1159 <srec_get_hex8+0x49>
mov    0xf(%rsp),%al
shl    $0x4,%al
mov    0xe(%rsp),%cl
and    $0xf,%cl
or     %al,%cl
mov    %cl,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @srec_get_hex8(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i32*, i32** %4
%9 = call i64 @srec_get_hex4(i32* %8, i8* %6)
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = call i64 @srec_get_hex4(i32* %12, i8* %7)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %2
store i32 1, i32* %3
br label %27
16: ; preds = %11
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = and i32 %18, 15
%20 = shl i32 %19, 4
%21 = load i8, i8* %7
%22 = zext i8 %21 to i32
%23 = and i32 %22, 15
%24 = or i32 %20, %23
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %5
store i8 %25, i8* %26
store i32 0, i32* %3
br label %27
27: ; preds = %16, %15
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @srec_get_hex8(i32* %0, i8* nocapture writeonly %1) {
%3 = alloca i8
%4 = alloca i8
%5 = call i64 @srec_get_hex4(i32* %0, i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = call i64 @srec_get_hex4(i32* %0, i8* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i8, i8* %3
%12 = shl i8 %11, 4
%13 = load i8, i8* %4
%14 = and i8 %13, 15
%15 = or i8 %14, %12
store i8 %15, i8* %1
br label %16
16: ; preds = %2, %7, %10
%17 = phi i32 [ 0, %10 ], [ 1, %7 ], [ 1, %2 ]
ret i32 %17
}