#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*/ fscanf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
void saisie_graphe(int **graphe, int nb_sommet) {
  int sommeta, sommetb, poidab;
  char action;
  fscanf(stdin, " %c", &action);
  while (action != 'q') {
    fscanf(stdin, " %d %d %d", &sommeta, &sommetb, &poidab);
    if (((sommeta >= 0) && (sommeta < nb_sommet)) &&
        ((sommetb >= 0) && (sommetb < nb_sommet)) &&
        ((poidab < 99999) && ((poidab > 0)))) {
      graphe[sommeta][sommetb] = poidab;
      graphe[sommetb][sommeta] = poidab;
    } else {
      printf("Erreur de saisie \n");
    }
    fscanf(stdin, " %c", &action);
  }
}


x86 assembly (clang, -O0):
<saisie_graphe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
lea    -0x19(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x71,%eax
je     121a <saisie_graphe+0xfa>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
mov    $0x0,%al
call   1040 <fscanf@plt>
cmpl   $0x0,-0x10(%rbp)
jl     11ee <saisie_graphe+0xce>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ee <saisie_graphe+0xce>
cmpl   $0x0,-0x14(%rbp)
jl     11ee <saisie_graphe+0xce>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ee <saisie_graphe+0xce>
cmpl   $0x1869f,-0x18(%rbp)
jge    11ee <saisie_graphe+0xce>
cmpl   $0x0,-0x18(%rbp)
jle    11ee <saisie_graphe+0xce>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11fa <saisie_graphe+0xda>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
lea    -0x19(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
jmp    114a <saisie_graphe+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saisie_graphe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
mov    0x2eac(%rip),%r12
mov    (%r12),%edi
lea    0xeb9(%rip),%rsi
lea    0x3(%rsp),%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpb   $0x71,0x3(%rsp)
jne    1169 <saisie_graphe+0x49>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%r13
lea    0x4(%rsp),%rbp
lea    0xe86(%rip),%r14
lea    0x3(%rsp),%r15
jmp    11b4 <saisie_graphe+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12),%edi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpb   $0x71,0x3(%rsp)
je     115a <saisie_graphe+0x3a>
mov    (%r12),%edi
lea    0xe45(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r13,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1190 <saisie_graphe+0x70>
cmp    %ebx,%eax
jge    1190 <saisie_graphe+0x70>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
js     1190 <saisie_graphe+0x70>
cmp    %ebx,%ecx
jge    1190 <saisie_graphe+0x70>
mov    0x4(%rsp),%edx
cmp    $0x1869e,%edx
jg     1190 <saisie_graphe+0x70>
test   %edx,%edx
jle    1190 <saisie_graphe+0x70>
mov    0x10(%rsp),%rsi
mov    (%rsi,%rax,8),%rax
mov    %edx,(%rax,%rcx,4)
mov    0x4(%rsp),%eax
movslq 0x8(%rsp),%rcx
mov    (%rsi,%rcx,8),%rcx
movslq 0xc(%rsp),%rdx
mov    %eax,(%rcx,%rdx,4)
jmp    119c <saisie_graphe+0x7c>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c" %c\00"
@.str.1 = [10 x i8] c" %d %d %d\00"
@.str.2 = [19 x i8] c"Erreur de saisie \0A\00"
define void @saisie_graphe(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32** %0, i32*** %3
store i32 %1, i32* %4
%9 = load i32, i32* @stdin
%10 = call i32 (i32, i8*, ...) @fscanf(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %11
11: ; preds = %58, %2
%12 = load i8, i8* %8
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 113
br i1 %14, label %15, label %61
15: ; preds = %11
%16 = load i32, i32* @stdin
%17 = call i32 (i32, i8*, ...) @fscanf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%18 = load i32, i32* %5
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %56
20: ; preds = %15
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %56
24: ; preds = %20
%25 = load i32, i32* %6
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %56
27: ; preds = %24
%28 = load i32, i32* %6
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %56
31: ; preds = %27
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 99999
br i1 %33, label %34, label %56
34: ; preds = %31
%35 = load i32, i32* %7
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %56
37: ; preds = %34
%38 = load i32, i32* %7
%39 = load i32**, i32*** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
%43 = load i32*, i32** %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 %38, i32* %46
%47 = load i32, i32* %7
%48 = load i32**, i32*** %3
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32*, i32** %48, i64 %50
%52 = load i32*, i32** %51
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
store i32 %47, i32* %55
br label %58
56: ; preds = %34, %31, %27, %24, %20, %15
%57 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56, %37
%59 = load i32, i32* @stdin
%60 = call i32 (i32, i8*, ...) @fscanf(i32 %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %11
61: ; preds = %11
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c" %c\00"
@.str.1 = [10 x i8] c" %d %d %d\00"
@str = [18 x i8] c"Erreur de saisie \00"
define void @saisie_graphe(i32** nocapture %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = load i32, i32* @stdin
%11 = call i32 (i32, i8*, ...) @fscanf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 113
br i1 %13, label %52, label %14
14: ; preds = %2, %47
%15 = load i32, i32* @stdin
%16 = call i32 (i32, i8*, ...) @fscanf(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, -1
br i1 %18, label %19, label %45
19: ; preds = %14
%20 = icmp slt i32 %17, %1
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, -1
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %24, label %45
24: ; preds = %19
%25 = icmp slt i32 %21, %1
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 99999
%28 = select i1 %25, i1 %27, i1 false
%29 = icmp sgt i32 %26, 0
%30 = select i1 %28, i1 %29, i1 false
br i1 %30, label %31, label %45
31: ; preds = %24
%32 = zext i32 %17 to i64
%33 = getelementptr inbounds i32*, i32** %0, i64 %32
%34 = load i32*, i32** %33
%35 = zext i32 %21 to i64
%36 = getelementptr inbounds i32, i32* %34, i64 %35
store i32 %26, i32* %36
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32*, i32** %0, i64 %39
%41 = load i32*, i32** %40
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %37, i32* %44
br label %47
45: ; preds = %24, %19, %14
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %47
47: ; preds = %45, %31
%48 = load i32, i32* @stdin
%49 = call i32 (i32, i8*, ...) @fscanf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%50 = load i8, i8* %6
%51 = icmp eq i8 %50, 113
br i1 %51, label %52, label %14
52: ; preds = %47, %2
ret void
}