#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 */
scalar_t__ isdigit(unsigned char);
char *strchr(char *, char);
int looks_like_numeric(char *format) {
  if (!(format = strchr(format, '%')))
    return 0;
  while (++format &&
         (*format == ' ' || *format == '-' || *format == '+' || *format == '#'))
    ;
  while (isdigit((unsigned char)*format) || *format == '.')
    ++format;
  return (*format == 'f' || *format == 'g' || *format == 'e');
}


x86 assembly (clang, -O0):
<looks_like_numeric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x25,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1154 <looks_like_numeric+0x34>
movl   $0x0,-0x4(%rbp)
jmp    1277 <looks_like_numeric+0x157>
jmp    1159 <looks_like_numeric+0x39>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     11c9 <looks_like_numeric+0xa9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
je     11c3 <looks_like_numeric+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x12(%rbp)
je     11c3 <looks_like_numeric+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2b,%ecx
mov    %al,-0x12(%rbp)
je     11c3 <looks_like_numeric+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11d9 <looks_like_numeric+0xb9>
jmp    11de <looks_like_numeric+0xbe>
jmp    1159 <looks_like_numeric+0x39>
jmp    11e3 <looks_like_numeric+0xc3>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x13(%rbp)
jne    1211 <looks_like_numeric+0xf1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1221 <looks_like_numeric+0x101>
jmp    1232 <looks_like_numeric+0x112>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11e3 <looks_like_numeric+0xc3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x66,%ecx
mov    %al,-0x14(%rbp)
je     126c <looks_like_numeric+0x14c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x67,%ecx
mov    %al,-0x14(%rbp)
je     126c <looks_like_numeric+0x14c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x65,%eax
sete   %al
mov    %al,-0x14(%rbp)
mov    -0x14(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<looks_like_numeric>:
push   %rbx
mov    $0x25,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     119b <looks_like_numeric+0x7b>
mov    %rax,%rbx
add    $0x2,%rbx
movabs $0x280900000000,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%eax
cmp    $0x2d,%rax
ja     1177 <looks_like_numeric+0x57>
bt     %rax,%rcx
jae    1177 <looks_like_numeric+0x57>
add    $0x1,%rbx
jmp    1150 <looks_like_numeric+0x30>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1170 <looks_like_numeric+0x50>
movzbl -0x1(%rbx),%ecx
cmp    $0x2e,%cl
je     1170 <looks_like_numeric+0x50>
lea    -0x66(%rcx),%eax
cmp    $0x2,%al
jae    119f <looks_like_numeric+0x7f>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
cmp    $0x65,%cl
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @looks_like_numeric(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i8* @strchr(i8* %4, i8 signext 37)
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %72
8: ; preds = %1
br label %9
9: ; preds = %37, %8
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %35
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %33, label %18
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 45
br i1 %22, label %33, label %23
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 43
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 35
br label %33
33: ; preds = %28, %23, %18, %13
%34 = phi i1 [ true, %23 ], [ true, %18 ], [ true, %13 ], [ %32, %28 ]
br label %35
35: ; preds = %33, %9
%36 = phi i1 [ false, %9 ], [ %34, %33 ]
br i1 %36, label %37, label %38
37: ; preds = %35
br label %9
38: ; preds = %35
br label %39
39: ; preds = %51, %38
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = call i64 @isdigit(i8 zeroext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 46
br label %49
49: ; preds = %44, %39
%50 = phi i1 [ true, %39 ], [ %48, %44 ]
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %3
br label %39
54: ; preds = %49
%55 = load i8*, i8** %3
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 102
br i1 %58, label %69, label %59
59: ; preds = %54
%60 = load i8*, i8** %3
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 103
br i1 %63, label %69, label %64
64: ; preds = %59
%65 = load i8*, i8** %3
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 101
br label %69
69: ; preds = %64, %59, %54
%70 = phi i1 [ true, %59 ], [ true, %54 ], [ %68, %64 ]
%71 = zext i1 %70 to i32
store i32 %71, i32* %2
br label %72
72: ; preds = %69, %7
%73 = load i32, i32* %2
ret i32 %73
}

LLVM IR (-O2):
define i32 @looks_like_numeric(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 37)
%3 = icmp eq i8* %2, null
br i1 %3, label %22, label %4
4: ; preds = %1, %8
%5 = phi i8* [ %6, %8 ], [ %2, %1 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
switch i8 %7, label %9 [
i8 32, label %8
i8 45, label %8
i8 43, label %8
i8 35, label %8
]
8: ; preds = %4, %4, %4, %4
br label %4
9: ; preds = %4, %16
%10 = phi i8 [ %18, %16 ], [ %7, %4 ]
%11 = phi i8* [ %17, %16 ], [ %6, %4 ]
%12 = tail call i64 @isdigit(i8 zeroext %10)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = load i8, i8* %11
switch i8 %15, label %19 [
i8 46, label %16
i8 102, label %22
i8 103, label %22
]
16: ; preds = %14, %9
%17 = getelementptr inbounds i8, i8* %11, i64 1
%18 = load i8, i8* %17
br label %9
19: ; preds = %14
%20 = icmp eq i8 %15, 101
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %14, %14, %19, %1
%23 = phi i32 [ 0, %1 ], [ %21, %19 ], [ 1, %14 ], [ 1, %14 ]
ret i32 %23
}