#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 /*<<< orphan*/ scanf(char *, int *, int *, int *);
void getgraph(int N, int G[N][N], int E) {
  int v1, v2, e;
  while (E--) {
    scanf("%d %d %d", &v1, &v2, &e);
    v1--, v2--;
    G[v1][v2] = G[v2][v1] = e;
  }
}


x86 assembly (clang, -O0):
<getgraph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11a7 <getgraph+0x97>
lea    0xebc(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1030 <scanf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1129 <getgraph+0x19>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getgraph>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
je     1190 <getgraph+0x80>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x14(%rsp),%rbp
nopl   0x0(%rax)
lea    0xeb9(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1030 <scanf@plt>
movslq 0x10(%rsp),%rax
lea    -0x1(%rax),%rcx
movslq 0xc(%rsp),%rdx
lea    -0x1(%rdx),%rsi
mov    %esi,0xc(%rsp)
imul   %r15,%rsi
mov    %ecx,0x10(%rsp)
imul   %r15,%rcx
mov    0x14(%rsp),%edi
lea    (%r14,%rsi,4),%rsi
mov    %edi,-0x4(%rsi,%rax,4)
lea    (%r14,%rcx,4),%rax
mov    %edi,-0x4(%rax,%rdx,4)
add    $0xffffffff,%ebx
jne    1140 <getgraph+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
define void @getgraph(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %18, %3
%15 = load i32, i32* %6
%16 = add nsw i32 %15, -1
store i32 %16, i32* %6
%17 = icmp ne i32 %15, 0
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%20 = load i32, i32* %7
%21 = add nsw i32 %20, -1
store i32 %21, i32* %7
%22 = load i32, i32* %8
%23 = add nsw i32 %22, -1
store i32 %23, i32* %8
%24 = load i32, i32* %9
%25 = load i32*, i32** %5
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul nsw i64 %27, %13
%29 = getelementptr inbounds i32, i32* %25, i64 %28
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %24, i32* %32
%33 = load i32*, i32** %5
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = mul nsw i64 %35, %13
%37 = getelementptr inbounds i32, i32* %33, i64 %36
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %24, i32* %40
br label %14
41: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
define void @getgraph(i32 %0, i32* nocapture writeonly %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = zext i32 %0 to i64
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %2, 0
br i1 %11, label %30, label %12
12: ; preds = %3, %12
%13 = phi i32 [ %14, %12 ], [ %2, %3 ]
%14 = add nsw i32 %13, -1
%15 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, -1
store i32 %19, i32* %5
%20 = load i32, i32* %6
%21 = sext i32 %19 to i64
%22 = mul nsw i64 %21, %7
%23 = getelementptr inbounds i32, i32* %1, i64 %22
%24 = sext i32 %17 to i64
%25 = getelementptr inbounds i32, i32* %23, i64 %24
store i32 %20, i32* %25
%26 = mul nsw i64 %24, %7
%27 = getelementptr inbounds i32, i32* %1, i64 %26
%28 = getelementptr inbounds i32, i32* %27, i64 %21
store i32 %20, i32* %28
%29 = icmp eq i32 %14, 0
br i1 %29, label %30, label %12
30: ; preds = %12, %3
ret void
}