#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 checkDigit(char const *, int);
int getCheckDigit(char const *);
scalar_t__ hasAlpha(char const *);
scalar_t__ isSingleDigit(char const *);
int strlen(char const *);
int cpfIsValid(const char *cpf) {
  int ckDigit, calculatedCkDigit;
  if (cpf == NULL) {
    return 0;
  }
  if (strlen(cpf) != 11) {
    return 0;
  }
  if (hasAlpha(cpf)) {
    return 0;
  }
  if (isSingleDigit(cpf)) {
    return 0;
  }
  ckDigit = getCheckDigit(cpf);
  calculatedCkDigit = checkDigit(cpf, 10) * 10 + checkDigit(cpf, 11);
  return (ckDigit == calculatedCkDigit);
}


x86 assembly (clang, -O0):
<cpfIsValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <cpfIsValid+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1218 <cpfIsValid+0xc8>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
je     1191 <cpfIsValid+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1218 <cpfIsValid+0xc8>
mov    -0x10(%rbp),%rdi
call   1060 <hasAlpha@plt>
cmp    $0x0,%rax
je     11b0 <cpfIsValid+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1218 <cpfIsValid+0xc8>
mov    -0x10(%rbp),%rdi
call   1070 <isSingleDigit@plt>
cmp    $0x0,%rax
je     11cf <cpfIsValid+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1218 <cpfIsValid+0xc8>
mov    -0x10(%rbp),%rdi
call   1030 <getCheckDigit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <checkDigit@plt>
imul   $0xa,%eax,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xb,%esi
call   1050 <checkDigit@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %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):
<cpfIsValid>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     11b6 <cpfIsValid+0x66>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0xb,%eax
jne    11b6 <cpfIsValid+0x66>
mov    %rbx,%rdi
call   1060 <hasAlpha@plt>
test   %rax,%rax
jne    11b6 <cpfIsValid+0x66>
mov    %rbx,%rdi
call   1070 <isSingleDigit@plt>
test   %rax,%rax
jne    11b6 <cpfIsValid+0x66>
mov    %rbx,%rdi
call   1030 <getCheckDigit@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <checkDigit@plt>
lea    (%rax,%rax,4),%ebp
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <checkDigit@plt>
lea    (%rax,%rbp,2),%eax
xor    %ebp,%ebp
cmp    %eax,%r14d
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cpfIsValid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %37
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp ne i32 %11, 11
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 0, i32* %2
br label %37
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i64 @hasAlpha(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %2
br label %37
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = call i64 @isSingleDigit(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 0, i32* %2
br label %37
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = call i32 @getCheckDigit(i8* %25)
store i32 %26, i32* %4
%27 = load i8*, i8** %3
%28 = call i32 @checkDigit(i8* %27, i32 10)
%29 = mul nsw i32 %28, 10
%30 = load i8*, i8** %3
%31 = call i32 @checkDigit(i8* %30, i32 11)
%32 = add nsw i32 %29, %31
store i32 %32, i32* %5
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = icmp eq i32 %33, %34
%36 = zext i1 %35 to i32
store i32 %36, i32* %2
br label %37
37: ; preds = %24, %23, %18, %13, %8
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
define i32 @cpfIsValid(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 11
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = tail call i64 @hasAlpha(i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = tail call i64 @isSingleDigit(i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = tail call i32 @getCheckDigit(i8* %0)
%14 = tail call i32 @checkDigit(i8* %0, i32 10)
%15 = mul nsw i32 %14, 10
%16 = tail call i32 @checkDigit(i8* %0, i32 11)
%17 = add nsw i32 %15, %16
%18 = icmp eq i32 %13, %17
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %9, %6, %3, %1, %12
%21 = phi i32 [ %19, %12 ], [ 0, %1 ], [ 0, %3 ], [ 0, %6 ], [ 0, %9 ]
ret i32 %21
}