#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*/ EXIT_FAILURE;
int /*<<< orphan*/ convert(int, int, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int year;
  int n1000, n100, n10, n1;
  printf("\nEnter the year (4 digits): ");
  scanf("%d", &year);
  if (year > 9999 || year < 1000) {
    printf("\nError !! The year must contain 4 digits.");
    exit(EXIT_FAILURE);
  }
  n1000 = year / 1000;
  n100 = ((year) % 1000) / 100;
  n10 = (year % 100) / 10;
  n1 = ((year % 10) % 10);
  convert(n1000, n100, n10, n1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x270f,-0x8(%rbp)
jg     1185 <main+0x45>
cmpl   $0x3e8,-0x8(%rbp)
jge    119f <main+0x5f>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <convert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r8d
lea    -0x2710(%r8),%ecx
cmp    $0xffffdcd7,%ecx
jbe    11dd <main+0x9d>
movzwl %r8w,%ecx
mov    %ecx,%edx
shr    $0x3,%edx
imul   $0x20c5,%edx,%edi
shr    $0x14,%edi
imul   $0x3e8,%edi,%edx
mov    %r8d,%esi
sub    %edx,%esi
movzwl %si,%edx
shr    $0x2,%edx
imul   $0x147b,%edx,%esi
shr    $0x11,%esi
imul   $0xcccd,%ecx,%eax
shr    $0x2,%ecx
imul   $0x147b,%ecx,%ecx
shr    $0x11,%ecx
imul   $0x64,%ecx,%ecx
mov    %r8d,%edx
sub    %ecx,%edx
imul   $0xcd,%edx,%ecx
movzwl %cx,%edx
shr    $0xb,%edx
shr    $0x12,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r8d
movzwl %r8w,%ecx
call   1030 <convert@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"\0AEnter the year (4 digits): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"\0AError !! The year must contain 4 digits.\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 9999
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %18
14: ; preds = %11, %0
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 1000
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = srem i32 %21, 1000
%23 = sdiv i32 %22, 100
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = srem i32 %24, 100
%26 = sdiv i32 %25, 10
store i32 %26, i32* %5
%27 = load i32, i32* %2
%28 = srem i32 %27, 10
%29 = srem i32 %28, 10
store i32 %29, i32* %6
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = call i32 @convert(i32 %30, i32 %31, i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0AEnter the year (4 digits): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"\0AError !! The year must contain 4 digits.\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add i32 %5, -10000
%7 = icmp ult i32 %6, -9000
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = trunc i32 %5 to i16
%14 = udiv i16 %13, 1000
%15 = zext i16 %14 to i32
%16 = urem i16 %13, 1000
%17 = udiv i16 %16, 100
%18 = zext i16 %17 to i32
%19 = urem i16 %13, 100
%20 = trunc i16 %19 to i8
%21 = udiv i8 %20, 10
%22 = zext i8 %21 to i32
%23 = urem i16 %13, 10
%24 = zext i16 %23 to i32
%25 = call i32 @convert(i32 %15, i32 %18, i32 %22, i32 %24)
ret i32 0
}