#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 */
struct expr {
  int dummy;
};

/* Variables and functions */
scalar_t__ isdigit(char const);
int string2mask(char const *, int);
int find_mask(const char *remain, struct expr *e) {
  int i = 0;
  int res;
  while (isdigit(remain[i]) || remain[i] == '.')
    i++;
  if (i == 0)
    return 0;
  res = string2mask(remain, i - 1);
  if (res == -2)
    return 0;
  return res;
}


x86 assembly (clang, -O0):
<find_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    116f <find_mask+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117f <find_mask+0x5f>
jmp    118d <find_mask+0x6d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <find_mask+0x17>
cmpl   $0x0,-0x1c(%rbp)
jne    11a3 <find_mask+0x83>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <find_mask+0xb1>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
call   1040 <string2mask@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xfffffffe,-0x20(%rbp)
jne    11cb <find_mask+0xab>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <find_mask+0xb1>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_mask>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1134 <find_mask+0x14>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <find_mask+0x10>
cmpb   $0x2e,(%r14,%rbx,1)
je     1130 <find_mask+0x10>
test   %ebx,%ebx
je     1167 <find_mask+0x47>
add    $0xffffffff,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <string2mask@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xfffffffe,%ecx
cmovne %ecx,%eax
jmp    1169 <find_mask+0x49>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.expr = type { i32 }
define i32 @find_mask(i8* %0, %struct.expr* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.expr*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store %struct.expr* %1, %struct.expr** %5
store i32 0, i32* %6
br label %8
8: ; preds = %26, %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @isdigit(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %8
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
br label %24
24: ; preds = %16, %8
%25 = phi i1 [ true, %8 ], [ %23, %16 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %8
29: ; preds = %24
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 0, i32* %3
br label %43
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = call i32 @string2mask(i8* %34, i32 %36)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, -2
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 0, i32* %3
br label %43
41: ; preds = %33
%42 = load i32, i32* %7
store i32 %42, i32* %3
br label %43
43: ; preds = %41, %40, %32
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
%struct.expr = type { i32 }
define i32 @find_mask(i8* %0, %struct.expr* nocapture readnone %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i64 [ %13, %12 ], [ 0, %2 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = tail call i64 @isdigit(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 46
br i1 %11, label %12, label %14
12: ; preds = %3, %9
%13 = add nuw i64 %4, 1
br label %3
14: ; preds = %9
%15 = trunc i64 %4 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = add nsw i32 %15, -1
%19 = tail call i32 @string2mask(i8* %0, i32 %18)
%20 = icmp eq i32 %19, -2
%21 = select i1 %20, i32 0, i32 %19
br label %22
22: ; preds = %17, %14
%23 = phi i32 [ 0, %14 ], [ %21, %17 ]
ret i32 %23
}