#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*/ O_RDONLY;
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char **, int);
int main(int argc, char *argv[], char *env[]) {
  if (argc < 2) {
    printf("Aucun fichier à ouvrir...\n");
    exit(1);
  }
  int f = open(argv[1], O_RDONLY);
  if (f < 0) {
    printf("Ouverture de fichier impossible...");
    exit(2);
  }
  int eof = 1, pos = 0;
  char c[16];
  while (0 < (eof = read(f, &c, 16))) {
    printf("%8.8x: ", pos);
    pos += 16;
    for (int i = 0; i < eof; i++) {
      printf("%2.2hhx", c[i]);
      if (i % 2)
        printf(" ");
    }
    if (eof < 16)
      for (int i = eof; i < 16; i++) {
        printf("  ");
        if (i % 2)
          printf(" ");
      }
    printf(" ");
    for (int i = 0; i < eof; i++) {
      if (c[i] >= 0x20 && c[i] < 0x7F)
        printf("%c", c[i]);
      else
        printf(".");
    }
    printf("\n");
  }
  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)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117c <main+0x3c>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11b7 <main+0x77>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jge    1355 <main+0x215>
mov    -0x24(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    125e <main+0x11e>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     124b <main+0x10b>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1250 <main+0x110>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1206 <main+0xc6>
cmpl   $0x10,-0x20(%rbp)
jge    12c0 <main+0x180>
mov    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x10,-0x48(%rbp)
jge    12bb <main+0x17b>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12a8 <main+0x168>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ad <main+0x16d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    126e <main+0x12e>
jmp    12c0 <main+0x180>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1342 <main+0x202>
movslq -0x4c(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jl     1321 <main+0x1e1>
movslq -0x4c(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x7f,%eax
jge    1321 <main+0x1e1>
movslq -0x4c(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132f <main+0x1ef>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <main+0x1f4>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12d5 <main+0x195>
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <main+0x85>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jle    12c7 <main+0x167>
mov    0x8(%rsi),%rdi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
test   %eax,%eax
js     12dd <main+0x17d>
mov    %eax,%r13d
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x10,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    12b6 <main+0x156>
mov    %eax,%r14d
lea    0xe74(%rip),%rbx
mov    $0x2e,%r12d
xor    %ebp,%ebp
mov    %r13d,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe4c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x10,%ebp
mov    %ebp,0xc(%rsp)
mov    %r14d,%r15d
xor    %r13d,%r13d
jmp    11f9 <main+0x99>
nop
add    $0x1,%r13
cmp    %r13,%r15
je     1220 <main+0xc0>
movsbl 0x10(%rsp,%r13,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x1,%r13b
je     11f0 <main+0x90>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11f0 <main+0x90>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%r13d
cmp    $0xf,%r14d
lea    0xe03(%rip),%rbp
jle    129a <main+0x13a>
mov    $0x20,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl 0x10(%rsp,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
cmovb  %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1240 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13d,%edi
lea    0x10(%rsp),%rsi
mov    $0x10,%edx
call   1060 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
mov    0xc(%rsp),%ebp
jg     11d0 <main+0x70>
jmp    12b6 <main+0x156>
nopl   (%rax)
add    $0x1,%r14d
cmp    $0x10,%r14d
je     1232 <main+0xd2>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x1,%r14b
je     1290 <main+0x130>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1290 <main+0x130>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd68(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Aucun fichier \C3\A0 ouvrir...\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [35 x i8] c"Ouverture de fichier impossible...\00"
@.str.2 = [8 x i8] c"%8.8x: \00"
@.str.3 = [8 x i8] c"%2.2hhx\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [2 x i8] c".\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [16 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %20
store i32 1, i32* %9
store i32 0, i32* %10
br label %32
32: ; preds = %115, %31
%33 = load i32, i32* %8
%34 = bitcast [16 x i8]* %11 to i8**
%35 = call i32 @read(i32 %33, i8** %34, i32 16)
store i32 %35, i32* %9
%36 = icmp slt i32 0, %35
br i1 %36, label %37, label %117
37: ; preds = %32
%38 = load i32, i32* %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 16
store i32 %41, i32* %10
store i32 0, i32* %12
br label %42
42: ; preds = %59, %37
%43 = load i32, i32* %12
%44 = load i32, i32* %9
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %62
46: ; preds = %42
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %12
%54 = srem i32 %53, 2
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %46
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %46
br label %59
59: ; preds = %58
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
br label %42
62: ; preds = %42
%63 = load i32, i32* %9
%64 = icmp slt i32 %63, 16
br i1 %64, label %65, label %82
65: ; preds = %62
%66 = load i32, i32* %9
store i32 %66, i32* %13
br label %67
67: ; preds = %78, %65
%68 = load i32, i32* %13
%69 = icmp slt i32 %68, 16
br i1 %69, label %70, label %81
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* %13
%73 = srem i32 %72, 2
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %77
77: ; preds = %75, %70
br label %78
78: ; preds = %77
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 1
store i32 %80, i32* %13
br label %67
81: ; preds = %67
br label %82
82: ; preds = %81, %62
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %14
br label %84
84: ; preds = %112, %82
%85 = load i32, i32* %14
%86 = load i32, i32* %9
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %115
88: ; preds = %84
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp sge i32 %93, 32
br i1 %94, label %95, label %109
95: ; preds = %88
%96 = load i32, i32* %14
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp slt i32 %100, 127
br i1 %101, label %102, label %109
102: ; preds = %95
%103 = load i32, i32* %14
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %104
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %107)
br label %111
109: ; preds = %95, %88
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %111
111: ; preds = %109, %102
br label %112
112: ; preds = %111
%113 = load i32, i32* %14
%114 = add nsw i32 %113, 1
store i32 %114, i32* %14
br label %84
115: ; preds = %84
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %32
117: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str.1 = [35 x i8] c"Ouverture de fichier impossible...\00"
@.str.2 = [8 x i8] c"%8.8x: \00"
@.str.3 = [8 x i8] c"%2.2hhx\00"
@.str.5 = [3 x i8] c" \00"
@str = [27 x i8] c"Aucun fichier \C3\A0 ouvrir...\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca [16 x i8]
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @exit(i32 2)
unreachable
18: ; preds = %9
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%20 = bitcast [16 x i8]* %4 to i8**
%21 = call i32 @read(i32 %13, i8** %20, i32 16)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %72
23: ; preds = %18, %57
%24 = phi i32 [ %59, %57 ], [ %21, %18 ]
%25 = phi i32 [ %27, %57 ], [ 0, %18 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i32 %25, 16
%28 = zext i32 %24 to i64
br label %31
29: ; preds = %41
%30 = icmp slt i32 %24, 16
br i1 %30, label %44, label %54
31: ; preds = %23, %41
%32 = phi i64 [ 0, %23 ], [ %42, %41 ]
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = and i64 %32, 1
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %31
%40 = tail call i32 @putchar(i32 32)
br label %41
41: ; preds = %31, %39
%42 = add nuw nsw i64 %32, 1
%43 = icmp eq i64 %42, %28
br i1 %43, label %29, label %31
44: ; preds = %29, %51
%45 = phi i32 [ %52, %51 ], [ %24, %29 ]
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%47 = and i32 %45, 1
%48 = icmp eq i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = tail call i32 @putchar(i32 32)
br label %51
51: ; preds = %44, %49
%52 = add i32 %45, 1
%53 = icmp eq i32 %52, 16
br i1 %53, label %54, label %44
54: ; preds = %51, %29
%55 = tail call i32 @putchar(i32 32)
%56 = zext i32 %24 to i64
br label %61
57: ; preds = %61
%58 = tail call i32 @putchar(i32 10)
%59 = call i32 @read(i32 %13, i8** %20, i32 16)
%60 = icmp sgt i32 %59, 0
br i1 %60, label %23, label %72
61: ; preds = %54, %61
%62 = phi i64 [ 0, %54 ], [ %70, %61 ]
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = add i8 %64, -127
%66 = icmp ult i8 %65, -95
%67 = select i1 %66, i8 46, i8 %64
%68 = zext i8 %67 to i32
%69 = tail call i32 @putchar(i32 %68)
%70 = add nuw nsw i64 %62, 1
%71 = icmp eq i64 %70, %56
br i1 %71, label %57, label %61
72: ; preds = %57, %18
ret i32 0
}