#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(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fin();
char getchar();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
void saisiChaine(char mot[30]) {
  char ch;
  char index = 0;
  system("stty -echo raw");
  ;
  memset(mot, 0, 30);
  while ((ch != 10) && (ch != 13)) {
    if (index >= 29)
      ch = 13;
    else {
      ch = getchar();
      if ((ch == 3) || (ch == 4) || (ch == 0x1a) || (ch == 0x1b)) {
        fin();
        exit(0);
      }
      if ((ch == 0x20) || (ch == 0x28) || (ch == 0x29) || (ch == 0x2D) ||
          (ch == 0x2E) || ((ch > 0x60) && (ch < 0x7B)) ||
          ((ch > 0x29) && (ch < 0x39))) {
        printf("%c", ch);
        fflush(stdout);
        mot[index] = ch;
        index = index + 1;
      }
      if ((ch > 0x40) && (ch < 0x5B)) {
        ch = ch + 0x20;
        printf("%c", ch);
        fflush(stdout);
        mot[index] = ch;
        index++;
      }
      if (ch == 127) {
        mot[index] = 0;
        if (index != 0) {
          index = index - 1;
          printf("\b \b");
        }
      }
    }
  }
  mot[index] = 0;
  printf("\n");
  system("stty echo -raw");
  ;
}


