#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 EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fprintf(int /*<<< orphan*/, char *, int, int);
int fread(int *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc < 2)
    error("Parametre invalide");
  FILE *file = NULL;
  if (!(file = fopen(argv[1], "r")))
    error("Fichier invalide\n");
  for (int i = 2; i < argc; i++) {
    int adr;
    if (!sscanf(argv[i], "%x", &adr))
      error("Adresse pas lisible\n");
    if (fseek(file, adr, SEEK_SET) < 0)
      error("Impossible de se placer dans le fichier");
    int value = 0;
    if (fread(&value, sizeof(char), 1, file) < 1)
      error("Impossible de lire");
    if (fprintf(stdout, "0x%06x:0x%x\n", adr, value) < 0)
      error("Impssible d'afficher l'inode");
  }
  fclose(file);
  return EXIT_SUCCESS;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    119c <main+0x2c>
lea    0xe69(%rip),%rdi
call   1080 <error@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb0(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d2 <main+0x62>
lea    0xe46(%rip),%rdi
call   1080 <error@plt>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b5 <main+0x145>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe2d(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%eax
jne    1216 <main+0xa6>
lea    0xe17(%rip),%rdi
call   1080 <error@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
cmp    $0x0,%rax
jge    1241 <main+0xd1>
lea    0xe01(%rip),%rdi
call   1080 <error@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
jge    1271 <main+0x101>
lea    0xdf9(%rip),%rdi
call   1080 <error@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xdf1(%rip),%rsi
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jge    12a2 <main+0x132>
lea    0xde8(%rip),%rdi
call   1080 <error@plt>
jmp    12a7 <main+0x137>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d9 <main+0x69>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1191 <main+0x21>
lea    0xe74(%rip),%rdi
call   1080 <error@plt>
mov    0x8(%r14),%rdi
lea    0xec7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b3 <main+0x43>
cmp    $0x3,%ebp
jge    11c8 <main+0x58>
jmp    12a1 <main+0x131>
lea    0xe59(%rip),%rdi
call   1080 <error@plt>
cmp    $0x3,%ebp
jl     12a1 <main+0x131>
mov    %ebp,%r15d
mov    $0x2,%r12d
mov    0x2e00(%rip),%r13
lea    0xe99(%rip),%rbp
jmp    11fd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%r15
je     12a1 <main+0x131>
mov    (%r14,%r12,8),%rdi
lea    0xe1d(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1060 <sscanf@plt>
test   %eax,%eax
jne    1222 <main+0xb2>
lea    0xe0b(%rip),%rdi
call   1080 <error@plt>
mov    0x4(%rsp),%esi
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1070 <fseek@plt>
test   %rax,%rax
jns    1248 <main+0xd8>
lea    0xdfa(%rip),%rdi
call   1080 <error@plt>
movl   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jg     1274 <main+0x104>
lea    0xdf6(%rip),%rdi
call   1080 <error@plt>
mov    0x0(%r13),%edi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    %rbp,%rsi
call   1050 <fprintf@plt>
test   %rax,%rax
jns    11f0 <main+0x80>
lea    0xdee(%rip),%rdi
call   1080 <error@plt>
jmp    11f0 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Parametre invalide\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"Fichier invalide\0A\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [21 x i8] c"Adresse pas lisible\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [40 x i8] c"Impossible de se placer dans le fichier\00"
@.str.6 = [19 x i8] c"Impossible de lire\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"0x%06x:0x%x\0A\00"
@.str.8 = [29 x i8] c"Impssible d'afficher l'inode\00"
@EXIT_SUCCESS = global i32 0
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
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
store i32* null, i32** %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %14
store i32 2, i32* %7
br label %23
23: ; preds = %60, %22
%24 = load i32, i32* %7
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %63
27: ; preds = %23
%28 = load i8**, i8*** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %27
%36 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %27
%38 = load i32*, i32** %6
%39 = load i32, i32* %8
%40 = load i32, i32* @SEEK_SET
%41 = call i64 @fseek(i32* %38, i32 %39, i32 %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %43, %37
store i32 0, i32* %9
%46 = load i32*, i32** %6
%47 = call i32 @fread(i32* %9, i32 1, i32 1, i32* %46)
%48 = icmp slt i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
%52 = load i32, i32* @stdout
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = call i64 @fprintf(i32 %52, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %53, i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %57, %51
br label %60
60: ; preds = %59
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %23
63: ; preds = %23
%64 = load i32*, i32** %6
%65 = call i32 @fclose(i32* %64)
%66 = load i32, i32* @EXIT_SUCCESS
ret i32 %66
}

LLVM IR (-O2):
@.str = [19 x i8] c"Parametre invalide\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"Fichier invalide\0A\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [21 x i8] c"Adresse pas lisible\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [40 x i8] c"Impossible de se placer dans le fichier\00"
@.str.6 = [19 x i8] c"Impossible de lire\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"0x%06x:0x%x\0A\00"
@.str.8 = [29 x i8] c"Impssible d'afficher l'inode\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
%16 = icmp sgt i32 %0, 2
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = bitcast i32* %3 to i8*
%19 = bitcast i32* %4 to i8*
%20 = zext i32 %0 to i64
br label %24
21: ; preds = %52, %15
%22 = call i32 @fclose(i32* %11)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
24: ; preds = %17, %52
%25 = phi i64 [ 2, %17 ], [ %53, %52 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = load i32, i32* %3
%34 = load i32, i32* @SEEK_SET
%35 = call i64 @fseek(i32* %11, i32 %33, i32 %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
store i32 0, i32* %4
%40 = call i32 @fread(i32* %4, i32 1, i32 1, i32* %11)
%41 = icmp slt i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = load i32, i32* @stdout
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = call i64 @fprintf(i32 %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %46, i32 %47)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %44
%53 = add nuw nsw i64 %25, 1
%54 = icmp eq i64 %53, %20
br i1 %54, label %21, label %24
}