#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*/ printf(char *);
scalar_t__ scanf(char *, char *);
scanfns(char *cadena) {
  char tmp;
  int contador = 0;
  while (scanf("%c", &tmp) > 0 && tmp != ' ' && tmp != '\t' && tmp != '\n') {
    if (contador < 5 - 1) {
      cadena[contador] = tmp;
    } else {
      printf("\a");
    }
    contador++;
  }
  cadena[5 - 1] = '\0';
}


x86 assembly (clang, -O0):
<scanfns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec6(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jle    1186 <scanfns+0x66>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x19(%rbp)
je     1186 <scanfns+0x66>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x19(%rbp)
je     1186 <scanfns+0x66>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1196 <scanfns+0x76>
jmp    11cd <scanfns+0xad>
cmpl   $0x4,-0x18(%rbp)
jge    11b3 <scanfns+0x93>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11bf <scanfns+0x9f>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <scanfns+0x13>
mov    -0x10(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanfns>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r12
lea    0xec9(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
jle    119b <scanfns+0x7b>
xor    %ebx,%ebx
lea    0xeb1(%rip),%r14
lea    0xf(%rsp),%r15
movabs $0x100000600,%r13
jmp    117e <scanfns+0x5e>
mov    $0x7,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
jle    119b <scanfns+0x7b>
movzbl 0xf(%rsp),%eax
cmp    $0x20,%rax
ja     118f <scanfns+0x6f>
bt     %rax,%r13
jb     119b <scanfns+0x7b>
cmp    $0x3,%rbx
ja     1160 <scanfns+0x40>
mov    %al,(%r12,%rbx,1)
jmp    116a <scanfns+0x4a>
movb   $0x0,0x4(%r12)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\07\00"
define i32 @scanfns(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
br label %6
6: ; preds = %34, %1
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 32
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 9
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br label %21
21: ; preds = %17, %13, %9, %6
%22 = phi i1 [ false, %13 ], [ false, %9 ], [ false, %6 ], [ %20, %17 ]
br i1 %22, label %23, label %37
23: ; preds = %21
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i8, i8* %4
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %34
32: ; preds = %23
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %26
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %6
37: ; preds = %21
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 4
store i8 0, i8* %39
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @scanfns(i8* nocapture writeonly %0) {
%2 = alloca i8
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %1, %14
%6 = phi i64 [ %15, %14 ], [ 0, %1 ]
%7 = load i8, i8* %2
switch i8 %7, label %8 [
i8 32, label %18
i8 10, label %18
i8 9, label %18
]
8: ; preds = %5
%9 = icmp ult i64 %6, 4
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %7, i8* %11
br label %14
12: ; preds = %8
%13 = call i32 @putchar(i32 7)
br label %14
14: ; preds = %12, %10
%15 = add nuw i64 %6, 1
%16 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %14, %5, %5, %5, %1
%19 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %19
ret i32 undef
}