#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void inputWGraph(int g[7][7]) {
  printf("\n\tInputting Weighted Edges: \n");
  printf("\tHow many edges do you wish to add? ans = ");
  int numberOfEdges = 0;
  scanf("%d", &numberOfEdges);
  int i;
  int a, b, w;
  for (i = 0; i < numberOfEdges; i++) {
    printf("\t%d.\n\tNode 1: ", i + 1);
    scanf("%d", &a);
    printf("\tNode 2: ");
    scanf("%d", &b);
    printf("\tWeight: ");
    scanf("%d", &w);
    g[a][b] = w;
    g[b][a] = w;
    printf("\tEdge (%d,%d) with weight %d added.\n\n", a, b, w);
  }
}


x86 assembly (clang, -O0):
<inputWGraph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
lea    0xef3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1229 <inputWGraph+0x109>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <inputWGraph+0x46>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputWGraph>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0x8(%rsp)
lea    0xec1(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1234 <inputWGraph+0x104>
lea    0xea5(%rip),%r15
lea    0xeba(%rip),%r14
lea    0xc(%rsp),%r12
lea    0xeb8(%rip),%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
lea    0xe84(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
movslq 0x14(%rsp),%rsi
movslq 0x10(%rsp),%rdx
lea    (%rsi,%rsi,8),%rax
lea    (%rax,%rax,2),%rax
add    %rsi,%rax
add    %rbx,%rax
mov    %ecx,(%rax,%rdx,4)
lea    (%rdx,%rdx,8),%rax
lea    (%rax,%rax,2),%rax
add    %rdx,%rax
add    %rbx,%rax
mov    %ecx,(%rax,%rsi,4)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x8(%rsp),%ebp
jl     11a0 <inputWGraph+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0A\09Inputting Weighted Edges: \0A\00"
@.str.1 = [43 x i8] c"\09How many edges do you wish to add? ans = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"\09%d.\0A\09Node 1: \00"
@.str.4 = [10 x i8] c"\09Node 2: \00"
@.str.5 = [10 x i8] c"\09Weight: \00"
@.str.6 = [38 x i8] c"\09Edge (%d,%d) with weight %d added.\0A\0A\00"
define void @inputWGraph([7 x i32]* %0) {
%2 = alloca [7 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store [7 x i32]* %0, [7 x i32]** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %11
11: ; preds = %44, %1
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %47
15: ; preds = %11
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%24 = load i32, i32* %7
%25 = load [7 x i32]*, [7 x i32]** %2
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x i32], [7 x i32]* %25, i64 %27
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [7 x i32], [7 x i32]* %28, i64 0, i64 %30
store i32 %24, i32* %31
%32 = load i32, i32* %7
%33 = load [7 x i32]*, [7 x i32]** %2
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [7 x i32], [7 x i32]* %33, i64 %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [7 x i32], [7 x i32]* %36, i64 0, i64 %38
store i32 %32, i32* %39
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %15
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %11
47: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"\09How many edges do you wish to add? ans = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"\09%d.\0A\09Node 1: \00"
@.str.4 = [10 x i8] c"\09Node 2: \00"
@.str.5 = [10 x i8] c"\09Weight: \00"
@.str.6 = [38 x i8] c"\09Edge (%d,%d) with weight %d added.\0A\0A\00"
@str = [29 x i8] c"\0A\09Inputting Weighted Edges: \00"
define void @inputWGraph([7 x i32]* nocapture writeonly %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %1, %15
%16 = phi i32 [ %17, %15 ], [ 0, %1 ]
%17 = add nuw nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [7 x i32], [7 x i32]* %0, i64 %26, i64 %28
store i32 %24, i32* %29
%30 = getelementptr inbounds [7 x i32], [7 x i32]* %0, i64 %28, i64 %26
store i32 %24, i32* %30
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %25, i32 %27, i32 %24)
%32 = load i32, i32* %2
%33 = icmp slt i32 %17, %32
br i1 %33, label %15, label %34
34: ; preds = %15, %1
ret void
}