#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 */
int ResultD(int);
int Tcl_StringMatch(char *, char *);
char Up(char);
int /*<<< orphan*/ free(char *);
int re_match(char *, char *);
char *strdup_upper(char *);
int picolCommandStringMatchOrRegexp(int argc, char **argv, void *pd) {
  char *pattern = strdup_upper(argv[1]);
  char *s = strdup_upper(argv[2]);
  int z = (Up(argv[0][1]) == 'R') ? re_match(pattern, s)
                                  : Tcl_StringMatch(s, pattern);
  free(pattern);
  free(s);
  return ResultD(z);
}


x86 assembly (clang, -O0):
<picolCommandStringMatchOrRegexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <strdup_upper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <strdup_upper@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%edi
call   1060 <Up@plt>
movsbl %al,%eax
cmp    $0x52,%eax
jne    11c6 <picolCommandStringMatchOrRegexp+0x66>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <re_match@plt>
mov    %eax,-0x30(%rbp)
jmp    11d6 <picolCommandStringMatchOrRegexp+0x76>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <Tcl_StringMatch@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%edi
call   1070 <ResultD@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<picolCommandStringMatchOrRegexp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1080 <strdup_upper@plt>
mov    %rax,%r14
mov    0x10(%rbp),%rdi
call   1080 <strdup_upper@plt>
mov    %rax,%rbx
mov    0x0(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1060 <Up@plt>
cmp    $0x52,%al
jne    119d <picolCommandStringMatchOrRegexp+0x3d>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <re_match@plt>
jmp    11a8 <picolCommandStringMatchOrRegexp+0x48>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <Tcl_StringMatch@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <ResultD@plt>

LLVM IR (-O0):
define i32 @picolCommandStringMatchOrRegexp(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i8* @strdup_upper(i8* %12)
store i8* %13, i8** %7
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i8* @strdup_upper(i8* %16)
store i8* %17, i8** %8
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = call signext i8 @Up(i8 signext %22)
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 82
br i1 %25, label %26, label %30
26: ; preds = %3
%27 = load i8*, i8** %7
%28 = load i8*, i8** %8
%29 = call i32 @re_match(i8* %27, i8* %28)
br label %34
30: ; preds = %3
%31 = load i8*, i8** %8
%32 = load i8*, i8** %7
%33 = call i32 @Tcl_StringMatch(i8* %31, i8* %32)
br label %34
34: ; preds = %30, %26
%35 = phi i32 [ %29, %26 ], [ %33, %30 ]
store i32 %35, i32* %9
%36 = load i8*, i8** %7
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 @free(i8* %38)
%40 = load i32, i32* %9
%41 = call i32 @ResultD(i32 %40)
ret i32 %41
}

LLVM IR (-O2):
define i32 @picolCommandStringMatchOrRegexp(i32 %0, i8** nocapture %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i8* @strdup_upper(i8* %5)
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i8* @strdup_upper(i8* %8)
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = tail call signext i8 @Up(i8 signext %12)
%14 = icmp eq i8 %13, 82
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = tail call i32 @re_match(i8* %6, i8* %9)
br label %19
17: ; preds = %3
%18 = tail call i32 @Tcl_StringMatch(i8* %9, i8* %6)
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ]
%21 = tail call i32 @free(i8* %6)
%22 = tail call i32 @free(i8* %9)
%23 = tail call i32 @ResultD(i32 %20)
ret i32 %23
}