x86 assembly (clang, -O0):
<saisiChaine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xa(%rbp)
lea    0xe79(%rip),%rdi
call   1030 <system@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xb(%rbp)
je     11bb <saisiChaine+0x4b>
movsbl -0x9(%rbp),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
test   $0x1,%al
jne    11cb <saisiChaine+0x5b>
jmp    1384 <saisiChaine+0x214>
movsbl -0xa(%rbp),%eax
cmp    $0x1d,%eax
jl     11e1 <saisiChaine+0x71>
movb   $0xd,-0x9(%rbp)
jmp    137f <saisiChaine+0x20f>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x3,%eax
je     121f <saisiChaine+0xaf>
movsbl -0x9(%rbp),%eax
cmp    $0x4,%eax
je     121f <saisiChaine+0xaf>
movsbl -0x9(%rbp),%eax
cmp    $0x1a,%eax
je     121f <saisiChaine+0xaf>
movsbl -0x9(%rbp),%eax
cmp    $0x1b,%eax
jne    122d <saisiChaine+0xbd>
mov    $0x0,%al
call   1080 <fin@plt>
xor    %edi,%edi
call   1090 <exit@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
je     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x28,%eax
je     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x29,%eax
je     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x2d,%eax
je     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x2e,%eax
je     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x60,%eax
jle    1288 <saisiChaine+0x118>
movsbl -0x9(%rbp),%eax
cmp    $0x7b,%eax
jl     12a2 <saisiChaine+0x132>
movsbl -0x9(%rbp),%eax
cmp    $0x29,%eax
jle    12db <saisiChaine+0x16b>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
jge    12db <saisiChaine+0x16b>
movsbl -0x9(%rbp),%esi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
movsbq -0xa(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsbl -0xa(%rbp),%eax
add    $0x1,%eax
mov    %al,-0xa(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x40,%eax
jle    1336 <saisiChaine+0x1c6>
movsbl -0x9(%rbp),%eax
cmp    $0x5b,%eax
jge    1336 <saisiChaine+0x1c6>
movsbl -0x9(%rbp),%eax
add    $0x20,%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%esi
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
movsbq -0xa(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jne    137a <saisiChaine+0x20a>
mov    -0x8(%rbp),%rax
movsbq -0xa(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0xa(%rbp),%eax
cmp    $0x0,%eax
je     1375 <saisiChaine+0x205>
movsbl -0xa(%rbp),%eax
sub    $0x1,%eax
mov    %al,-0xa(%rbp)
lea    0xca4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    137a <saisiChaine+0x20a>
jmp    137f <saisiChaine+0x20f>
jmp    119c <saisiChaine+0x2c>
mov    -0x8(%rbp),%rax
movsbq -0xa(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xc7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc72(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saisiChaine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xe6b(%rip),%rdi
call   1040 <system@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
mov    0x2e30(%rip),%r12
movabs $0x630100000000,%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
cmp    $0xa,%bl
je     12aa <saisiChaine+0x12a>
cmp    $0xd,%bl
je     12aa <saisiChaine+0x12a>
mov    $0xd,%bl
cmp    $0x1c,%bpl
jg     11c0 <saisiChaine+0x40>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%ebx
cmp    $0x2e,%al
ja     128f <saisiChaine+0x10f>
movzbl %bl,%eax
bt     %rax,%r13
jae    1284 <saisiChaine+0x104>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    (%r12),%edi
call   1080 <fflush@plt>
movsbq %bpl,%rax
mov    %bl,(%r15,%rax,1)
add    $0x1,%bpl
mov    %ebp,%r14d
lea    -0x41(%rbx),%eax
cmp    $0x19,%al
ja     1249 <saisiChaine+0xc9>
add    $0x20,%bl
movzbl %bl,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    (%r12),%edi
call   1080 <fflush@plt>
movsbq %r14b,%rax
mov    %bpl,(%r15,%rax,1)
add    $0x1,%r14b
mov    %r14d,%ebp
jmp    11c0 <saisiChaine+0x40>
mov    %r14d,%ebp
cmp    $0x7f,%bl
jne    11c0 <saisiChaine+0x40>
movsbq %r14b,%rax
movb   $0x0,(%r15,%rax,1)
mov    $0x7f,%bl
xor    %ebp,%ebp
test   %al,%al
je     11c0 <saisiChaine+0x40>
add    $0xff,%r14b
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%ebp
jmp    11c0 <saisiChaine+0x40>
mov    $0xc000018,%ecx
bt     %rax,%rcx
jb     12d7 <saisiChaine+0x157>
lea    -0x61(%rbx),%eax
cmp    $0x1a,%al
jb     11f8 <saisiChaine+0x78>
lea    -0x2a(%rbx),%eax
cmp    $0xe,%al
ja     1215 <saisiChaine+0x95>
jmp    11f8 <saisiChaine+0x78>
movsbq %bpl,%rax
movb   $0x0,(%r15,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd4f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <system@plt>
xor    %eax,%eax
call   1090 <fin@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"stty -echo raw\00"
@.str.1 = [3 x i8] c"%c\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"\08 \08\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [15 x i8] c"stty echo -raw\00"
define void @saisiChaine(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %4
%5 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 @memset(i8* %6, i32 0, i32 30)
br label %8
8: ; preds = %139, %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 13
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %140
18: ; preds = %16
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 29
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 13, i8* %3
br label %139
23: ; preds = %18
%24 = call signext i8 (...) @getchar()
store i8 %24, i8* %3
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 3
br i1 %27, label %40, label %28
28: ; preds = %23
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 4
br i1 %31, label %40, label %32
32: ; preds = %28
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 26
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 27
br i1 %39, label %40, label %43
40: ; preds = %36, %32, %28, %23
%41 = call i32 (...) @fin()
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %36
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 32
br i1 %46, label %79, label %47
47: ; preds = %43
%48 = load i8, i8* %3
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 40
br i1 %50, label %79, label %51
51: ; preds = %47
%52 = load i8, i8* %3
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 41
br i1 %54, label %79, label %55
55: ; preds = %51
%56 = load i8, i8* %3
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 45
br i1 %58, label %79, label %59
59: ; preds = %55
%60 = load i8, i8* %3
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 46
br i1 %62, label %79, label %63
63: ; preds = %59
%64 = load i8, i8* %3
%65 = sext i8 %64 to i32
%66 = icmp sgt i32 %65, 96
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = load i8, i8* %3
%69 = sext i8 %68 to i32
%70 = icmp slt i32 %69, 123
br i1 %70, label %79, label %71
71: ; preds = %67, %63
%72 = load i8, i8* %3
%73 = sext i8 %72 to i32
%74 = icmp sgt i32 %73, 41
br i1 %74, label %75, label %94
75: ; preds = %71
%76 = load i8, i8* %3
%77 = sext i8 %76 to i32
%78 = icmp slt i32 %77, 57
br i1 %78, label %79, label %94
79: ; preds = %75, %67, %59, %55, %51, %47, %43
%80 = load i8, i8* %3
%81 = sext i8 %80 to i32
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %81)
%83 = load i32, i32* @stdout
%84 = call i32 @fflush(i32 %83)
%85 = load i8, i8* %3
%86 = load i8*, i8** %2
%87 = load i8, i8* %4
%88 = sext i8 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
store i8 %85, i8* %89
%90 = load i8, i8* %4
%91 = sext i8 %90 to i32
%92 = add nsw i32 %91, 1
%93 = trunc i32 %92 to i8
store i8 %93, i8* %4
br label %94
94: ; preds = %79, %75, %71
%95 = load i8, i8* %3
%96 = sext i8 %95 to i32
%97 = icmp sgt i32 %96, 64
br i1 %97, label %98, label %119
98: ; preds = %94
%99 = load i8, i8* %3
%100 = sext i8 %99 to i32
%101 = icmp slt i32 %100, 91
br i1 %101, label %102, label %119
102: ; preds = %98
%103 = load i8, i8* %3
%104 = sext i8 %103 to i32
%105 = add nsw i32 %104, 32
%106 = trunc i32 %105 to i8
store i8 %106, i8* %3
%107 = load i8, i8* %3
%108 = sext i8 %107 to i32
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %108)
%110 = load i32, i32* @stdout
%111 = call i32 @fflush(i32 %110)
%112 = load i8, i8* %3
%113 = load i8*, i8** %2
%114 = load i8, i8* %4
%115 = sext i8 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
store i8 %112, i8* %116
%117 = load i8, i8* %4
%118 = add i8 %117, 1
store i8 %118, i8* %4
br label %119
119: ; preds = %102, %98, %94
%120 = load i8, i8* %3
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 127
br i1 %122, label %123, label %138
123: ; preds = %119
%124 = load i8*, i8** %2
%125 = load i8, i8* %4
%126 = sext i8 %125 to i64
%127 = getelementptr inbounds i8, i8* %124, i64 %126
store i8 0, i8* %127
%128 = load i8, i8* %4
%129 = sext i8 %128 to i32
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %137
131: ; preds = %123
%132 = load i8, i8* %4
%133 = sext i8 %132 to i32
%134 = sub nsw i32 %133, 1
%135 = trunc i32 %134 to i8
store i8 %135, i8* %4
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %137
137: ; preds = %131, %123
br label %138
138: ; preds = %137, %119
br label %139
139: ; preds = %138, %22
br label %8
140: ; preds = %16
%141 = load i8*, i8** %2
%142 = load i8, i8* %4
%143 = sext i8 %142 to i64
%144 = getelementptr inbounds i8, i8* %141, i64 %143
store i8 0, i8* %144
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%146 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"stty -echo raw\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"\08 \08\00"
@.str.4 = [15 x i8] c"stty echo -raw\00"
define void @saisiChaine(i8* %0) {
%2 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @memset(i8* %0, i32 0, i32 30)
br label %4
4: ; preds = %52, %1
%5 = phi i8 [ undef, %1 ], [ %53, %52 ]
%6 = phi i8 [ 0, %1 ], [ %54, %52 ]
%7 = icmp sgt i8 %6, 28
br label %8
8: ; preds = %4, %10
%9 = phi i8 [ 13, %10 ], [ %5, %4 ]
switch i8 %9, label %10 [
i8 13, label %55
i8 10, label %55
]
10: ; preds = %8
br i1 %7, label %8, label %11
11: ; preds = %10
%12 = tail call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
switch i8 %12, label %17 [
i8 27, label %14
i8 26, label %14
i8 4, label %14
i8 3, label %14
i8 46, label %23
i8 45, label %23
i8 41, label %23
i8 40, label %23
i8 32, label %23
]
14: ; preds = %11, %11, %11, %11
%15 = tail call i32 (...) @fin()
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %11
%18 = add i8 %12, -97
%19 = icmp ult i8 %18, 26
%20 = add i8 %12, -42
%21 = icmp ult i8 %20, 15
%22 = or i1 %19, %21
br i1 %22, label %23, label %30
23: ; preds = %11, %11, %11, %11, %11, %17
%24 = tail call i32 @putchar(i32 %13)
%25 = load i32, i32* @stdout
%26 = tail call i32 @fflush(i32 %25)
%27 = sext i8 %6 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 %12, i8* %28
%29 = add nsw i8 %6, 1
br label %30
30: ; preds = %17, %23
%31 = phi i8 [ %29, %23 ], [ %6, %17 ]
%32 = add i8 %12, -65
%33 = icmp ult i8 %32, 26
br i1 %33, label %34, label %43
34: ; preds = %30
%35 = add nuw nsw i8 %12, 32
%36 = zext i8 %35 to i32
%37 = tail call i32 @putchar(i32 %36)
%38 = load i32, i32* @stdout
%39 = tail call i32 @fflush(i32 %38)
%40 = sext i8 %31 to i64
%41 = getelementptr inbounds i8, i8* %0, i64 %40
store i8 %35, i8* %41
%42 = add nsw i8 %31, 1
br label %52
43: ; preds = %30
%44 = icmp eq i8 %12, 127
br i1 %44, label %45, label %52
45: ; preds = %43
%46 = sext i8 %31 to i64
%47 = getelementptr inbounds i8, i8* %0, i64 %46
store i8 0, i8* %47
%48 = icmp eq i8 %31, 0
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = add i8 %31, -1
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %49, %45, %43, %34
%53 = phi i8 [ %35, %34 ], [ %12, %43 ], [ 127, %45 ], [ 127, %49 ]
%54 = phi i8 [ %42, %34 ], [ %31, %43 ], [ 0, %45 ], [ %50, %49 ]
br label %4
55: ; preds = %8, %8
%56 = sext i8 %6 to i64
%57 = getelementptr inbounds i8, i8* %0, i64 %56
store i8 0, i8* %57
%58 = tail call i32 @putchar(i32 10)
%59 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret void
}