#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 */
struct properties {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _keystore_is_block_device(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *properties_get(struct properties *, char *);
int /*<<< orphan*/ str_list_free_string_array(char **);
char **str_list_split(char *);
char *strchr(char *, char);
int _keystore_display_volume_status(struct properties *properties,
                                    const char *name) {
  int i, warning = 0;
  char **volume_list;
  char *volumes;
  char *ch;
  volumes = properties_get(properties, "volumes");
  if (volumes == NULL)
    return 0;
  volume_list = str_list_split(volumes);
  for (i = 0; volume_list[i] != NULL; i++) {
    ch = strchr(volume_list[i], ':');
    if (ch != NULL)
      *ch = '\0';
    if (!_keystore_is_block_device(volume_list[i])) {
      printf("WARNING: The volume '%s' associated with "
             "key '%s' is not available\n",
             volume_list[i], name);
      warning = 1;
    }
  }
  if (warning)
    printf("\n");
  free(volumes);
  str_list_free_string_array(volume_list);
  return warning;
}


x86 assembly (clang, -O0):
<_keystore_display_volume_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <properties_get@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b2 <_keystore_display_volume_status+0x42>
movl   $0x0,-0x4(%rbp)
jmp    1287 <_keystore_display_volume_status+0x117>
mov    -0x30(%rbp),%rdi
call   1040 <str_list_split@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1257 <_keystore_display_volume_status+0xe7>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1205 <_keystore_display_volume_status+0x95>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <_keystore_is_block_device@plt>
cmp    $0x0,%eax
jne    1244 <_keystore_display_volume_status+0xd4>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rdx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x20(%rbp)
jmp    1249 <_keystore_display_volume_status+0xd9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <_keystore_display_volume_status+0x56>
cmpl   $0x0,-0x20(%rbp)
je     126f <_keystore_display_volume_status+0xff>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1070 <str_list_free_string_array@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_keystore_display_volume_status>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
lea    0xe6b(%rip),%rsi
call   1090 <properties_get@plt>
test   %rax,%rax
je     1228 <_keystore_display_volume_status+0xa8>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <str_list_split@plt>
mov    %rax,%r14
mov    (%rax),%rbx
test   %rbx,%rbx
je     122c <_keystore_display_volume_status+0xac>
lea    0xe48(%rip),%r12
mov    %r14,(%rsp)
xor    %ebp,%ebp
jmp    11dd <_keystore_display_volume_status+0x5d>
nopl   0x0(%rax,%rax,1)
mov    0x8(%r14),%rbx
add    $0x8,%r14
test   %rbx,%rbx
je     1218 <_keystore_display_volume_status+0x98>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11f5 <_keystore_display_volume_status+0x75>
movb   $0x0,(%rax)
mov    (%r14),%rbx
mov    %rbx,%rdi
call   10a0 <_keystore_is_block_device@plt>
test   %eax,%eax
jne    11d0 <_keystore_display_volume_status+0x50>
mov    (%r14),%rsi
mov    %r12,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%ebp
jmp    11d0 <_keystore_display_volume_status+0x50>
test   %ebp,%ebp
je     1230 <_keystore_display_volume_status+0xb0>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1232 <_keystore_display_volume_status+0xb2>
xor    %ebp,%ebp
jmp    1246 <_keystore_display_volume_status+0xc6>
xor    %ebp,%ebp
jmp    1236 <_keystore_display_volume_status+0xb6>
xor    %ebp,%ebp
mov    (%rsp),%r14
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1080 <str_list_free_string_array@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.properties = type { i32 }
@.str = [8 x i8] c"volumes\00"
@.str.1 = [68 x i8] c"WARNING: The volume '%s' associated with key '%s' is not available\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @_keystore_display_volume_status(%struct.properties* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.properties*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
store %struct.properties* %0, %struct.properties** %4
store i8* %1, i8** %5
store i32 0, i32* %7
%11 = load %struct.properties*, %struct.properties** %4
%12 = call i8* @properties_get(%struct.properties* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %9
%13 = load i8*, i8** %9
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %68
16: ; preds = %2
%17 = load i8*, i8** %9
%18 = call i8** @str_list_split(i8* %17)
store i8** %18, i8*** %8
store i32 0, i32* %6
br label %19
19: ; preds = %54, %16
%20 = load i8**, i8*** %8
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %57
26: ; preds = %19
%27 = load i8**, i8*** %8
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i8* @strchr(i8* %31, i8 signext 58)
store i8* %32, i8** %10
%33 = load i8*, i8** %10
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %26
%36 = load i8*, i8** %10
store i8 0, i8* %36
br label %37
37: ; preds = %35, %26
%38 = load i8**, i8*** %8
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @_keystore_is_block_device(i8* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %37
%46 = load i8**, i8*** %8
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = load i8*, i8** %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* %50, i8* %51)
store i32 1, i32* %7
br label %53
53: ; preds = %45, %37
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %19
57: ; preds = %19
%58 = load i32, i32* %7
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
%65 = load i8**, i8*** %8
%66 = call i32 @str_list_free_string_array(i8** %65)
%67 = load i32, i32* %7
store i32 %67, i32* %3
br label %68
68: ; preds = %62, %15
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
%struct.properties = type { i32 }
@.str = [8 x i8] c"volumes\00"
@.str.1 = [68 x i8] c"WARNING: The volume '%s' associated with key '%s' is not available\0A\00"
define i32 @_keystore_display_volume_status(%struct.properties* %0, i8* %1) {
%3 = tail call i8* @properties_get(%struct.properties* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %39, label %5
5: ; preds = %2
%6 = tail call i8** @str_list_split(i8* %3)
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %35, label %9
9: ; preds = %5, %25
%10 = phi i64 [ %27, %25 ], [ 0, %5 ]
%11 = phi i8* [ %29, %25 ], [ %7, %5 ]
%12 = phi i8** [ %28, %25 ], [ %6, %5 ]
%13 = phi i32 [ %26, %25 ], [ 0, %5 ]
%14 = tail call i8* @strchr(i8* %11, i8 signext 58)
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %9
store i8 0, i8* %14
%17 = load i8*, i8** %12
br label %18
18: ; preds = %16, %9
%19 = phi i8* [ %17, %16 ], [ %11, %9 ]
%20 = tail call i32 @_keystore_is_block_device(i8* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %12
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %1)
br label %25
25: ; preds = %18, %22
%26 = phi i32 [ %13, %18 ], [ 1, %22 ]
%27 = add nuw i64 %10, 1
%28 = getelementptr inbounds i8*, i8** %6, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %9
31: ; preds = %25
%32 = icmp eq i32 %26, 0
br i1 %32, label %35, label %33
33: ; preds = %31
%34 = tail call i32 @putchar(i32 10)
br label %35
35: ; preds = %5, %33, %31
%36 = phi i32 [ %26, %33 ], [ 0, %31 ], [ 0, %5 ]
%37 = tail call i32 @free(i8* %3)
%38 = tail call i32 @str_list_free_string_array(i8** %6)
br label %39
39: ; preds = %2, %35
%40 = phi i32 [ %36, %35 ], [ 0, %2 ]
ret i32 %40
}