#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*/ *strchr(char *, char);
int skipWordBackwards(char *string, int position) {
  char separators[] = " .,?";
  int i;
  for (i = position; i > 0 && strchr(separators, string[i - 1]) == NULL; i--)
    ;
  return i;
}


x86 assembly (clang, -O0):
<skipWordBackwards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0x11(%rbp)
mov    0xed6(%rip),%al
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jle    116a <skipWordBackwards+0x5a>
lea    -0x11(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117a <skipWordBackwards+0x6a>
jmp    118d <skipWordBackwards+0x7d>
jmp    117f <skipWordBackwards+0x6f>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <skipWordBackwards+0x27>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skipWordBackwards>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movb   $0x0,0x4(%rsp)
movl   $0x3f2c2e20,(%rsp)
mov    %esi,%ebp
xor    %r14d,%r14d
test   %esi,%esi
cmovs  %esi,%r14d
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
jle    1160 <skipWordBackwards+0x50>
movsbl -0x1(%rbx,%rbp,1),%esi
add    $0xffffffffffffffff,%rbp
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     1140 <skipWordBackwards+0x30>
add    $0x1,%ebp
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.skipWordBackwards.separators = [5 x i8] c" .,?\00"
define i32 @skipWordBackwards(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [5 x i8]* %5 to i8*
%8 = load i32, i32* %4
store i32 %8, i32* %6
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = call i32* @strchr(i8* %13, i8 signext %19)
%21 = icmp eq i32* %20, null
br label %22
22: ; preds = %12, %9
%23 = phi i1 [ false, %9 ], [ %21, %12 ]
br i1 %23, label %24, label %28
24: ; preds = %22
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = add nsw i32 %26, -1
store i32 %27, i32* %6
br label %9
28: ; preds = %22
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@__const.skipWordBackwards.separators = [5 x i8] c" .,?\00"
define i32 @skipWordBackwards(i8* nocapture %0, i32 %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = zext i32 %1 to i64
%6 = call i32 @llvm.smin.i32(i32 %1, i32 0)
br label %7
7: ; preds = %11, %2
%8 = phi i64 [ %12, %11 ], [ %5, %2 ]
%9 = trunc i64 %8 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = add nsw i64 %8, -1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = call i32* @strchr(i8* %4, i8 signext %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %7, label %17
17: ; preds = %11
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %7, %17
%20 = phi i32 [ %18, %17 ], [ %6, %7 ]
ret i32 %20
}