#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*/ ishex(char);
int strlen(char *);
int checksalt(char *salt) {
  int i;
  if (!salt)
    return 0;
  for (i = 0; i < strlen(salt); i++)
    if (!ishex(salt[i]))
      return 1;
  if (i == 8)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<checksalt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <checksalt+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11bc <checksalt+0x9c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    119f <checksalt+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <ishex@plt>
cmp    $0x0,%eax
jne    118c <checksalt+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    11bc <checksalt+0x9c>
jmp    1191 <checksalt+0x71>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <checksalt+0x2a>
cmpl   $0x8,-0x14(%rbp)
jne    11b5 <checksalt+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11bc <checksalt+0x9c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checksalt>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     116c <checksalt+0x4c>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    116f <checksalt+0x4f>
xor    %ebp,%ebp
nopl   (%rax)
movsbl (%rbx,%rbp,1),%edi
call   1030 <ishex@plt>
test   %eax,%eax
je     116f <checksalt+0x4f>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1140 <checksalt+0x20>
xor    %r14d,%r14d
cmp    $0x8,%ebp
setne  %r14b
jmp    116f <checksalt+0x4f>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checksalt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %32
8: ; preds = %1
store i32 0, i32* %4
br label %9
9: ; preds = %24, %8
%10 = load i32, i32* %4
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @ishex(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %14
store i32 1, i32* %2
br label %32
23: ; preds = %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %9
27: ; preds = %9
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 8
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 0, i32* %2
br label %32
31: ; preds = %27
store i32 1, i32* %2
br label %32
32: ; preds = %31, %30, %22, %7
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @checksalt(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %3, %12
%7 = phi i64 [ %13, %12 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i32 @ishex(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %6
%13 = add nuw nsw i64 %7, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %6, label %17
17: ; preds = %12
%18 = trunc i64 %13 to i32
%19 = icmp ne i32 %18, 8
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %6, %3, %17, %1
%22 = phi i32 [ 0, %1 ], [ 1, %3 ], [ %20, %17 ], [ 1, %6 ]
ret i32 %22
}