#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 strlen(char *);
int check_symbols(char serial_number[12]) {
  int lenght = 0;
  for (int i = 0; i < strlen(serial_number); i++, lenght++) {
    if ((serial_number[i] < '0') || (serial_number[i] > '9')) {
      return 0;
    }
  }
  if (lenght != 10) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_symbols>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1198 <check_symbols+0x88>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1170 <check_symbols+0x60>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    117c <check_symbols+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <check_symbols+0xa5>
jmp    1181 <check_symbols+0x71>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <check_symbols+0x1a>
cmpl   $0xa,-0x14(%rbp)
je     11ae <check_symbols+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <check_symbols+0xa5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_symbols>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
xor    %r14d,%r14d
test   %eax,%eax
jle    1158 <check_symbols+0x48>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%eax
add    $0xc6,%al
cmp    $0xf6,%al
jb     1158 <check_symbols+0x48>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1130 <check_symbols+0x20>
xor    %r14d,%r14d
cmp    $0xa,%ebx
sete   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @check_symbols(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %5
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %34
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 48
br i1 %18, label %27, label %19
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp sgt i32 %25, 57
br i1 %26, label %27, label %28
27: ; preds = %19, %11
store i32 0, i32* %2
br label %39
28: ; preds = %19
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %6
34: ; preds = %6
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %34
store i32 0, i32* %2
br label %39
38: ; preds = %34
store i32 1, i32* %2
br label %39
39: ; preds = %38, %37, %27
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @check_symbols(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %1, %10
%5 = phi i64 [ %11, %10 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = add i8 %7, -58
%9 = icmp ult i8 %8, -10
br i1 %9, label %19, label %10
10: ; preds = %4
%11 = add nuw nsw i64 %5, 1
%12 = tail call i32 @strlen(i8* %0)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %4, label %15
15: ; preds = %10
%16 = trunc i64 %11 to i32
%17 = icmp eq i32 %16, 10
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %4, %1, %15
%20 = phi i32 [ 0, %1 ], [ %18, %15 ], [ 0, %4 ]
ret i32 %20
}