#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*/ isdigit(char const);
int compare_left(char const *a, char const *b) {
  for (;; a++, b++) {
    if (!isdigit(*a) && !isdigit(*b))
      return 0;
    else if (!isdigit(*a))
      return -1;
    else if (!isdigit(*b))
      return +1;
    else if (*a < *b)
      return -1;
    else if (*a > *b)
      return +1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1156 <compare_left+0x46>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1156 <compare_left+0x46>
movl   $0x0,-0x4(%rbp)
jmp    1212 <compare_left+0x102>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1177 <compare_left+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <compare_left+0x102>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1198 <compare_left+0x88>
movl   $0x1,-0x4(%rbp)
jmp    1212 <compare_left+0x102>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jge    11ba <compare_left+0xaa>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <compare_left+0x102>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jle    11dc <compare_left+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    1212 <compare_left+0x102>
jmp    11e1 <compare_left+0xd1>
jmp    11e6 <compare_left+0xd6>
jmp    11eb <compare_left+0xdb>
jmp    11f0 <compare_left+0xe0>
jmp    11f5 <compare_left+0xe5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <compare_left+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_left>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    113c <compare_left+0x2c>
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117c <compare_left+0x6c>
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     117e <compare_left+0x6e>
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1175 <compare_left+0x65>
movzbl (%r14,%rbx,1),%eax
cmp    %al,(%r15,%rbx,1)
jl     117e <compare_left+0x6e>
mov    $0x1,%ebp
jg     117e <compare_left+0x6e>
add    $0x1,%rbx
jmp    1120 <compare_left+0x10>
mov    $0x1,%ebp
jmp    117e <compare_left+0x6e>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @compare_left(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %27, %2
%4 = phi i8* [ %0, %2 ], [ %28, %27 ]
%5 = phi i8* [ %1, %2 ], [ %29, %27 ]
%6 = load i8, i8* %4
%7 = tail call i32 @isdigit(i8 signext %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8, i8* %5
%11 = tail call i32 @isdigit(i8 signext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %9, %3
%14 = load i8, i8* %4
%15 = tail call i32 @isdigit(i8 signext %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %30, label %17
17: ; preds = %13
%18 = load i8, i8* %5
%19 = tail call i32 @isdigit(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %30, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = load i8, i8* %5
%24 = icmp slt i8 %22, %23
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = icmp sgt i8 %22, %23
br i1 %26, label %30, label %27
27: ; preds = %25
%28 = getelementptr inbounds i8, i8* %4, i64 1
%29 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
30: ; preds = %25, %21, %17, %13, %9
%31 = phi i32 [ 0, %9 ], [ -1, %13 ], [ 1, %17 ], [ -1, %21 ], [ 1, %25 ]
ret i32 %31
}