#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 uint32_t;
typedef int /*<<< orphan*/ reg;

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ help(char *);
scalar_t__ lseek(int, unsigned long, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ r_loop(int, char **, unsigned long);
int read(int, int *, int);
int sscanf(char *, char *, unsigned long *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ w_loop(int, char **, unsigned long);
int write(int, int *, int);
int main(int argc, char **argv) {
  int fd;
  unsigned long addr, value, nbytes = 0;
  uint32_t reg;
  int dowrite = 0, doloop = 0;
  char c;
  if (argc < 3 || argv[1][0] == '-')
    help(argv[0]);
  if (sscanf(argv[2], "%lx%c", &addr, &c) != 1) {
    fprintf(stderr, "%s: Not an hex address \"%s\"\n", argv[0], argv[2]);
    exit(1);
  }
  if (argv[argc - 1][0] == '+') {
    if (sscanf(argv[argc - 1], "+%lx%c", &nbytes, &c) != 1) {
      fprintf(stderr, "%s: Not +<hex-number> \"%s\"\n", argv[0],
              argv[argc - 1]);
      exit(1);
    }
    doloop = 1;
    argc--;
  }
  if (argc > 4)
    help(argv[0]);
  if (argc == 4) {
    if (sscanf(argv[3], "%lx%c", &value, &c) != 1) {
      fprintf(stderr, "%s: Not an hex value \"%s\"\n", argv[0], argv[3]);
      exit(1);
    }
    dowrite = 1;
  }
  if (0) {
    if (dowrite)
      printf("write %lx to %s:%lx (loop %i %lx)\n", value, argv[1], addr,
             doloop, nbytes);
    else
      printf("read from %s:%lx (loop %i %lx)\n", argv[1], addr, doloop, nbytes);
    exit(0);
  }
  fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1], strerror(errno));
    exit(1);
  }
  if (lseek(fd, addr, SEEK_SET) < 0) {
    fprintf(stderr, "%s: %s: lseek: %s\n", argv[0], argv[1], strerror(errno));
    exit(1);
  }
  if (doloop && dowrite)
    w_loop(fd, argv, nbytes);
  if (doloop)
    r_loop(fd, argv, nbytes);
  if (dowrite) {
    reg = value;
    if (write(fd, &reg, sizeof(reg)) != sizeof(reg)) {
      fprintf(stderr, "%s: write(): %s\n", argv[0], strerror(errno));
      exit(1);
    }
    exit(0);
  }
  if (read(fd, &reg, sizeof(reg)) != sizeof(reg)) {
    fprintf(stderr, "%s: read(): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  printf("%08x\n", reg);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     120d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1219 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <help@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf6(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x3d(%rbp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
je     126e <main+0xae>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1302 <main+0x142>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd7a(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x3d(%rbp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
je     12f2 <main+0x132>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x1,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1318 <main+0x158>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <help@plt>
cmpl   $0x4,-0x8(%rbp)
jne    137e <main+0x1be>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xced(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x3d(%rbp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
je     1377 <main+0x1b7>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    13f8 <main+0x238>
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    %rax,%r8
lea    0xc74(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    0x2bc2(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    146e <main+0x2ae>
mov    0x2bba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    0x2b8f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    %rax,%r8
lea    0xc0a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1492 <main+0x2d2>
cmpl   $0x0,-0x38(%rbp)
je     1492 <main+0x2d2>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <w_loop@plt>
cmpl   $0x0,-0x3c(%rbp)
je     14ac <main+0x2ec>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10a0 <r_loop@plt>
cmpl   $0x0,-0x38(%rbp)
je     1528 <main+0x368>
mov    -0x28(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cltq
cmp    $0x4,%rax
je     1521 <main+0x361>
mov    0x2af7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    %rax,%rcx
lea    0xb6a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
cltq
cmp    $0x4,%rax
je     1598 <main+0x3d8>
mov    0x2a8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
mov    0x2a67(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rdx
mov    %rax,%rcx
lea    0xb04(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x34(%rbp),%esi
lea    0xaf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jl     11e9 <main+0x29>
mov    0x8(%r12),%rax
cmpb   $0x2d,(%rax)
jne    11f2 <main+0x32>
mov    (%r12),%rdi
call   10c0 <help@plt>
mov    0x10(%r12),%rdi
lea    0xe20(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0x3(%rsp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1255 <main+0x95>
movslq %ebp,%rbx
mov    -0x8(%r12,%rbx,8),%rdi
mov    (%rdi),%r14b
cmp    $0x2b,%r14b
jne    1245 <main+0x85>
lea    0xdf3(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x3(%rsp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1364 <main+0x1a4>
add    $0xffffffff,%ebp
cmp    $0x5,%ebp
jl     127f <main+0xbf>
mov    (%r12),%rdi
call   10c0 <help@plt>
jmp    12c2 <main+0x102>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
mov    0x10(%r12),%rcx
lea    0xd92(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmp    $0x4,%ebp
jne    12c2 <main+0x102>
mov    0x18(%r12),%rdi
lea    0xd8e(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x3(%rsp),%rcx
call   1090 <sscanf@plt>
mov    $0x1,%r15b
cmp    $0x1,%eax
je     12c5 <main+0x105>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
mov    0x18(%r12),%rcx
lea    0xd80(%rip),%rsi
jmp    126e <main+0xae>
xor    %r15d,%r15d
mov    0x8(%r12),%rdi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
jns    1305 <main+0x145>
mov    0x2cf5(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%r14
mov    0x8(%r12),%rbx
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd58(%rip),%rsi
jmp    1348 <main+0x188>
mov    %eax,%ebp
mov    0x18(%rsp),%rsi
mov    0x2cb5(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1050 <lseek@plt>
test   %rax,%rax
jns    1385 <main+0x1c5>
mov    0x2cb0(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%r14
mov    0x8(%r12),%rbx
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd1f(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
add    $0xffffffffffffffff,%rbx
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
mov    (%r12,%rbx,8),%rcx
lea    0xca4(%rip),%rsi
jmp    126e <main+0xae>
cmp    $0x2b,%r14b
setne  %al
mov    %r15d,%ecx
xor    $0x1,%cl
or     %al,%cl
je     13c6 <main+0x206>
cmp    $0x2b,%r14b
je     13db <main+0x21b>
test   %r15b,%r15b
je     13ef <main+0x22f>
mov    0x10(%rsp),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0x4,%eax
jne    141e <main+0x25e>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    %r12,%rsi
call   1080 <w_loop@plt>
cmp    $0x2b,%r14b
jne    139c <main+0x1dc>
mov    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    %r12,%rsi
call   10a0 <r_loop@plt>
test   %r15b,%r15b
jne    13a1 <main+0x1e1>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1060 <read@plt>
cmp    $0x4,%eax
jne    1442 <main+0x282>
mov    0x4(%rsp),%esi
lea    0xc8b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%rbx
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc3a(%rip),%rsi
jmp    1464 <main+0x2a4>
mov    0x2b8f(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%rbx
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc27(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
jmp    126e <main+0xae>

LLVM IR (-O0):
@.str = [6 x i8] c"%lx%c\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"%s: Not an hex address \22%s\22\0A\00"
@.str.2 = [7 x i8] c"+%lx%c\00"
@.str.3 = [28 x i8] c"%s: Not +<hex-number> \22%s\22\0A\00"
@.str.4 = [27 x i8] c"%s: Not an hex value \22%s\22\0A\00"
@O_RDWR = global i32 0
@.str.5 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [19 x i8] c"%s: %s: lseek: %s\0A\00"
@.str.7 = [17 x i8] c"%s: write(): %s\0A\00"
@.str.8 = [16 x i8] c"%s: read(): %s\0A\00"
@.str.9 = [6 x i8] c"%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %9
store i32 0, i32* %11
store i32 0, i32* %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %24, label %16
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br i1 %23, label %24, label %29
24: ; preds = %16, %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @help(i8* %27)
br label %29
29: ; preds = %24, %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %7, i8* %13)
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %45
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %29
%46 = load i8**, i8*** %5
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 43
br i1 %55, label %56, label %81
56: ; preds = %45
%57 = load i8**, i8*** %5
%58 = load i32, i32* %4
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %57, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %9, i8* %13)
%64 = icmp ne i32 %63, 1
br i1 %64, label %65, label %78
65: ; preds = %56
%66 = load i32, i32* @stderr
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %5
%71 = load i32, i32* %4
%72 = sub nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %70, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %69, i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %56
store i32 1, i32* %12
%79 = load i32, i32* %4
%80 = add nsw i32 %79, -1
store i32 %80, i32* %4
br label %81
81: ; preds = %78, %45
%82 = load i32, i32* %4
%83 = icmp sgt i32 %82, 4
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 0
%87 = load i8*, i8** %86
%88 = call i32 @help(i8* %87)
br label %89
89: ; preds = %84, %81
%90 = load i32, i32* %4
%91 = icmp eq i32 %90, 4
br i1 %91, label %92, label %109
92: ; preds = %89
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 3
%95 = load i8*, i8** %94
%96 = call i32 @sscanf(i8* %95, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %8, i8* %13)
%97 = icmp ne i32 %96, 1
br i1 %97, label %98, label %108
98: ; preds = %92
%99 = load i32, i32* @stderr
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 0
%102 = load i8*, i8** %101
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 3
%105 = load i8*, i8** %104
%106 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %102, i8* %105)
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %92
store i32 1, i32* %11
br label %109
109: ; preds = %108, %89
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 1
%112 = load i8*, i8** %111
%113 = load i32, i32* @O_RDWR
%114 = call i32 @open(i8* %112, i32 %113)
store i32 %114, i32* %6
%115 = load i32, i32* %6
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %129
117: ; preds = %109
%118 = load i32, i32* @stderr
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 0
%121 = load i8*, i8** %120
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 1
%124 = load i8*, i8** %123
%125 = load i32, i32* @errno
%126 = call i8* @strerror(i32 %125)
%127 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %121, i8* %124, i8* %126)
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %109
%130 = load i32, i32* %6
%131 = load i64, i64* %7
%132 = load i32, i32* @SEEK_SET
%133 = call i64 @lseek(i32 %130, i64 %131, i32 %132)
%134 = icmp slt i64 %133, 0
br i1 %134, label %135, label %147
135: ; preds = %129
%136 = load i32, i32* @stderr
%137 = load i8**, i8*** %5
%138 = getelementptr inbounds i8*, i8** %137, i64 0
%139 = load i8*, i8** %138
%140 = load i8**, i8*** %5
%141 = getelementptr inbounds i8*, i8** %140, i64 1
%142 = load i8*, i8** %141
%143 = load i32, i32* @errno
%144 = call i8* @strerror(i32 %143)
%145 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %139, i8* %142, i8* %144)
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %129
%148 = load i32, i32* %12
%149 = icmp ne i32 %148, 0
br i1 %149, label %150, label %158
150: ; preds = %147
%151 = load i32, i32* %11
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %158
153: ; preds = %150
%154 = load i32, i32* %6
%155 = load i8**, i8*** %5
%156 = load i64, i64* %9
%157 = call i32 @w_loop(i32 %154, i8** %155, i64 %156)
br label %158
158: ; preds = %153, %150, %147
%159 = load i32, i32* %12
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %166
161: ; preds = %158
%162 = load i32, i32* %6
%163 = load i8**, i8*** %5
%164 = load i64, i64* %9
%165 = call i32 @r_loop(i32 %162, i8** %163, i64 %164)
br label %166
166: ; preds = %161, %158
%167 = load i32, i32* %11
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %187
169: ; preds = %166
%170 = load i64, i64* %8
%171 = trunc i64 %170 to i32
store i32 %171, i32* %10
%172 = load i32, i32* %6
%173 = call i32 @write(i32 %172, i32* %10, i32 4)
%174 = sext i32 %173 to i64
%175 = icmp ne i64 %174, 4
br i1 %175, label %176, label %185
176: ; preds = %169
%177 = load i32, i32* @stderr
%178 = load i8**, i8*** %5
%179 = getelementptr inbounds i8*, i8** %178, i64 0
%180 = load i8*, i8** %179
%181 = load i32, i32* @errno
%182 = call i8* @strerror(i32 %181)
%183 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %180, i8* %182)
%184 = call i32 @exit(i32 1)
unreachable
185: ; preds = %169
%186 = call i32 @exit(i32 0)
unreachable
187: ; preds = %166
%188 = load i32, i32* %6
%189 = call i32 @read(i32 %188, i32* %10, i32 4)
%190 = sext i32 %189 to i64
%191 = icmp ne i64 %190, 4
br i1 %191, label %192, label %201
192: ; preds = %187
%193 = load i32, i32* @stderr
%194 = load i8**, i8*** %5
%195 = getelementptr inbounds i8*, i8** %194, i64 0
%196 = load i8*, i8** %195
%197 = load i32, i32* @errno
%198 = call i8* @strerror(i32 %197)
%199 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %193, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %196, i8* %198)
%200 = call i32 @exit(i32 1)
unreachable
201: ; preds = %187
%202 = load i32, i32* %10
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %202)
%204 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lx%c\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"%s: Not an hex address \22%s\22\0A\00"
@.str.2 = [7 x i8] c"+%lx%c\00"
@.str.3 = [28 x i8] c"%s: Not +<hex-number> \22%s\22\0A\00"
@.str.4 = [27 x i8] c"%s: Not an hex value \22%s\22\0A\00"
@O_RDWR = global i32 0
@.str.5 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [19 x i8] c"%s: %s: lseek: %s\0A\00"
@.str.7 = [17 x i8] c"%s: write(): %s\0A\00"
@.str.8 = [16 x i8] c"%s: read(): %s\0A\00"
@.str.9 = [6 x i8] c"%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8
%8 = bitcast i64* %3 to i8*
%9 = bitcast i64* %4 to i8*
%10 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%11 = bitcast i32* %6 to i8*
%12 = icmp slt i32 %0, 3
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %18, label %21
18: ; preds = %13, %2
%19 = load i8*, i8** %1
%20 = tail call i32 @help(i8* %19)
br label %21
21: ; preds = %18, %13
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %3, i8* %7)
%25 = icmp eq i32 %24, 1
br i1 %25, label %32, label %26
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = load i8*, i8** %22
%30 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %21
%33 = add nsw i32 %0, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 43
br i1 %38, label %39, label %48
39: ; preds = %32
%40 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %5, i8* %7)
%41 = icmp eq i32 %40, 1
br i1 %41, label %48, label %42
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %1
%45 = load i8*, i8** %35
%46 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %39, %32
%49 = phi i32 [ %0, %32 ], [ %33, %39 ]
%50 = icmp sgt i32 %49, 4
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i8*, i8** %1
%53 = call i32 @help(i8* %52)
br label %67
54: ; preds = %48
%55 = icmp eq i32 %49, 4
br i1 %55, label %56, label %67
56: ; preds = %54
%57 = getelementptr inbounds i8*, i8** %1, i64 3
%58 = load i8*, i8** %57
%59 = call i32 @sscanf(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %4, i8* %7)
%60 = icmp eq i32 %59, 1
br i1 %60, label %67, label %61
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %1
%64 = load i8*, i8** %57
%65 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %63, i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %51, %56, %54
%68 = phi i1 [ false, %51 ], [ true, %56 ], [ false, %54 ]
%69 = getelementptr inbounds i8*, i8** %1, i64 1
%70 = load i8*, i8** %69
%71 = load i32, i32* @O_RDWR
%72 = call i32 @open(i8* %70, i32 %71)
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %82
74: ; preds = %67
%75 = load i32, i32* @stderr
%76 = load i8*, i8** %1
%77 = load i8*, i8** %69
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %76, i8* %77, i8* %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %67
%83 = load i64, i64* %3
%84 = load i32, i32* @SEEK_SET
%85 = call i64 @lseek(i32 %72, i64 %83, i32 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %95
87: ; preds = %82
%88 = load i32, i32* @stderr
%89 = load i8*, i8** %1
%90 = load i8*, i8** %69
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %89, i8* %90, i8* %92)
%94 = call i32 @exit(i32 1)
unreachable
95: ; preds = %82
%96 = and i1 %38, %68
br i1 %96, label %97, label %100
97: ; preds = %95
%98 = load i64, i64* %5
%99 = call i32 @w_loop(i32 %72, i8** %1, i64 %98)
br label %100
100: ; preds = %97, %95
br i1 %38, label %101, label %104
101: ; preds = %100
%102 = load i64, i64* %5
%103 = call i32 @r_loop(i32 %72, i8** %1, i64 %102)
br label %104
104: ; preds = %101, %100
br i1 %68, label %105, label %119
105: ; preds = %104
%106 = load i64, i64* %4
%107 = trunc i64 %106 to i32
store i32 %107, i32* %6
%108 = call i32 @write(i32 %72, i32* %6, i32 4)
%109 = icmp eq i32 %108, 4
br i1 %109, label %117, label %110
110: ; preds = %105
%111 = load i32, i32* @stderr
%112 = load i8*, i8** %1
%113 = load i32, i32* @errno
%114 = call i8* @strerror(i32 %113)
%115 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %112, i8* %114)
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %105
%118 = call i32 @exit(i32 0)
unreachable
119: ; preds = %104
%120 = call i32 @read(i32 %72, i32* %6, i32 4)
%121 = icmp eq i32 %120, 4
br i1 %121, label %129, label %122
122: ; preds = %119
%123 = load i32, i32* @stderr
%124 = load i8*, i8** %1
%125 = load i32, i32* @errno
%126 = call i8* @strerror(i32 %125)
%127 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %124, i8* %126)
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %119
%130 = load i32, i32* %6
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %130)
%132 = call i32 @exit(i32 0)
unreachable
}