#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 EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int i, rnd, max;
  int vals[10];
  printf("Init tableau.\n");
  for (i = 0; i < 10; ++i) {
    vals[i] = 0;
  }
  max = 1000000;
  printf("Lecture argument si present.\n");
  if (argc == 2) {
    max = atoi(argv[1]);
    printf("%d\n", max);
    if (max <= 0) {
      max = 1000000;
    }
  }
  srand(time(NULL));
  for (i = 0; i < max; ++i) {
    rnd = rand() % 10;
    printf("\r%d%%", i * 100 / max);
    fflush(stdout);
    vals[rnd]++;
  }
  printf("\r");
  for (i = 0; i < 10; ++i) {
    printf("Ecart %d => %d\n", i, vals[i] - (max / 10));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11af <main+0x4f>
movslq -0x14(%rbp),%rax
movl   $0x0,-0x50(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <main+0x2b>
movl   $0xf4240,-0x1c(%rbp)
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1205 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jg     1200 <main+0xa0>
movl   $0xf4240,-0x1c(%rbp)
jmp    1205 <main+0xa5>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    127d <main+0x11d>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
imul   $0x64,-0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
movslq -0x18(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121c <main+0xbc>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    12d6 <main+0x176>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x54(%rbp),%edx
sub    %eax,%edx
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1292 <main+0x132>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe7c(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
mov    $0xf4240,%r12d
cmp    $0x2,%ebp
jne    11f3 <main+0x73>
mov    0x8(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
lea    0xe34(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
mov    $0xf4240,%r12d
cmovg  %ebp,%r12d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xdf8(%rip),%r14
mov    0x2dd1(%rip),%r15
xor    %ebp,%ebp
mov    %r12d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %ebp,%eax
cltd
idiv   %r12d
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%edi
call   1080 <fflush@plt>
movslq %ebx,%rax
addl   $0x1,0x20(%rsp,%rax,4)
add    $0x64,%ebp
add    $0xffffffff,%r13d
jne    1220 <main+0xa0>
movslq %r12d,%rax
imul   $0xffffffff99999999,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
mov    0x20(%rsp),%r14d
add    %ebx,%r14d
mov    0x24(%rsp),%r13d
add    %ebx,%r13d
mov    0x28(%rsp),%r12d
add    %ebx,%r12d
mov    0x2c(%rsp),%r15d
add    %ebx,%r15d
mov    0x30(%rsp),%eax
add    %ebx,%eax
mov    %eax,0xc(%rsp)
mov    0x34(%rsp),%eax
add    %ebx,%eax
mov    %eax,0x10(%rsp)
mov    0x38(%rsp),%eax
add    %ebx,%eax
mov    %eax,0x14(%rsp)
mov    0x3c(%rsp),%eax
add    %ebx,%eax
mov    %eax,0x18(%rsp)
mov    0x40(%rsp),%eax
add    %ebx,%eax
mov    %eax,0x1c(%rsp)
add    0x44(%rsp),%ebx
mov    $0xd,%edi
call   1030 <putchar@plt>
lea    0xd18(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x5,%esi
mov    0x10(%rsp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x7,%esi
mov    0x18(%rsp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
mov    0x1c(%rsp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    $0x9,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Init tableau.\0A\00"
@.str.1 = [30 x i8] c"Lecture argument si present.\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"\0D%d%%\00"
@stdout = global i32 0
@.str.4 = [2 x i8] c"\0D\00"
@.str.5 = [16 x i8] c"Ecart %d => %d\0A\00"
@EXIT_SUCCESS = global i32 0
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 [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %18, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %16
store i32 0, i32* %17
br label %18
18: ; preds = %14
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %11
21: ; preds = %11
store i32 1000000, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %8
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %25
store i32 1000000, i32* %8
br label %35
35: ; preds = %34, %25
br label %36
36: ; preds = %35, %21
%37 = call i32 @time(i32* null)
%38 = call i32 @srand(i32 %37)
store i32 0, i32* %6
br label %39
39: ; preds = %58, %36
%40 = load i32, i32* %6
%41 = load i32, i32* %8
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %61
43: ; preds = %39
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 10
store i32 %45, i32* %7
%46 = load i32, i32* %6
%47 = mul nsw i32 %46, 100
%48 = load i32, i32* %8
%49 = sdiv i32 %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @stdout
%52 = call i32 @fflush(i32 %51)
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
store i32 %57, i32* %55
br label %58
58: ; preds = %43
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %39
61: ; preds = %39
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %63
63: ; preds = %76, %61
%64 = load i32, i32* %6
%65 = icmp slt i32 %64, 10
br i1 %65, label %66, label %79
66: ; preds = %63
%67 = load i32, i32* %6
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [10 x i32], [10 x i32]* %9, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = load i32, i32* %8
%73 = sdiv i32 %72, 10
%74 = sub nsw i32 %71, %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %67, i32 %74)
br label %76
76: ; preds = %66
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %63
79: ; preds = %63
%80 = load i32, i32* @EXIT_SUCCESS
ret i32 %80
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"\0D%d%%\00"
@stdout = global i32 0
@.str.5 = [16 x i8] c"Ecart %d => %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [14 x i8] c"Init tableau.\00"
@str.6 = [29 x i8] c"Lecture argument si present.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = icmp slt i32 %11, 1
%14 = select i1 %13, i32 1000000, i32 %11
br label %15
15: ; preds = %2, %8
%16 = phi i32 [ %14, %8 ], [ 1000000, %2 ]
%17 = tail call i32 @time(i32* null)
%18 = tail call i32 @srand(i32 %17)
br label %19
19: ; preds = %15, %19
%20 = phi i32 [ %32, %19 ], [ 0, %15 ]
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 10
%23 = mul nsw i32 %20, 100
%24 = sdiv i32 %23, %16
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @stdout
%27 = tail call i32 @fflush(i32 %26)
%28 = sext i32 %22 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = add nuw nsw i32 %20, 1
%33 = icmp eq i32 %32, %16
br i1 %33, label %34, label %19
34: ; preds = %19
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%36 = load i32, i32* %35
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
%40 = load i32, i32* %39
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
%42 = load i32, i32* %41
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
%44 = load i32, i32* %43
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
%46 = load i32, i32* %45
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
%48 = load i32, i32* %47
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
%50 = load i32, i32* %49
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
%52 = load i32, i32* %51
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
%54 = load i32, i32* %53
%55 = tail call i32 @putchar(i32 13)
%56 = sdiv i32 %16, -10
%57 = add i32 %36, %56
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 %57)
%59 = add i32 %38, %56
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 %59)
%61 = add i32 %40, %56
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 2, i32 %61)
%63 = add i32 %42, %56
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 %63)
%65 = add i32 %44, %56
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 %65)
%67 = add i32 %46, %56
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 5, i32 %67)
%69 = add i32 %48, %56
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 6, i32 %69)
%71 = add i32 %50, %56
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 7, i32 %71)
%73 = add i32 %52, %56
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 8, i32 %73)
%75 = add i32 %54, %56
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 9, i32 %75)
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}