#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 */
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strlen(char const *);
int optstr_is_string_arg(const char *fmt) {
  if (!fmt) {
    return 0;
  }
  if (!strlen(fmt)) {
    return 0;
  }
  if (strchr(fmt, 's')) {
    return 1;
  }
  if (strchr(fmt, '[') && strchr(fmt, ']')) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<optstr_is_string_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <optstr_is_string_arg+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <optstr_is_string_arg+0xa8>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1161 <optstr_is_string_arg+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <optstr_is_string_arg+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x73,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1185 <optstr_is_string_arg+0x65>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <optstr_is_string_arg+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x5b,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11c1 <optstr_is_string_arg+0xa1>
mov    -0x10(%rbp),%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11c1 <optstr_is_string_arg+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <optstr_is_string_arg+0xa8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optstr_is_string_arg>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1173 <optstr_is_string_arg+0x53>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     1173 <optstr_is_string_arg+0x53>
mov    %rbx,%rdi
mov    $0x73,%esi
call   1040 <strchr@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1173 <optstr_is_string_arg+0x53>
mov    %rbx,%rdi
mov    $0x5b,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1171 <optstr_is_string_arg+0x51>
mov    %rbx,%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1173 <optstr_is_string_arg+0x53>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @optstr_is_string_arg(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i32 0, i32* %2
br label %27
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
store i32 0, i32* %2
br label %27
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strchr(i8* %13, i8 signext 115)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 1, i32* %2
br label %27
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i64 @strchr(i8* %18, i8 signext 91)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = call i64 @strchr(i8* %22, i8 signext 93)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 1, i32* %2
br label %27
26: ; preds = %21, %17
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %16, %11, %6
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @optstr_is_string_arg(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @strchr(i8* %0, i8 signext 115)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i64 @strchr(i8* %0, i8 signext 91)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i64 @strchr(i8* %0, i8 signext 93)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12, %9
br label %16
16: ; preds = %12, %6, %3, %1, %15
%17 = phi i32 [ 0, %15 ], [ 0, %1 ], [ 0, %3 ], [ 1, %6 ], [ 1, %12 ]
ret i32 %17
}