#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*/ strlen(char *);
int strtol(char *, char **, int);
int processChecksum(char *string) {
  char *err = NULL;
  char cChecksum[2] = {(string[strlen(string) - 1]), '\0'};
  int checksum = strtol(cChecksum, &err, 16);
  if (*err != '\0') {
    checksum = -1;
  }
  return checksum;
}


x86 assembly (clang, -O0):
<processChecksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
lea    -0x12(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1187 <processChecksum+0x67>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processChecksum>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
call   1030 <strlen@plt>
cltq
mov    -0x1(%rax,%rbx,1),%al
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
lea    0x6(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    0x8(%rsp),%rcx
xor    %edx,%edx
cmp    (%rcx),%dl
sbb    %ecx,%ecx
or     %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @processChecksum(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [2 x i8]
%5 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = load i8, i8* %12
store i8 %13, i8* %6
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8 0, i8* %14
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%16 = call i32 @strtol(i8* %15, i8** %3, i32 16)
store i32 %16, i32* %5
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %1
store i32 -1, i32* %5
br label %22
22: ; preds = %21, %1
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
define i32 @processChecksum(i8* %0) {
%2 = alloca i8*
%3 = alloca [2 x i8]
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
store i8 %10, i8* %5
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
store i8 0, i8* %11
%12 = call i32 @strtol(i8* %5, i8** %2, i32 16)
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = select i1 %15, i32 %12, i32 -1
ret i32 %16
}