#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 msgpath_array {
  int dummy;
};
struct imap_ll {
  int dummy;
};
struct globber_array {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ is_globber_array_match(struct globber_array *, char *);
int /*<<< orphan*/ scan_folder(struct imap_ll *, char *,
                               struct msgpath_array *);
int /*<<< orphan*/ split_on_colons(char const *, int *, char ***);
void build_imap_message_list(const char *folders, struct msgpath_array *msgs,
                             struct globber_array *omit_globs,
                             struct imap_ll *imapc) {
  char **folderlist;
  int n_folders;
  int i;
  split_on_colons(folders, &n_folders, &folderlist);
  for (i = 0; i < n_folders; i++) {
    if (!is_globber_array_match(omit_globs, folderlist[i])) {
      scan_folder(imapc, folderlist[i], msgs);
    }
  }
}


x86 assembly (clang, -O0):
<build_imap_message_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <split_on_colons@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11b6 <build_imap_message_list+0x86>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <is_globber_array_match@plt>
cmp    $0x0,%eax
jne    11a3 <build_imap_message_list+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <scan_folder@plt>
jmp    11a8 <build_imap_message_list+0x78>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1160 <build_imap_message_list+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_imap_message_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <split_on_colons@plt>
cmpl   $0x0,0xc(%rsp)
jle    1199 <build_imap_message_list+0x69>
xor    %ebx,%ebx
jmp    116e <build_imap_message_list+0x3e>
xchg   %ax,%ax
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jge    1199 <build_imap_message_list+0x69>
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r12,%rdi
call   1030 <is_globber_array_match@plt>
test   %eax,%eax
jne    1160 <build_imap_message_list+0x30>
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1050 <scan_folder@plt>
jmp    1160 <build_imap_message_list+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.msgpath_array = type { i32 }
%struct.globber_array = type { i32 }
%struct.imap_ll = type { i32 }
define void @build_imap_message_list(i8* %0, %struct.msgpath_array* %1, %struct.globber_array* %2, %struct.imap_ll* %3) {
%5 = alloca i8*
%6 = alloca %struct.msgpath_array*
%7 = alloca %struct.globber_array*
%8 = alloca %struct.imap_ll*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store %struct.msgpath_array* %1, %struct.msgpath_array** %6
store %struct.globber_array* %2, %struct.globber_array** %7
store %struct.imap_ll* %3, %struct.imap_ll** %8
%12 = load i8*, i8** %5
%13 = call i32 @split_on_colons(i8* %12, i32* %10, i8*** %9)
store i32 0, i32* %11
br label %14
14: ; preds = %37, %4
%15 = load i32, i32* %11
%16 = load i32, i32* %10
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load %struct.globber_array*, %struct.globber_array** %7
%20 = load i8**, i8*** %9
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @is_globber_array_match(%struct.globber_array* %19, i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %18
%28 = load %struct.imap_ll*, %struct.imap_ll** %8
%29 = load i8**, i8*** %9
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load %struct.msgpath_array*, %struct.msgpath_array** %6
%35 = call i32 @scan_folder(%struct.imap_ll* %28, i8* %33, %struct.msgpath_array* %34)
br label %36
36: ; preds = %27, %18
br label %37
37: ; preds = %36
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %14
40: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.msgpath_array = type { i32 }
%struct.globber_array = type { i32 }
%struct.imap_ll = type { i32 }
define void @build_imap_message_list(i8* %0, %struct.msgpath_array* %1, %struct.globber_array* %2, %struct.imap_ll* %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = bitcast i8*** %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = call i32 @split_on_colons(i8* %0, i32* %6, i8*** %5)
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %4, %24
%13 = phi i64 [ %25, %24 ], [ 0, %4 ]
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 %13
%16 = load i8*, i8** %15
%17 = call i32 @is_globber_array_match(%struct.globber_array* %2, i8* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 %13
%22 = load i8*, i8** %21
%23 = call i32 @scan_folder(%struct.imap_ll* %3, i8* %22, %struct.msgpath_array* %1)
br label %24
24: ; preds = %12, %19
%25 = add nuw nsw i64 %13, 1
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %12, label %29
29: ; preds = %24, %4
ret void
}