#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__ strcmp(char const *, char *);
int strlen(char const *);
bool toolname_is_chreipl_helper(const char *toolname) {
  int clen = strlen("chreipl_helper.device-mapper");
  int tlen = strlen(toolname);
  if (tlen < clen)
    return false;
  return strcmp(toolname + tlen - clen, "chreipl_helper.device-mapper") == 0;
}


x86 assembly (clang, -O0):
<toolname_is_chreipl_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    115f <toolname_is_chreipl_helper+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    1191 <toolname_is_chreipl_helper+0x71>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
movslq -0x14(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toolname_is_chreipl_helper>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
jl     116a <toolname_is_chreipl_helper+0x4a>
movslq %ecx,%rax
add    %rax,%rbx
movslq %ebp,%rax
sub    %rax,%rbx
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"chreipl_helper.device-mapper\00"
define i32 @toolname_is_chreipl_helper(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %25
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = sub i64 0, %19
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %2
br label %25
25: ; preds = %13, %12
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [29 x i8] c"chreipl_helper.device-mapper\00"
define i32 @toolname_is_chreipl_helper(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, %2
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = sext i32 %2 to i64
%9 = sub nsw i64 0, %8
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %1, %5
%15 = phi i32 [ %13, %5 ], [ 0, %1 ]
ret i32 %15
}