#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*/ sscanf(char const *, char *, unsigned int *, unsigned int *,
                          unsigned int *);
int ihex_get_record_information(const char *input_string,
                                unsigned char *reclen_p,
                                unsigned short *load_offset_p,
                                unsigned char *rectyp_p) {
  int error = 0;
  unsigned int reclen;
  unsigned int load_offset;
  unsigned int rectyp;
  if (!sscanf(input_string, ":%02x%04x%02x", &reclen, &load_offset, &rectyp)) {
    error = 1;
  } else {
    *reclen_p = (unsigned char)reclen;
    *load_offset_p = (unsigned short)load_offset;
    *rectyp_p = (unsigned char)rectyp;
  }
  return error;
}


x86 assembly (clang, -O0):
<ihex_get_record_information>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec6(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1030 <sscanf@plt>
cmp    $0x0,%eax
jne    1160 <ihex_get_record_information+0x50>
movl   $0x1,-0x24(%rbp)
jmp    1183 <ihex_get_record_information+0x73>
mov    -0x28(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ihex_get_record_information>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0xed7(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1030 <sscanf@plt>
test   %eax,%eax
je     115b <ihex_get_record_information+0x4b>
mov    0xc(%rsp),%al
mov    %al,(%rbx)
movzwl 0x8(%rsp),%eax
mov    %ax,(%r15)
mov    0x4(%rsp),%al
mov    %al,(%r14)
xor    %eax,%eax
jmp    1160 <ihex_get_record_information+0x50>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c":%02x%04x%02x\00"
define i32 @ihex_get_record_information(i8* %0, i8* %1, i16* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i16*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i16* %2, i16** %7
store i8* %3, i8** %8
store i32 0, i32* %9
%13 = load i8*, i8** %5
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11, i32* %12)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %4
store i32 1, i32* %9
br label %27
17: ; preds = %4
%18 = load i32, i32* %10
%19 = trunc i32 %18 to i8
%20 = load i8*, i8** %6
store i8 %19, i8* %20
%21 = load i32, i32* %11
%22 = trunc i32 %21 to i16
%23 = load i16*, i16** %7
store i16 %22, i16* %23
%24 = load i32, i32* %12
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %8
store i8 %25, i8* %26
br label %27
27: ; preds = %17, %16
%28 = load i32, i32* %9
ret i32 %28
}

LLVM IR (-O2):
@.str = [14 x i8] c":%02x%04x%02x\00"
define i32 @ihex_get_record_information(i8* nocapture %0, i8* nocapture writeonly %1, i16* nocapture writeonly %2, i8* nocapture writeonly %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %4
%14 = load i32, i32* %5
%15 = trunc i32 %14 to i8
store i8 %15, i8* %1
%16 = load i32, i32* %6
%17 = trunc i32 %16 to i16
store i16 %17, i16* %2
%18 = load i32, i32* %7
%19 = trunc i32 %18 to i8
store i8 %19, i8* %3
br label %20
20: ; preds = %4, %13
%21 = phi i32 [ 0, %13 ], [ 1, %4 ]
ret i32 %21
}