#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 FirstDigit(int);
int GetNumbers(int *, int);
int /*<<< orphan*/ InitializeList(int *, int);
int SecondDigit(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int n = 0;
  int firstDigit, secondDigit;
  int isNotCorrect = 1;
  while (isNotCorrect) {
    printf("Ingresa el número n: ");
    scanf("%d", &n);
    if (n < 0)
      printf("El número no es válido. Vuelve a intentarlo.\n\n");
    else
      isNotCorrect = 0;
  }
  if (n > 0) {
    int list[n];
    InitializeList(list, n);
    firstDigit = GetNumbers(list, n);
    firstDigit = FirstDigit(firstDigit);
    secondDigit = SecondDigit(list, n);
    printf("\nEl último digito diferente de 0 del factorial de %d es: %d\n", n,
           (firstDigit * secondDigit) % 10);
  } else
    printf("\nEl último digito diferente de 0 del factorial de 0 es: 1\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11d5 <main+0x75>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    11c9 <main+0x69>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <main+0x70>
movl   $0x0,-0x20(%rbp)
jmp    1184 <main+0x24>
cmpl   $0x0,-0x14(%rbp)
jle    1263 <main+0x103>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%esi
call   1040 <InitializeList@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <GetNumbers@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <FirstDigit@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
call   1080 <SecondDigit@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
jmp    1271 <main+0x111>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,-0x24(%rbp)
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
jns    11f3 <main+0x83>
lea    0xee2(%rip),%r14
lea    0xe48(%rip),%r15
lea    0xe58(%rip),%r12
lea    -0x24(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
js     11d0 <main+0x60>
mov    -0x24(%rbp),%eax
test   %eax,%eax
jle    1275 <main+0x105>
mov    %rsp,%r15
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x24(%rbp),%esi
mov    %rbx,%rdi
call   1050 <InitializeList@plt>
mov    -0x24(%rbp),%esi
mov    %rbx,%rdi
call   1060 <GetNumbers@plt>
mov    %eax,%edi
call   1080 <FirstDigit@plt>
mov    %eax,%r14d
mov    -0x24(%rbp),%esi
mov    %rbx,%rdi
call   1090 <SecondDigit@plt>
mov    -0x24(%rbp),%esi
imul   %r14d,%eax
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rsp
jmp    1281 <main+0x111>
lea    0xddc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Ingresa el n\C3\BAmero n: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"El n\C3\BAmero no es v\C3\A1lido. Vuelve a intentarlo.\0A\0A\00"
@.str.3 = [62 x i8] c"\0AEl \C3\BAltimo digito diferente de 0 del factorial de %d es: %d\0A\00"
@.str.4 = [60 x i8] c"\0AEl \C3\BAltimo digito diferente de 0 del factorial de 0 es: 1\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %9
br label %12
12: ; preds = %23, %2
%13 = load i32, i32* %9
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %23
22: ; preds = %15
store i32 0, i32* %9
br label %23
23: ; preds = %22, %20
br label %12
24: ; preds = %12
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = load i32, i32* %6
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %10
%31 = alloca i32, i64 %29
store i64 %29, i64* %11
%32 = load i32, i32* %6
%33 = call i32 @InitializeList(i32* %31, i32 %32)
%34 = load i32, i32* %6
%35 = call i32 @GetNumbers(i32* %31, i32 %34)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = call i32 @FirstDigit(i32 %36)
store i32 %37, i32* %7
%38 = load i32, i32* %6
%39 = call i32 @SecondDigit(i32* %31, i32 %38)
store i32 %39, i32* %8
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = mul nsw i32 %41, %42
%44 = srem i32 %43, 10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %44)
%46 = load i8*, i8** %10
br label %49
47: ; preds = %24
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Ingresa el n\C3\BAmero n: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [62 x i8] c"\0AEl \C3\BAltimo digito diferente de 0 del factorial de %d es: %d\0A\00"
@str = [59 x i8] c"\0AEl \C3\BAltimo digito diferente de 0 del factorial de 0 es: 1\00"
@str.5 = [48 x i8] c"El n\C3\BAmero no es v\C3\A1lido. Vuelve a intentarlo.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %2
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = zext i32 %16 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i32, i64 %19
%22 = load i32, i32* %3
%23 = call i32 @InitializeList(i32* %21, i32 %22)
%24 = load i32, i32* %3
%25 = call i32 @GetNumbers(i32* %21, i32 %24)
%26 = call i32 @FirstDigit(i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @SecondDigit(i32* %21, i32 %27)
%29 = load i32, i32* %3
%30 = mul nsw i32 %28, %26
%31 = srem i32 %30, 10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %31)
br label %35
33: ; preds = %15
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %33, %18
ret i32 0
}