#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__ strcmp(char *, char const *);
char *strtok_r(char *, char *, char *);
signed char fs_check_if_readonly(char *mount_options) {
  static char const readonly_pattern[] = "ro";
  char *str1, saveptr1;
  int j;
  for (j = 1, str1 = mount_options;; j++, str1 = NULL) {
    char *token = strtok_r(str1, ",", &saveptr1);
    if (token == NULL)
      break;
    if ((strcmp(token, readonly_pattern) == 0))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fs_check_if_readonly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebd(%rip),%rsi
lea    -0x19(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1163 <fs_check_if_readonly+0x43>
jmp    11a1 <fs_check_if_readonly+0x81>
mov    -0x28(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <fs_check_if_readonly+0x66>
movb   $0x1,-0x1(%rbp)
jmp    11a5 <fs_check_if_readonly+0x85>
jmp    118b <fs_check_if_readonly+0x6b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
jmp    113b <fs_check_if_readonly+0x1b>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fs_check_if_readonly>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed3(%rip),%r14
lea    0xf(%rsp),%rbx
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1169 <fs_check_if_readonly+0x49>
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
mov    $0x0,%edi
test   %rax,%rax
jne    1140 <fs_check_if_readonly+0x20>
mov    $0x1,%al
jmp    116b <fs_check_if_readonly+0x4b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@fs_check_if_readonly.readonly_pattern = internal constant [3 x i8] c"ro\00"
@.str = [2 x i8] c",\00"
define signext i8 @fs_check_if_readonly(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32 1, i32* %6
%8 = load i8*, i8** %3
store i8* %8, i8** %4
br label %9
9: ; preds = %21, %1
%10 = load i8*, i8** %4
%11 = call i8* @strtok_r(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %5)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
br label %24
15: ; preds = %9
%16 = load i8*, i8** %7
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @fs_check_if_readonly.readonly_pattern, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8 1, i8* %2
br label %25
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
store i8* null, i8** %4
br label %9
24: ; preds = %14
store i8 0, i8* %2
br label %25
25: ; preds = %24, %19
%26 = load i8, i8* %2
ret i8 %26
}

LLVM IR (-O2):
@fs_check_if_readonly.readonly_pattern = internal constant [3 x i8] c"ro\00"
@.str = [2 x i8] c",\00"
define signext i8 @fs_check_if_readonly(i8* %0) {
%2 = alloca i8
br label %3
3: ; preds = %7, %1
%4 = phi i8* [ %0, %1 ], [ null, %7 ]
%5 = call i8* @strtok_r(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @fs_check_if_readonly.readonly_pattern, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %3
10: ; preds = %7, %3
%11 = phi i8 [ 0, %3 ], [ 1, %7 ]
ret i8 %11
}