#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 */
scalar_t__ memcmp(char *, char *, int);
int handlehex(int len, char *line) {
  static char *token = "$HEX[";
  if (len >= 6) {
    if ((memcmp(line, token, 5) == 0) && (line[len - 1] == ']')) {
      return 0;
    }
  }
  return len;
}


x86 assembly (clang, -O0):
<handlehex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
jl     1173 <handlehex+0x63>
mov    -0x10(%rbp),%rdi
mov    0x2ef4(%rip),%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    116e <handlehex+0x5e>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    116e <handlehex+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    1179 <handlehex+0x69>
jmp    1173 <handlehex+0x63>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handlehex>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x6,%edi
jl     1143 <handlehex+0x33>
mov    %rsi,%r14
lea    0xedb(%rip),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    1143 <handlehex+0x33>
lea    -0x1(%rbx),%ecx
xor    %eax,%eax
cmpb   $0x5d,(%r14,%rcx,1)
je     1145 <handlehex+0x35>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@handlehex.token = internal global i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0)
@.str = [6 x i8] c"$HEX[\00"
define i32 @handlehex(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
%7 = icmp sge i32 %6, 6
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** @handlehex.token
%11 = call i64 @memcmp(i8* %9, i8* %10, i32 5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 93
br i1 %21, label %22, label %23
22: ; preds = %13
store i32 0, i32* %3
br label %26
23: ; preds = %13, %8
br label %24
24: ; preds = %23, %2
%25 = load i32, i32* %4
store i32 %25, i32* %3
br label %26
26: ; preds = %24, %22
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [6 x i8] c"$HEX[\00"
define i32 @handlehex(i32 %0, i8* %1) {
%3 = icmp sgt i32 %0, 5
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = tail call i64 @memcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = add nsw i32 %0, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 93
br i1 %12, label %14, label %13
13: ; preds = %4, %7, %2
br label %14
14: ; preds = %7, %13
%15 = phi i32 [ %0, %13 ], [ 0, %7 ]
ret i32 %15
}