#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__ check_env(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int /*<<< orphan*/);
int path_attached_to_hba(const char *disk_path, const char *hba_path) {
  int rc;
  if (check_env("IMSM_TEST_AHCI_DEV") || check_env("IMSM_TEST_SCU_DEV")) {
    return 1;
  }
  if (!disk_path || !hba_path)
    return 0;
  ({
    if (0)
      fprintf(stderr, "hba: %s - disk: %s\n", hba_path, disk_path);
    0;
  });
  if (strncmp(disk_path, hba_path, strlen(hba_path)) == 0)
    rc = 1;
  else
    rc = 0;
  return rc;
}


x86 assembly (clang, -O0):
<path_attached_to_hba>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xeb9(%rip),%rdi
call   1040 <check_env@plt>
cmp    $0x0,%rax
jne    116c <path_attached_to_hba+0x3c>
lea    0xeb6(%rip),%rdi
call   1040 <check_env@plt>
cmp    $0x0,%rax
je     1178 <path_attached_to_hba+0x48>
movl   $0x1,-0x4(%rbp)
jmp    11ec <path_attached_to_hba+0xbc>
cmpq   $0x0,-0x10(%rbp)
je     118e <path_attached_to_hba+0x5e>
cmpq   $0x0,-0x18(%rbp)
jne    119a <path_attached_to_hba+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    11ec <path_attached_to_hba+0xbc>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11df <path_attached_to_hba+0xaf>
movl   $0x1,-0x1c(%rbp)
jmp    11e6 <path_attached_to_hba+0xb6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_attached_to_hba>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
call   1040 <check_env@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    118b <path_attached_to_hba+0x5b>
lea    0xebc(%rip),%rdi
call   1040 <check_env@plt>
test   %rax,%rax
jne    118b <path_attached_to_hba+0x5b>
xor    %ebp,%ebp
test   %rbx,%rbx
je     118b <path_attached_to_hba+0x5b>
test   %r14,%r14
je     118b <path_attached_to_hba+0x5b>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"IMSM_TEST_AHCI_DEV\00"
@.str.1 = [18 x i8] c"IMSM_TEST_SCU_DEV\00"
@stderr = global i32 0
define i32 @path_attached_to_hba(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i64 @check_env(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i64 @check_env(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store i32 1, i32* %3
br label %33
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %17, %14
store i32 0, i32* %3
br label %33
21: ; preds = %17
store i32 0, i32* %7
%22 = load i32, i32* %7
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %5
%26 = call i32 @strlen(i8* %25)
%27 = call i64 @strncmp(i8* %23, i8* %24, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 1, i32* %6
br label %31
30: ; preds = %21
store i32 0, i32* %6
br label %31
31: ; preds = %30, %29
%32 = load i32, i32* %6
store i32 %32, i32* %3
br label %33
33: ; preds = %31, %20, %13
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [19 x i8] c"IMSM_TEST_AHCI_DEV\00"
@.str.1 = [18 x i8] c"IMSM_TEST_SCU_DEV\00"
@stderr = global i32 0
define i32 @path_attached_to_hba(i8* %0, i8* %1) {
%3 = tail call i64 @check_env(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = tail call i64 @check_env(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = icmp ne i8* %0, null
%10 = icmp ne i8* %1, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = tail call i32 @strlen(i8* %1)
%14 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %8, %2, %5, %12
%18 = phi i32 [ %16, %12 ], [ 1, %5 ], [ 1, %2 ], [ 0, %8 ]
ret i32 %18
}