#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 /*<<< 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 if (i == j + 1)
          fprintf(fichier, "%d ", 1);
        else
          fprintf(fichier, "%d ", 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    119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe5a(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12a1 <main+0x141>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe39(%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    1298 <main+0x138>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1285 <main+0x125>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    122d <main+0xcd>
mov    -0x18(%rbp),%rdi
lea    0xde7(%rip),%rsi
xor    %edx,%edx
call   1050 <fprintf@plt>
jmp    1272 <main+0x112>
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1258 <main+0xf8>
mov    -0x18(%rbp),%rdi
lea    0xdbf(%rip),%rsi
mov    $0x1,%edx
call   1050 <fprintf@plt>
jmp    126d <main+0x10d>
mov    -0x18(%rbp),%rdi
lea    0xda5(%rip),%rsi
mov    $0x14,%edx
call   1050 <fprintf@plt>
jmp    1272 <main+0x112>
jmp    1277 <main+0x117>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11fe <main+0x9e>
jmp    128a <main+0x12a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11eb <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    117f <main+0x1f>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
lea    0xe7a(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1229 <main+0xc9>
mov    %rax,%r12
lea    0xe63(%rip),%rsi
mov    %rax,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r15d,%r15d
jle    1221 <main+0xc1>
lea    0xe3c(%rip),%r14
jmp    11d8 <main+0x78>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %r15d,%ebp
je     1221 <main+0xc1>
xor    %ebx,%ebx
jmp    11f5 <main+0x95>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <fprintf@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
je     11d0 <main+0x70>
cmp    %ebx,%ebp
je     11e0 <main+0x80>
add    $0x1,%ebx
mov    %r12,%rdi
mov    %r14,%rsi
cmp    %ebx,%ebp
jne    1210 <main+0xb0>
mov    $0x1,%edx
jmp    1215 <main+0xb5>
nopl   (%rax)
mov    $0x14,%edx
call   1050 <fprintf@plt>
cmp    %r15d,%ebx
jne    11f5 <main+0x95>
jmp    11d0 <main+0x70>
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 %67
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 = %61, %21
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %64
32: ; preds = %28
store i32 0, i32* %9
br label %33
33: ; preds = %57, %32
%34 = load i32, i32* %9
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %60
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 %56
44: ; preds = %37
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
%48 = icmp eq i32 %45, %47
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i32*, i32** %6
%51 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %55
52: ; preds = %44
%53 = load i32*, i32** %6
%54 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 20)
br label %55
55: ; preds = %52, %49
br label %56
56: ; preds = %55, %41
br label %57
57: ; preds = %56
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %33
60: ; preds = %33
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %28
64: ; preds = %28
%65 = load i32*, i32** %6
%66 = call i32 @fclose(i32* %65)
br label %67
67: ; preds = %64, %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 %41, 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 %39
18: ; preds = %12, %36
%19 = phi i32 [ %37, %36 ], [ 0, %12 ]
br label %20
20: ; preds = %18, %33
%21 = phi i32 [ %34, %33 ], [ 0, %18 ]
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 0)
%25 = add nuw nsw i32 %21, 1
br label %33
26: ; preds = %20
%27 = add nuw nsw i32 %21, 1
%28 = icmp eq i32 %19, %27
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %33
31: ; preds = %26
%32 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 20)
br label %33
33: ; preds = %23, %31, %29
%34 = phi i32 [ %25, %23 ], [ %27, %31 ], [ %27, %29 ]
%35 = icmp eq i32 %34, %9
br i1 %35, label %36, label %20
36: ; preds = %33
%37 = add nuw nsw i32 %19, 1
%38 = icmp eq i32 %37, %9
br i1 %38, label %39, label %18
39: ; preds = %36, %12
%40 = tail call i32 @fclose(i32* %10)
br label %41
41: ; preds = %39, %8
ret i32 0
}