#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*/ isascii(char const);
int /*<<< orphan*/ isdigit(char const);
int cl_write_netlog_format(char const *s, char const *e) {
  long long ll = 0;
  if (s >= e)
    return 's';
  for (; s < e; s++) {
    if (!isascii(*s) || !isdigit(*s))
      return 's';
    ll = ll * 10 + (*s - '0');
  }
  if (ll < (1ull << 32))
    return 'i';
  return 'l';
}


x86 assembly (clang, -O0):
<cl_write_netlog_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     1152 <cl_write_netlog_format+0x32>
movl   $0x73,-0x4(%rbp)
jmp    11ec <cl_write_netlog_format+0xcc>
jmp    1157 <cl_write_netlog_format+0x37>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c5 <cl_write_netlog_format+0xa5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isascii@plt>
cmp    $0x0,%eax
je     118f <cl_write_netlog_format+0x6f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119b <cl_write_netlog_format+0x7b>
movl   $0x73,-0x4(%rbp)
jmp    11ec <cl_write_netlog_format+0xcc>
imul   $0xa,-0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <cl_write_netlog_format+0x37>
movabs $0x100000000,%rax
cmp    %rax,-0x20(%rbp)
jae    11e5 <cl_write_netlog_format+0xc5>
movl   $0x69,-0x4(%rbp)
jmp    11ec <cl_write_netlog_format+0xcc>
movl   $0x6c,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_write_netlog_format>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x73,%r14d
cmp    %rsi,%rdi
jae    118e <cl_write_netlog_format+0x6e>
mov    %rsi,%r15
mov    %rdi,%r12
sub    %rdi,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
movsbl (%r12,%rbx,1),%edi
call   1040 <isascii@plt>
test   %eax,%eax
je     118e <cl_write_netlog_format+0x6e>
movsbl (%r12,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     118e <cl_write_netlog_format+0x6e>
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
movsbq (%r12,%rbx,1),%rcx
lea    (%rcx,%rax,2),%rbp
add    $0xffffffffffffffd0,%rbp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <cl_write_netlog_format+0x20>
xor    %eax,%eax
shr    $0x20,%rbp
setne  %al
lea    (%rax,%rax,2),%r14d
add    $0x69,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cl_write_netlog_format(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 0, i64* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = icmp uge i8* %7, %8
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 115, i32* %3
br label %44
11: ; preds = %2
br label %12
12: ; preds = %36, %11
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = icmp ult i8* %13, %14
br i1 %15, label %16, label %39
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = call i32 @isascii(i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = call i32 @isdigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21, %16
store i32 115, i32* %3
br label %44
27: ; preds = %21
%28 = load i64, i64* %6
%29 = mul nsw i64 %28, 10
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 48
%34 = sext i32 %33 to i64
%35 = add nsw i64 %29, %34
store i64 %35, i64* %6
br label %36
36: ; preds = %27
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
br label %12
39: ; preds = %12
%40 = load i64, i64* %6
%41 = icmp ult i64 %40, 4294967296
br i1 %41, label %42, label %43
42: ; preds = %39
store i32 105, i32* %3
br label %44
43: ; preds = %39
store i32 108, i32* %3
br label %44
44: ; preds = %43, %42, %26, %10
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @cl_write_netlog_format(i8* %0, i8* readnone %1) {
%3 = icmp ult i8* %0, %1
br i1 %3, label %4, label %30
4: ; preds = %2
%5 = ptrtoint i8* %1 to i64
%6 = ptrtoint i8* %0 to i64
%7 = sub i64 %5, %6
%8 = getelementptr i8, i8* %0, i64 %7
br label %9
9: ; preds = %4, %19
%10 = phi i64 [ %24, %19 ], [ 0, %4 ]
%11 = phi i8* [ %25, %19 ], [ %0, %4 ]
%12 = load i8, i8* %11
%13 = tail call i32 @isascii(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %30, label %15
15: ; preds = %9
%16 = load i8, i8* %11
%17 = tail call i32 @isdigit(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %30, label %19
19: ; preds = %15
%20 = mul nsw i64 %10, 10
%21 = load i8, i8* %11
%22 = sext i8 %21 to i64
%23 = add i64 %20, -48
%24 = add i64 %23, %22
%25 = getelementptr inbounds i8, i8* %11, i64 1
%26 = icmp eq i8* %25, %8
br i1 %26, label %27, label %9
27: ; preds = %19
%28 = icmp ult i64 %24, 4294967296
%29 = select i1 %28, i32 105, i32 108
br label %30
30: ; preds = %9, %15, %27, %2
%31 = phi i32 [ 115, %2 ], [ %29, %27 ], [ 115, %15 ], [ 115, %9 ]
ret i32 %31
}