#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*/ LogError(char *, char *, ...);
int strlen(char *);
int check_number(char *s, int len) {
  int i;
  int l = strlen(s);
  for (i = 0; i < l; i++) {
    if (s[i] < '0' || s[i] > '9') {
      LogError("Time format error at '%s': unexpected character: '%c'.\n", s,
               s[i]);
      return 0;
    }
  }
  if (l != len) {
    LogError("Time format error: '%s' unexpected.\n", s);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b5 <check_number+0x95>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1178 <check_number+0x58>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    11a2 <check_number+0x82>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <LogError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <check_number+0xc6>
jmp    11a7 <check_number+0x87>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <check_number+0x22>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11df <check_number+0xbf>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <LogError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <check_number+0xc6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_number>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1156 <check_number+0x36>
mov    %eax,%ecx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rsi,1),%edx
lea    -0x3a(%rdx),%edi
cmp    $0xf5,%dil
jbe    1175 <check_number+0x55>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1140 <check_number+0x20>
mov    $0x1,%ebp
cmp    %r14d,%eax
je     1188 <check_number+0x68>
lea    0xed1(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <LogError@plt>
jmp    1188 <check_number+0x68>
lea    0xe84(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <LogError@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Time format error at '%s': unexpected character: '%c'.\0A\00"
@.str.1 = [37 x i8] c"Time format error: '%s' unexpected.\0A\00"
define i32 @check_number(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %7
store i32 0, i32* %6
br label %10
10: ; preds = %40, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %43
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %20, 48
br i1 %21, label %30, label %22
22: ; preds = %14
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %28, 57
br i1 %29, label %30, label %39
30: ; preds = %22, %14
%31 = load i8*, i8** %4
%32 = load i8*, i8** %4
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, i8*, ...) @LogError(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %31, i32 %37)
store i32 0, i32* %3
br label %51
39: ; preds = %22
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %10
43: ; preds = %10
%44 = load i32, i32* %7
%45 = load i32, i32* %5
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i8*, i8** %4
%49 = call i32 (i8*, i8*, ...) @LogError(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %48)
store i32 0, i32* %3
br label %51
50: ; preds = %43
store i32 1, i32* %3
br label %51
51: ; preds = %50, %47, %30
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [56 x i8] c"Time format error at '%s': unexpected character: '%c'.\0A\00"
@.str.1 = [37 x i8] c"Time format error: '%s' unexpected.\0A\00"
define i32 @check_number(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = zext i32 %3 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %15, %6
br i1 %8, label %19, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %15, %7 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = add i8 %12, -58
%14 = icmp ult i8 %13, -10
%15 = add nuw nsw i64 %10, 1
br i1 %14, label %16, label %7
16: ; preds = %9
%17 = sext i8 %12 to i32
%18 = tail call i32 (i8*, i8*, ...) @LogError(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %17)
br label %23
19: ; preds = %7, %2
%20 = icmp eq i32 %3, %1
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = tail call i32 (i8*, i8*, ...) @LogError(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %23
23: ; preds = %19, %21, %16
%24 = phi i32 [ 0, %16 ], [ 0, %21 ], [ 1, %19 ]
ret i32 %24
}