#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 */
char *_keystore_get_volume_type(struct properties *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *properties_get(struct properties *, char *);
int /*<<< orphan*/ str_list_free_string_array(char **);
char **str_list_split(char *);
scalar_t__ strcasecmp(char *, char const *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ util_print_indented(char const *, int /*<<< orphan*/);
int _keystore_msg_for_volumes(const char *msg, struct properties *properties,
                              const char *volume_type) {
  char *volumes = NULL;
  char **volume_list;
  char *type = NULL;
  int i;
  if (volume_type != NULL) {
    type = _keystore_get_volume_type(properties);
    if (strcasecmp(type, volume_type) != 0)
      goto out;
  }
  volumes = properties_get(properties, "volumes");
  if (volumes != NULL && strlen(volumes) > 0) {
    volume_list = str_list_split(volumes);
    util_print_indented(msg, 0);
    for (i = 0; volume_list[i] != NULL; i++)
      printf("  %s\n", volume_list[i]);
    str_list_free_string_array(volume_list);
  }
out:
  if (volumes != NULL)
    free(volumes);
  if (type != NULL)
    free(type);
  return 0;
}


x86 assembly (clang, -O0):
<_keystore_msg_for_volumes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ed <_keystore_msg_for_volumes+0x5d>
mov    -0x10(%rbp),%rdi
call   1060 <_keystore_get_volume_type@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcasecmp@plt>
cmp    $0x0,%rax
je     11e8 <_keystore_msg_for_volumes+0x58>
jmp    1285 <_keystore_msg_for_volumes+0xf5>
jmp    11ed <_keystore_msg_for_volumes+0x5d>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   10a0 <properties_get@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1280 <_keystore_msg_for_volumes+0xf0>
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
jle    1280 <_keystore_msg_for_volumes+0xf0>
mov    -0x20(%rbp),%rdi
call   1040 <str_list_split@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   10b0 <util_print_indented@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1277 <_keystore_msg_for_volumes+0xe7>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xda4(%rip),%rdi
call   1080 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    123e <_keystore_msg_for_volumes+0xae>
mov    -0x28(%rbp),%rdi
call   1090 <str_list_free_string_array@plt>
jmp    1285 <_keystore_msg_for_volumes+0xf5>
cmpq   $0x0,-0x20(%rbp)
je     1299 <_keystore_msg_for_volumes+0x109>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     12ad <_keystore_msg_for_volumes+0x11d>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_keystore_msg_for_volumes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdx,%rdx
je     11c8 <_keystore_msg_for_volumes+0x38>
mov    %rdx,%rbx
mov    %r14,%rdi
call   1060 <_keystore_get_volume_type@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcasecmp@plt>
test   %rax,%rax
jne    1244 <_keystore_msg_for_volumes+0xb4>
jmp    11cb <_keystore_msg_for_volumes+0x3b>
xor    %r13d,%r13d
lea    0xe2e(%rip),%rsi
mov    %r14,%rdi
call   10a0 <properties_get@plt>
test   %rax,%rax
je     1244 <_keystore_msg_for_volumes+0xb4>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <strlen@plt>
test   %rax,%rax
jle    123c <_keystore_msg_for_volumes+0xac>
mov    %r14,%rdi
call   1040 <str_list_split@plt>
mov    %rax,%r12
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <util_print_indented@plt>
mov    (%r12),%rsi
test   %rsi,%rsi
je     1234 <_keystore_msg_for_volumes+0xa4>
mov    %r12,%rbx
add    $0x8,%rbx
lea    0xded(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1080 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1220 <_keystore_msg_for_volumes+0x90>
mov    %r12,%rdi
call   1090 <str_list_free_string_array@plt>
mov    %r14,%rdi
call   1030 <free@plt>
test   %r13,%r13
je     1251 <_keystore_msg_for_volumes+0xc1>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.properties = type { i32 }
@.str = [8 x i8] c"volumes\00"
@.str.1 = [6 x i8] c" %s\0A\00"
define i32 @_keystore_msg_for_volumes(i8* %0, %struct.properties* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = tail call i8* @_keystore_get_volume_type(%struct.properties* %1)
%7 = tail call i64 @strcasecmp(i8* %6, i8* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %5, %3
%10 = phi i8* [ %6, %5 ], [ null, %3 ]
%11 = tail call i8* @properties_get(%struct.properties* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %33, label %13
13: ; preds = %9
%14 = tail call i64 @strlen(i8* %11)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = tail call i8** @str_list_split(i8* %11)
%18 = tail call i32 @util_print_indented(i8* %0, i32 0)
%19 = load i8*, i8** %17
%20 = icmp eq i8* %19, null
br i1 %20, label %29, label %21
21: ; preds = %16, %21
%22 = phi i64 [ %25, %21 ], [ 0, %16 ]
%23 = phi i8* [ %27, %21 ], [ %19, %16 ]
%24 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = add nuw i64 %22, 1
%26 = getelementptr inbounds i8*, i8** %17, i64 %25
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %21
29: ; preds = %21, %16
%30 = tail call i32 @str_list_free_string_array(i8** %17)
br label %31
31: ; preds = %29, %13
%32 = tail call i32 @free(i8* %11)
br label %33
33: ; preds = %9, %5, %31
%34 = phi i8* [ %10, %31 ], [ %10, %9 ], [ %6, %5 ]
%35 = icmp eq i8* %34, null
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = tail call i32 @free(i8* %34)
br label %38
38: ; preds = %36, %33
ret i32 0
}