#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 */
char *strstr(char *, char *);
int check_pattern(char *pattern) {
  char *retval1, *retval2, *retval3;
  char *pt1 = "]d";
  char *pt2 = "*";
  char *pt3 = "+";
  int retint = 0;
  retval1 = strstr(pattern, pt1);
  retval2 = strstr(pattern, pt2);
  retval3 = strstr(pattern, pt3);
  if (retval1 != NULL && retval2 == NULL && retval3 == NULL) {
    retint = 1;
  }
  return (retint);
}


x86 assembly (clang, -O0):
<check_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119f <check_pattern+0x8f>
cmpq   $0x0,-0x18(%rbp)
jne    119f <check_pattern+0x8f>
cmpq   $0x0,-0x20(%rbp)
jne    119f <check_pattern+0x8f>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_pattern>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed1(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2a,%esi
call   1030 <strchr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x2b,%esi
call   1030 <strchr@plt>
test   %r14,%r14
setne  %cl
test   %r15,%r15
sete   %dl
and    %cl,%dl
test   %rax,%rax
sete   %al
and    %dl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"]d\00"
define i32 @check_pattern(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 42)
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 43)
%5 = icmp ne i8* %2, null
%6 = icmp eq i8* %3, null
%7 = select i1 %5, i1 %6, i1 false
%8 = icmp eq i8* %4, null
%9 = select i1 %7, i1 %8, i1 false
%10 = zext i1 %9 to i32
ret i32 %10
}