#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 */
char EOF;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ conv(char);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int count[255];
  int i = 0;
  for (i = 0; i < 255; i++)
    count[i] = 0;
  char c;
  int fd[2];
  pipe(fd);
  if (!fork()) {
    close(fd[0]);
    fprintf(stdout, "Saisissez des caractères, terminez par Ctrl+D.\n");
    while ((c = getchar()) != EOF) {
      write(fd[1], &c, 1);
    }
    close(fd[1]);
    wait(NULL);
  } else {
    close(fd[1]);
    while (read(fd[0], &c, sizeof(char))) {
      putchar(conv(c));
      count[c]++;
    }
    for (i = 34; i < 128; i++) {
      printf("count[%c]=%i\n", i, count[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0xff,-0x414(%rbp)
jge    1213 <main+0x63>
movslq -0x414(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11dd <main+0x2d>
lea    -0x420(%rbp),%rdi
call   1080 <pipe@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
cmp    $0x0,%eax
jne    12a6 <main+0xf6>
mov    -0x420(%rbp),%edi
call   1070 <close@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    %al,-0x415(%rbp)
movsbl %al,%eax
mov    0x2d82(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     128d <main+0xdd>
mov    -0x41c(%rbp),%edi
lea    -0x415(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    124f <main+0x9f>
mov    -0x41c(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <wait@plt>
jmp    1356 <main+0x1a6>
mov    -0x41c(%rbp),%edi
call   1070 <close@plt>
mov    -0x420(%rbp),%edi
lea    -0x415(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x0,%rax
je     1303 <main+0x153>
movsbl -0x415(%rbp),%edi
call   1050 <conv@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
movsbq -0x415(%rbp),%rax
ff
mov    -0x410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    12b1 <main+0x101>
movl   $0x22,-0x414(%rbp)
cmpl   $0x80,-0x414(%rbp)
jge    1351 <main+0x1a1>
mov    -0x414(%rbp),%esi
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%edx
lea    0xcf9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    130d <main+0x15d>
jmp    1356 <main+0x1a6>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
lea    0x10(%rsp),%rdi
mov    $0x3fc,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0x8(%rsp),%rdi
call   1090 <pipe@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     127d <main+0xbd>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
test   %rax,%rax
je     124f <main+0x8f>
lea    0x7(%rsp),%r14
nopw   0x0(%rax,%rax,1)
movsbq 0x7(%rsp),%rbx
mov    %ebx,%edi
call   1050 <conv@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
addl   $0x1,0x10(%rsp,%rbx,4)
mov    0x8(%rsp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
test   %rax,%rax
jne    1220 <main+0x60>
mov    $0x22,%ebx
lea    0xdd6(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    1260 <main+0xa0>
jmp    12f1 <main+0x131>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
call   10c0 <fprintf@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %al,0x7(%rsp)
mov    0x2d3b(%rip),%r14
cmp    (%r14),%al
je     12e1 <main+0x121>
lea    0x7(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %al,0x7(%rsp)
cmp    (%r14),%al
jne    12c0 <main+0x100>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [49 x i8] c"Saisissez des caract\C3\A8res, terminez par Ctrl+D.\0A\00"
@EOF = global i8 0
@.str.1 = [14 x i8] c"count[%c]=%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i32]
%7 = alloca i32
%8 = alloca i8
%9 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %7
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 255
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [255 x i32], [255 x i32]* %6, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %10
20: ; preds = %10
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%22 = call i32 @pipe(i32* %21)
%23 = call i32 (...) @fork()
%24 = icmp ne i32 %23, 0
br i1 %24, label %46, label %25
25: ; preds = %20
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* @stdout
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %37, %25
%32 = call signext i8 (...) @getchar()
store i8 %32, i8* %8
%33 = sext i8 %32 to i32
%34 = load i8, i8* @EOF
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %33, %35
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 @write(i32 %39, i8* %8, i32 1)
br label %31
41: ; preds = %31
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%43 = load i32, i32* %42
%44 = call i32 @close(i32 %43)
%45 = call i32 @wait(i32* null)
br label %79
46: ; preds = %20
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
br label %50
50: ; preds = %55, %46
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%52 = load i32, i32* %51
%53 = call i64 @read(i32 %52, i8* %8, i32 1)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i8, i8* %8
%57 = call i32 @conv(i8 signext %56)
%58 = call i32 @putchar(i32 %57)
%59 = load i8, i8* %8
%60 = sext i8 %59 to i64
%61 = getelementptr inbounds [255 x i32], [255 x i32]* %6, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 1
store i32 %63, i32* %61
br label %50
64: ; preds = %50
store i32 34, i32* %7
br label %65
65: ; preds = %75, %64
%66 = load i32, i32* %7
%67 = icmp slt i32 %66, 128
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = load i32, i32* %7
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [255 x i32], [255 x i32]* %6, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %69, i32 %73)
br label %75
75: ; preds = %68
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %65
78: ; preds = %65
br label %79
79: ; preds = %78, %41
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [49 x i8] c"Saisissez des caract\C3\A8res, terminez par Ctrl+D.\0A\00"
@EOF = global i8 0
@.str.1 = [14 x i8] c"count[%c]=%i\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [255 x i32]
%4 = bitcast [255 x i32]* %3 to i8*
%5 = alloca i8
%6 = alloca [2 x i32]
%7 = bitcast [2 x i32]* %6 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%9 = call i32 @pipe(i32* %8)
%10 = call i32 (...) @fork()
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %2
%13 = load i32, i32* %8
%14 = call i32 @close(i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%17 = call signext i8 (...) @getchar()
store i8 %17, i8* %5
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
br label %22
22: ; preds = %20, %22
%23 = load i32, i32* %21
%24 = call i32 @write(i32 %23, i8* %5, i32 1)
%25 = call signext i8 (...) @getchar()
store i8 %25, i8* %5
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %28, label %22
28: ; preds = %22, %12
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 @close(i32 %30)
%32 = call i32 @wait(i32* null)
br label %60
33: ; preds = %2
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%35 = load i32, i32* %34
%36 = call i32 @close(i32 %35)
%37 = load i32, i32* %8
%38 = call i64 @read(i32 %37, i8* %5, i32 1)
%39 = icmp eq i64 %38, 0
br i1 %39, label %51, label %40
40: ; preds = %33, %40
%41 = load i8, i8* %5
%42 = call i32 @conv(i8 signext %41)
%43 = call i32 @putchar(i32 %42)
%44 = sext i8 %41 to i64
%45 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
%48 = load i32, i32* %8
%49 = call i64 @read(i32 %48, i8* %5, i32 1)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %40
51: ; preds = %40, %33
br label %52
52: ; preds = %51, %52
%53 = phi i64 [ %58, %52 ], [ 34, %51 ]
%54 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = trunc i64 %53 to i32
%57 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %55)
%58 = add nuw nsw i64 %53, 1
%59 = icmp eq i64 %58, 128
br i1 %59, label %60, label %52
60: ; preds = %52, %28
ret i32 0
}