#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 isalnum(int);
int ispunct(int);
int isspace(int);
int stub1(char const);
int stub2(char const);
int M_JumpWordReverse(const char *line, int offset) {
  int (*is)(int);
  int c;
  c = line[--offset];
  if (isspace(c))
    is = isspace;
  else if (ispunct(c))
    is = ispunct;
  else
    is = isalnum;
  c = (*is)(line[offset]);
  while (offset > 0 && (*is)(line[offset - 1]) == c)
    offset--;
  return offset;
}


x86 assembly (clang, -O0):
<M_JumpWordReverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1038 <isspace@plt>
cmp    $0x0,%eax
je     1157 <M_JumpWordReverse+0x47>
mov    0x2e92(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1188 <M_JumpWordReverse+0x78>
mov    -0x1c(%rbp),%edi
call   1030 <ispunct@plt>
cmp    $0x0,%eax
je     1178 <M_JumpWordReverse+0x68>
mov    0x2e69(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1183 <M_JumpWordReverse+0x73>
mov    0x2e51(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1188 <M_JumpWordReverse+0x78>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x1d(%rbp)
jle    11cc <M_JumpWordReverse+0xbc>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%edi
call   *%rax
cmp    -0x1c(%rbp),%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11dc <M_JumpWordReverse+0xcc>
jmp    11ea <M_JumpWordReverse+0xda>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <M_JumpWordReverse+0x8d>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<M_JumpWordReverse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
movslq %esi,%r12
movsbl -0x1(%rdi,%r12,1),%ebp
add    $0xffffffffffffffff,%r12
mov    %ebp,%edi
call   1038 <isspace@plt>
test   %eax,%eax
je     1141 <M_JumpWordReverse+0x31>
mov    0x2ea1(%rip),%r15
jmp    115c <M_JumpWordReverse+0x4c>
mov    %ebp,%edi
call   1030 <ispunct@plt>
test   %eax,%eax
jne    1155 <M_JumpWordReverse+0x45>
mov    0x2e7d(%rip),%r15
jmp    115c <M_JumpWordReverse+0x4c>
mov    0x2e7c(%rip),%r15
mov    %ebp,%edi
call   *%r15
mov    %eax,%r13d
mov    %r12d,%ebp
xor    %eax,%eax
test   %r12d,%r12d
cmovs  %r12d,%eax
mov    %eax,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebp,%ebp
jle    119b <M_JumpWordReverse+0x8b>
movsbl -0x1(%r14,%rbp,1),%edi
add    $0xffffffffffffffff,%rbp
call   *%r15
add    $0xffffffff,%ebx
cmp    %r13d,%eax
je     1180 <M_JumpWordReverse+0x70>
jmp    119e <M_JumpWordReverse+0x8e>
mov    %r12d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @M_JumpWordReverse(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32 (i32)*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @isspace(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 (i32)* @isspace, i32 (i32)** %5
br label %25
18: ; preds = %2
%19 = load i32, i32* %6
%20 = call i32 @ispunct(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 (i32)* @ispunct, i32 (i32)** %5
br label %24
23: ; preds = %18
store i32 (i32)* @isalnum, i32 (i32)** %5
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %17
%26 = load i32 (i32)*, i32 (i32)** %5
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 %26(i32 %32)
store i32 %33, i32* %6
br label %34
34: ; preds = %51, %25
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %34
%38 = load i32 (i32)*, i32 (i32)** %5
%39 = load i8*, i8** %3
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = call i32 %38(i32 %45)
%47 = load i32, i32* %6
%48 = icmp eq i32 %46, %47
br label %49
49: ; preds = %37, %34
%50 = phi i1 [ false, %34 ], [ %48, %37 ]
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i32, i32* %4
%53 = add nsw i32 %52, -1
store i32 %53, i32* %4
br label %34
54: ; preds = %49
%55 = load i32, i32* %4
ret i32 %55
}

LLVM IR (-O2):
define i32 @M_JumpWordReverse(i8* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = tail call i32 @isspace(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = tail call i32 @ispunct(i32 %7)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 (i32)* @isalnum, i32 (i32)* @ispunct
br label %14
14: ; preds = %10, %2
%15 = phi i32 (i32)* [ @isspace, %2 ], [ %13, %10 ]
%16 = tail call i32 %15(i32 %7)
%17 = zext i32 %3 to i64
%18 = call i32 @llvm.smin.i32(i32 %3, i32 0)
br label %19
19: ; preds = %23, %14
%20 = phi i64 [ %24, %23 ], [ %17, %14 ]
%21 = trunc i64 %20 to i32
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = add nsw i64 %20, -1
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 %15(i32 %27)
%29 = icmp eq i32 %28, %16
br i1 %29, label %19, label %30
30: ; preds = %23
%31 = trunc i64 %20 to i32
br label %32
32: ; preds = %19, %30
%33 = phi i32 [ %31, %30 ], [ %18, %19 ]
ret i32 %33
}