#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 */
unsigned int date_part(unsigned int *, int);
unsigned int not_valid_date(unsigned int, unsigned int);
unsigned int check(unsigned int *egn) {
  unsigned int mul_k[] = {2, 4, 8, 5, 10, 9, 7, 3, 6};
  unsigned int month = date_part(egn, 2);
  unsigned int day = date_part(egn, 4);
  unsigned int not_valid = not_valid_date(month, day);
  unsigned int sum = 0;
  unsigned int i;
  unsigned last = 0;
  if (not_valid) {
    return 0;
  }
  for (i = 0; i < 9; ++i) {
    sum += egn[i] * mul_k[i];
  }
  last = sum % 11;
  if (last == 10) {
    last = 0;
  }
  return (last == egn[9]);
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1040 <date_part@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <date_part@plt>
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1030 <not_valid_date@plt>
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     11a5 <check+0x75>
movl   $0x0,-0x4(%rbp)
jmp    1211 <check+0xe1>
movl   $0x0,-0x54(%rbp)
cmpl   $0x9,-0x54(%rbp)
jae    11dc <check+0xac>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    -0x54(%rbp),%ecx
imul   -0x40(%rbp,%rcx,4),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ac <check+0x7c>
mov    -0x50(%rbp),%eax
mov    $0xb,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x58(%rbp)
cmpl   $0xa,-0x58(%rbp)
jne    11fc <check+0xcc>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x24(%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2,%esi
call   1040 <date_part@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <date_part@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <not_valid_date@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    11de <check+0xbe>
mov    (%rbx),%eax
mov    0x4(%rbx),%ecx
add    %eax,%eax
lea    (%rax,%rcx,4),%eax
mov    0x8(%rbx),%ecx
lea    (%rax,%rcx,8),%eax
mov    0xc(%rbx),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    0x10(%rbx),%edx
lea    (%rdx,%rdx,4),%edx
movdqu 0x14(%rbx),%xmm0
movdqa 0xe83(%rip),%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq 0xe7d(%rip),%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
lea    (%rsi,%rdx,2),%edx
add    %ecx,%edx
add    %eax,%edx
mov    $0xba2e8ba3,%eax
imul   %rdx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
sub    %eax,%edx
xor    %ecx,%ecx
cmp    $0xa,%edx
cmovne %edx,%ecx
xor    %eax,%eax
cmp    0x24(%rbx),%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.check.mul_k = [9 x i32] [i32 2, i32 4, i32 8, i32 5, i32 10, i32 9, i32 7, i32 3, i32 6]
define i32 @check(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [9 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
%11 = bitcast [9 x i32]* %4 to i8*
%12 = load i32*, i32** %3
%13 = call i32 @date_part(i32* %12, i32 2)
store i32 %13, i32* %5
%14 = load i32*, i32** %3
%15 = call i32 @date_part(i32* %14, i32 4)
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = call i32 @not_valid_date(i32 %16, i32 %17)
store i32 %18, i32* %7
store i32 0, i32* %8
store i32 0, i32* %10
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %1
store i32 0, i32* %2
br label %55
22: ; preds = %1
store i32 0, i32* %9
br label %23
23: ; preds = %39, %22
%24 = load i32, i32* %9
%25 = icmp ult i32 %24, 9
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = load i32*, i32** %3
%28 = load i32, i32* %9
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %9
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = mul i32 %31, %35
%37 = load i32, i32* %8
%38 = add i32 %37, %36
store i32 %38, i32* %8
br label %39
39: ; preds = %26
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %23
42: ; preds = %23
%43 = load i32, i32* %8
%44 = urem i32 %43, 11
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 0, i32* %10
br label %48
48: ; preds = %47, %42
%49 = load i32, i32* %10
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i32, i32* %50, i64 9
%52 = load i32, i32* %51
%53 = icmp eq i32 %49, %52
%54 = zext i1 %53 to i32
store i32 %54, i32* %2
br label %55
55: ; preds = %48, %21
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
define i32 @check(i32* %0) {
%2 = tail call i32 @date_part(i32* %0, i32 2)
%3 = tail call i32 @date_part(i32* %0, i32 4)
%4 = tail call i32 @not_valid_date(i32 %2, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %38
6: ; preds = %1
%7 = load i32, i32* %0
%8 = shl i32 %7, 1
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = shl i32 %10, 2
%12 = add i32 %11, %8
%13 = getelementptr inbounds i32, i32* %0, i64 2
%14 = load i32, i32* %13
%15 = shl i32 %14, 3
%16 = add i32 %15, %12
%17 = getelementptr inbounds i32, i32* %0, i64 3
%18 = load i32, i32* %17
%19 = mul i32 %18, 5
%20 = getelementptr inbounds i32, i32* %0, i64 4
%21 = load i32, i32* %20
%22 = mul i32 %21, 10
%23 = getelementptr inbounds i32, i32* %0, i64 5
%24 = bitcast i32* %23 to <4 x i32>*
%25 = load <4 x i32>, <4 x i32>* %24
%26 = mul <4 x i32> %25, <i32 9, i32 7, i32 3, i32 6>
%27 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %26)
%28 = add i32 %27, %22
%29 = add i32 %28, %19
%30 = add i32 %29, %16
%31 = urem i32 %30, 11
%32 = icmp eq i32 %31, 10
%33 = select i1 %32, i32 0, i32 %31
%34 = getelementptr inbounds i32, i32* %0, i64 9
%35 = load i32, i32* %34
%36 = icmp eq i32 %33, %35
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %1, %6
%39 = phi i32 [ %37, %6 ], [ 0, %1 ]
ret i32 %39
}