#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int rand();
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fichier = NULL;
  int nb_elements = 2048;
  if (argc == 2) {
    nb_elements = atoi(argv[1]);
  }
  fichier = fopen("graph", "w");
  if (fichier != NULL) {
    fprintf(fichier, "%d ", nb_elements);
    srand((int)time(NULL));
    int i, j;
    for (i = 0; i < nb_elements; i++) {
      for (j = 0; j < nb_elements; j++) {
        if (i == j)
          fprintf(fichier, "%d ", 0);
        else
          fprintf(fichier, "%d ", rand() % 20);
      }
    }
    fclose(fichier);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x800,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11af <main+0x3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe4a(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1293 <main+0x123>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    128a <main+0x11a>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1277 <main+0x107>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    123d <main+0xcd>
mov    -0x18(%rbp),%rdi
lea    0xdd7(%rip),%rsi
xor    %edx,%edx
call   1050 <fprintf@plt>
jmp    1264 <main+0xf4>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    $0x14,%ecx
cltd
idiv   %ecx
lea    0xda9(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1269 <main+0xf9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <main+0x9e>
jmp    127c <main+0x10c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11fb <main+0x8b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x800,%r15d
cmp    $0x2,%edi
jne    118f <main+0x1f>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
lea    0xe6a(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     123c <main+0xcc>
mov    %rax,%r12
lea    0xe53(%rip),%rsi
mov    %rax,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r15d,%r15d
jle    1234 <main+0xc4>
lea    0xe2e(%rip),%r14
xor    %ebp,%ebp
jmp    11e8 <main+0x78>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %r15d,%ebp
je     1234 <main+0xc4>
xor    %ebx,%ebx
jmp    1203 <main+0x93>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
add    $0x1,%ebx
cmp    %ebx,%r15d
je     11e0 <main+0x70>
mov    $0x0,%edx
cmp    %ebx,%ebp
je     11f0 <main+0x80>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
jmp    11f0 <main+0x80>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"graph\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d \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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 2048, i32* %7
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
br label %17
17: ; preds = %12, %2
%18 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %60
21: ; preds = %17
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i64 @time(i32* null)
%26 = trunc i64 %25 to i32
%27 = call i32 @srand(i32 %26)
store i32 0, i32* %8
br label %28
28: ; preds = %54, %21
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %57
32: ; preds = %28
store i32 0, i32* %9
br label %33
33: ; preds = %50, %32
%34 = load i32, i32* %9
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %53
37: ; preds = %33
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32*, i32** %6
%43 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %49
44: ; preds = %37
%45 = load i32*, i32** %6
%46 = call i32 (...) @rand()
%47 = srem i32 %46, 20
%48 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %44, %41
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %33
53: ; preds = %33
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %28
57: ; preds = %28
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %57, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"graph\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 2048, %2 ]
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %36, label %12
12: ; preds = %8
%13 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%14 = tail call i64 @time(i32* null)
%15 = trunc i64 %14 to i32
%16 = tail call i32 @srand(i32 %15)
%17 = icmp sgt i32 %9, 0
br i1 %17, label %18, label %34
18: ; preds = %12, %31
%19 = phi i32 [ %32, %31 ], [ 0, %12 ]
br label %20
20: ; preds = %18, %26
%21 = phi i32 [ %29, %26 ], [ 0, %18 ]
%22 = icmp eq i32 %19, %21
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 20
br label %26
26: ; preds = %20, %23
%27 = phi i32 [ %25, %23 ], [ 0, %20 ]
%28 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i32 %21, 1
%30 = icmp eq i32 %29, %9
br i1 %30, label %31, label %20
31: ; preds = %26
%32 = add nuw nsw i32 %19, 1
%33 = icmp eq i32 %32, %9
br i1 %33, label %34, label %18
34: ; preds = %31, %12
%35 = tail call i32 @fclose(i32* %10)
br label %36
36: ; preds = %34, %8
ret i32 0
}