#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 */
unsigned char CheckSum(char const *, int *);
scalar_t__ str2lx(char const *, char **, int);
unsigned int IntegrityAndCorrectCheck(const char *pStr) {
  int i;
  char *pos;
  unsigned int errCode = 0;
  unsigned char ucChkSum = CheckSum(pStr, &i);
  if (*(pStr + i) != '*')
    errCode |= (0x08);
  else {
    if (ucChkSum != (unsigned char)str2lx(pStr + i + 1, &pos, 16)) {
      errCode |= (0x01);
    }
  }
  return errCode;
}


x86 assembly (clang, -O0):
<IntegrityAndCorrectCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <CheckSum@plt>
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
je     1166 <IntegrityAndCorrectCheck+0x46>
mov    -0x1c(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a9 <IntegrityAndCorrectCheck+0x89>
movzbl -0x1d(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1030 <str2lx@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
movzbl %cl,%ecx
cmp    %ecx,%eax
je     11a4 <IntegrityAndCorrectCheck+0x84>
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a9 <IntegrityAndCorrectCheck+0x89>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IntegrityAndCorrectCheck>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
call   1040 <CheckSum@plt>
mov    %eax,%ebp
movslq 0xc(%rsp),%rcx
mov    $0x8,%eax
cmpb   $0x2a,(%rbx,%rcx,1)
jne    1169 <IntegrityAndCorrectCheck+0x49>
add    %rcx,%rbx
add    $0x1,%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1030 <str2lx@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %cl,%bpl
setne  %al
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @IntegrityAndCorrectCheck(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = call zeroext i8 @CheckSum(i8* %7, i32* %3)
store i8 %8, i8* %6
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 42
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %5
%18 = or i32 %17, 8
store i32 %18, i32* %5
br label %35
19: ; preds = %1
%20 = load i8, i8* %6
%21 = zext i8 %20 to i32
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i64 @str2lx(i8* %26, i8** %4, i32 16)
%28 = trunc i64 %27 to i8
%29 = zext i8 %28 to i32
%30 = icmp ne i32 %21, %29
br i1 %30, label %31, label %34
31: ; preds = %19
%32 = load i32, i32* %5
%33 = or i32 %32, 1
store i32 %33, i32* %5
br label %34
34: ; preds = %31, %19
br label %35
35: ; preds = %34, %16
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
define i32 @IntegrityAndCorrectCheck(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = bitcast i32* %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = call zeroext i8 @CheckSum(i8* %0, i32* %2)
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 42
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = call i64 @str2lx(i8* %13, i8** %3, i32 16)
%15 = trunc i64 %14 to i8
%16 = icmp ne i8 %6, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %12, %1
%19 = phi i32 [ 8, %1 ], [ %17, %12 ]
ret i32 %19
}