#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 RAND_MAX;
int /*<<< orphan*/ printf(char *, double);
int rand();
int /*<<< orphan*/ sscanf(char *, char *, int *);
int main(int argc, char **argv) {
  char *stringa;
  int i, j, N;
  double s = 0, A[N * N];
  stringa = argv[1];
  sscanf(stringa, "%u", &N);
  printf("%u 	\n", N);
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      A[i + j * N] = 1. * rand() / RAND_MAX;
      s += A[i + j * N];
    }
  }
  printf("%f ", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <sscanf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    124e <main+0x11e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    123b <main+0x10b>
mov    $0x0,%al
call   1050 <rand@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
cvtsi2sd %ecx,%xmm1
movsd  0xe18(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2df5(%rip),%rcx
cvtsi2sdl (%rcx),%xmm1
divsd  %xmm1,%xmm0
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c3 <main+0x93>
jmp    1240 <main+0x110>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <main+0x80>
movsd  -0x30(%rbp),%xmm0
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r14
mov    0x8(%rsi),%rdi
lea    0xeb8(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
cvtsi2sdl 0xc(%rsp),%xmm0
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
xorpd  %xmm0,%xmm0
test   %eax,%eax
jle    11d2 <main+0xa2>
mov    0x2e71(%rip),%rbx
xor    %r15d,%r15d
jmp    1189 <main+0x59>
nopl   0x0(%rax)
add    $0x1,%r15d
cmp    %eax,%r15d
jge    11d2 <main+0xa2>
test   %eax,%eax
jle    1180 <main+0x50>
xor    %ebp,%ebp
nop
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%rbx),%xmm1
divsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
add    $0x1,%ebp
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
jl     1190 <main+0x60>
jmp    1180 <main+0x50>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [6 x i8] c"%u \09\0A\00"
@RAND_MAX = global i32 0
@.str.2 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i8*
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %10
%13 = load i32, i32* %9
%14 = load i32, i32* %9
%15 = mul nsw i32 %13, %14
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %11
%18 = alloca double, i64 %16
store i64 %16, i64* %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%24 = load i32, i32* %9
%25 = sitofp i32 %24 to double
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %25)
store i32 0, i32* %7
br label %27
27: ; preds = %64, %2
%28 = load i32, i32* %7
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %67
31: ; preds = %27
store i32 0, i32* %8
br label %32
32: ; preds = %60, %31
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %63
36: ; preds = %32
%37 = call i32 (...) @rand()
%38 = sitofp i32 %37 to double
%39 = fmul double 1.000000e+00, %38
%40 = load i32, i32* @RAND_MAX
%41 = sitofp i32 %40 to double
%42 = fdiv double %39, %41
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = load i32, i32* %9
%46 = mul nsw i32 %44, %45
%47 = add nsw i32 %43, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %18, i64 %48
store double %42, double* %49
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = mul nsw i32 %51, %52
%54 = add nsw i32 %50, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %18, i64 %55
%57 = load double, double* %56
%58 = load double, double* %10
%59 = fadd double %58, %57
store double %59, double* %10
br label %60
60: ; preds = %36
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %32
63: ; preds = %32
br label %64
64: ; preds = %63
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %27
67: ; preds = %27
%68 = load double, double* %10
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %68)
store i32 0, i32* %3
%70 = load i8*, i8** %11
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [6 x i8] c"%u \09\0A\00"
@RAND_MAX = global i32 0
@.str.2 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i8* @llvm.stacksave()
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = sitofp i32 %9 to double
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %36
14: ; preds = %2, %31
%15 = phi i32 [ %32, %31 ], [ %12, %2 ]
%16 = phi i32 [ %34, %31 ], [ 0, %2 ]
%17 = phi double [ %33, %31 ], [ 0.000000e+00, %2 ]
%18 = icmp sgt i32 %15, 0
br i1 %18, label %19, label %31
19: ; preds = %14, %19
%20 = phi double [ %27, %19 ], [ %17, %14 ]
%21 = phi i32 [ %28, %19 ], [ 0, %14 ]
%22 = call i32 (...) @rand()
%23 = sitofp i32 %22 to double
%24 = load i32, i32* @RAND_MAX
%25 = sitofp i32 %24 to double
%26 = fdiv double %23, %25
%27 = fadd double %20, %26
%28 = add nuw nsw i32 %21, 1
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %19, label %31
31: ; preds = %19, %14
%32 = phi i32 [ %15, %14 ], [ %29, %19 ]
%33 = phi double [ %17, %14 ], [ %27, %19 ]
%34 = add nuw nsw i32 %16, 1
%35 = icmp slt i32 %34, %32
br i1 %35, label %14, label %36
36: ; preds = %31, %2
%37 = phi double [ 0.000000e+00, %2 ], [ %33, %31 ]
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %37)
ret i32 0
}