#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 /*<<< orphan*/ error_exit(int, char *, char const *);
int find_unquoted_character(const char *string, char character) {
  unsigned char in_quotes = 0;
  unsigned pos;
  const char *p;
  for (p = string, pos = 0; *p; p++, pos++) {
    if (*p == '"') {
      in_quotes ^= 1;
      continue;
    }
    if (in_quotes)
      continue;
    if (*p == character)
      return pos;
  }
  if (in_quotes)
    error_exit(1, "mismatched quotes in string: %s", string);
  return -1;
}


x86 assembly (clang, -O0):
<find_unquoted_character>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ad <find_unquoted_character+0x9d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1161 <find_unquoted_character+0x51>
movzbl -0x12(%rbp),%eax
xor    $0x1,%eax
mov    %al,-0x12(%rbp)
jmp    1193 <find_unquoted_character+0x83>
cmpb   $0x0,-0x12(%rbp)
je     1170 <find_unquoted_character+0x60>
jmp    1193 <find_unquoted_character+0x83>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    118e <find_unquoted_character+0x7e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d3 <find_unquoted_character+0xc3>
jmp    1193 <find_unquoted_character+0x83>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1135 <find_unquoted_character+0x25>
cmpb   $0x0,-0x12(%rbp)
je     11cc <find_unquoted_character+0xbc>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe39(%rip),%rsi
call   1030 <error_exit@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_unquoted_character>:
push   %rbx
mov    %rdi,%rdx
xor    %ebx,%ebx
xor    %eax,%eax
jmp    1126 <find_unquoted_character+0x16>
nopw   0x0(%rax,%rax,1)
xor    $0x1,%al
add    $0x1,%rbx
movzbl (%rdx,%rbx,1),%ecx
cmp    $0x22,%cl
je     1120 <find_unquoted_character+0x10>
test   %cl,%cl
je     1144 <find_unquoted_character+0x34>
test   %al,%al
jne    113e <find_unquoted_character+0x2e>
cmp    %sil,%cl
je     115e <find_unquoted_character+0x4e>
xor    %eax,%eax
add    $0x1,%rbx
jmp    1126 <find_unquoted_character+0x16>
mov    $0xffffffff,%ebx
test   %al,%al
je     115e <find_unquoted_character+0x4e>
lea    0xeac(%rip),%rsi
mov    $0x1,%edi
call   1030 <error_exit@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"mismatched quotes in string: %s\00"
define i32 @find_unquoted_character(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 0, i8* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %8
store i32 0, i32* %7
br label %10
10: ; preds = %38, %2
%11 = load i8*, i8** %8
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %43
14: ; preds = %10
%15 = load i8*, i8** %8
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 34
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8, i8* %6
%21 = zext i8 %20 to i32
%22 = xor i32 %21, 1
%23 = trunc i32 %22 to i8
store i8 %23, i8* %6
br label %38
24: ; preds = %14
%25 = load i8, i8* %6
%26 = icmp ne i8 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
br label %38
28: ; preds = %24
%29 = load i8*, i8** %8
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %31, %33
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = load i32, i32* %7
store i32 %36, i32* %3
br label %50
37: ; preds = %28
br label %38
38: ; preds = %37, %27, %19
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %8
%41 = load i32, i32* %7
%42 = add i32 %41, 1
store i32 %42, i32* %7
br label %10
43: ; preds = %10
%44 = load i8, i8* %6
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i8*, i8** %4
%48 = call i32 @error_exit(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %43
store i32 -1, i32* %3
br label %50
50: ; preds = %49, %35
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [32 x i8] c"mismatched quotes in string: %s\00"
define i32 @find_unquoted_character(i8* %0, i8 signext %1) {
br label %3
3: ; preds = %14, %2
%4 = phi i8 [ 0, %2 ], [ %15, %14 ]
%5 = phi i32 [ 0, %2 ], [ %17, %14 ]
%6 = phi i8* [ %0, %2 ], [ %16, %14 ]
%7 = load i8, i8* %6
switch i8 %7, label %10 [
i8 0, label %18
i8 34, label %8
]
8: ; preds = %3
%9 = xor i8 %4, 1
br label %14
10: ; preds = %3
%11 = icmp eq i8 %4, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = icmp eq i8 %7, %1
br i1 %13, label %22, label %14
14: ; preds = %12, %10, %8
%15 = phi i8 [ %9, %8 ], [ %4, %10 ], [ 0, %12 ]
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = add i32 %5, 1
br label %3
18: ; preds = %3
%19 = icmp eq i8 %4, 0
br i1 %19, label %22, label %20
20: ; preds = %18
%21 = tail call i32 @error_exit(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %22
22: ; preds = %12, %18, %20
%23 = phi i32 [ -1, %20 ], [ -1, %18 ], [ %5, %12 ]
ret i32 %23
}