#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*/ isdigit(char);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int checkNumberCorrectness(char *number) {
  if (strlen(number) > 13 - 1)
    return 0;
  for (int i = 0; i < strlen(number); i++) {
    if (number[i] == '-' || !isdigit(number[i])) {
      puts("The phone number is invalid.");
      return 0;
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<checkNumberCorrectness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xc,%eax
jle    115a <checkNumberCorrectness+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11cb <checkNumberCorrectness+0x9b>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11cb <checkNumberCorrectness+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11ac <checkNumberCorrectness+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11c4 <checkNumberCorrectness+0x94>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cb <checkNumberCorrectness+0x9b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkNumberCorrectness>:
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xc,%ecx
jg     1167 <checkNumberCorrectness+0x37>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1179 <checkNumberCorrectness+0x49>
mov    (%rbx),%al
cmp    $0x2d,%al
je     1169 <checkNumberCorrectness+0x39>
movsbl %al,%edi
call   1030 <isdigit@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     1169 <checkNumberCorrectness+0x39>
pop    %rbx
ret
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"The phone number is invalid.\00"
define i32 @checkNumberCorrectness(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp sgt i32 %6, 12
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %37
9: ; preds = %1
store i32 0, i32* %4
br label %10
10: ; preds = %34, %9
%11 = load i32, i32* %4
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 45
br i1 %22, label %31, label %23
23: ; preds = %15
%24 = load i8*, i8** %3
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @isdigit(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %23, %15
%32 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %37
33: ; preds = %23
store i32 1, i32* %2
br label %37
34: ; No predecessors!
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %10
37: ; preds = %8, %31, %33, %10
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [29 x i8] c"The phone number is invalid.\00"
define i32 @checkNumberCorrectness(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 12
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 45
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @isdigit(i8 signext %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4, %10, %1
%16 = phi i32 [ 0, %1 ], [ 0, %13 ], [ undef, %4 ], [ 1, %10 ]
ret i32 %16
}