#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;
typedef unsigned long off_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
void *mmap(int /*<<< orphan*/, unsigned long, int, int /*<<< orphan*/, int,
           unsigned long);
int munmap(void *, unsigned long);
int open(char *, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
void *strtoul(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int tolower(char);
int main(int argc, char **argv) {
  int fd;
  void *map_base, *virt_addr;
  uint32_t read_result, writeval;
  char *filename;
  off_t target;
  int access_type = 'w';
  if (argc < 3) {
    fprintf(stderr,
            "\nUsage:\t%s { sys file } { offset } [ type [ data ] ]\n"
            "\tsys file: sysfs file for the pci resource to act on\n"
            "\toffset  : offset into pci memory region to act upon\n"
            "\ttype    : access operation type : [b]yte, [h]alfword, [w]ord\n"
            "\tdata    : data to be written\n\n",
            argv[0]);
    exit(1);
  }
  filename = argv[1];
  target = strtoul(argv[2], 0, 0);
  if (argc > 3)
    access_type = tolower(argv[3][0]);
  if ((fd = open(filename, O_RDWR | O_SYNC)) == -1)
    do {
      fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", 73,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/InnoRoute/packages/refs/heads/master/"
              "pcimem/src/pcimem.c",
              errno, strerror(errno));
      exit(1);
    } while (0);
  map_base = mmap(0, 4096UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
                  target & ~(4096UL - 1));
  if (map_base == (void *)-1)
    do {
      fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", 81,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/InnoRoute/packages/refs/heads/master/"
              "pcimem/src/pcimem.c",
              errno, strerror(errno));
      exit(1);
    } while (0);
  virt_addr = map_base + (target & (4096UL - 1));
  if (argc < 5) {
    switch (access_type) {
    case 'b':
      read_result = *((uint8_t *)virt_addr);
      break;
    case 'h':
      read_result = *((uint16_t *)virt_addr);
      break;
    case 'w':
      read_result = *((uint32_t *)virt_addr);
      break;
    default:
      fprintf(stderr, "Illegal data type '%c'.\n", access_type);
      exit(2);
    }
    printf("Value at offset 0x%X : 0x%X\n", target, read_result);
    fflush(stdout);
  }
  if (argc > 4) {
    writeval = strtoul(argv[4], 0, 0);
    switch (access_type) {
    case 'b':
      *((uint8_t *)virt_addr) = writeval;
      break;
    case 'h':
      *((uint16_t *)virt_addr) = writeval;
      break;
    case 'w':
      *((uint32_t *)virt_addr) = writeval;
      break;
    }
    printf("Written 0x%X\n", writeval);
    fflush(stdout);
  }
  if (munmap(map_base, 4096UL) == -1)
    do {
      fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", 127,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/InnoRoute/packages/refs/heads/master/"
              "pcimem/src/pcimem.c",
              errno, strerror(errno));
      exit(1);
    } while (0);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x77,-0x44(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11ff <main+0x4f>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10b0 <strtoul@plt>
mov    %rax,-0x40(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    123d <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
mov    0x2d7f(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12bd <main+0x10d>
jmp    1269 <main+0xb9>
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%r8d
mov    %rax,%r9
lea    0xe5d(%rip),%rsi
mov    $0x49,%edx
lea    0xe76(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edx
mov    0x2ce3(%rip),%rax
or     (%rax),%edx
mov    0x2d12(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x40(%rbp),%r9
and    $0xfffffffffffff000,%r9
xor    %edi,%edi
mov    $0x1000,%esi
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x20(%rbp)
jne    1361 <main+0x1b1>
jmp    130d <main+0x15d>
mov    0x2cac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2c98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%r8d
mov    %rax,%r9
lea    0xdb9(%rip),%rsi
mov    $0x51,%edx
lea    0xdd2(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
and    $0xfff,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    142a <main+0x27a>
mov    -0x44(%rbp),%eax
mov    %eax,-0x58(%rbp)
sub    $0x62,%eax
je     13b7 <main+0x207>
jmp    1395 <main+0x1e5>
mov    -0x58(%rbp),%eax
sub    $0x68,%eax
je     13c5 <main+0x215>
jmp    13a6 <main+0x1f6>
mov    -0x58(%rbp),%eax
sub    $0x77,%eax
je     13d3 <main+0x223>
jmp    13e1 <main+0x231>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1405 <main+0x255>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1405 <main+0x255>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1405 <main+0x255>
mov    0x2bd8(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %eax,%esi
mov    -0x2c(%rbp),%edx
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
cmpl   $0x4,-0x8(%rbp)
jle    14c2 <main+0x312>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10b0 <strtoul@plt>
mov    %eax,-0x30(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x62,%eax
je     147e <main+0x2ce>
jmp    145c <main+0x2ac>
mov    -0x5c(%rbp),%eax
sub    $0x68,%eax
je     148c <main+0x2dc>
jmp    146d <main+0x2bd>
mov    -0x5c(%rbp),%eax
sub    $0x77,%eax
je     149a <main+0x2ea>
jmp    14a3 <main+0x2f3>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    14a3 <main+0x2f3>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    14a3 <main+0x2f3>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%esi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2aed(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1000,%esi
call   1090 <munmap@plt>
cmp    $0xffffffff,%eax
jne    1532 <main+0x382>
jmp    14de <main+0x32e>
mov    0x2adb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2ac7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2abb(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%r8d
mov    %rax,%r9
lea    0xbe8(%rip),%rsi
mov    $0x7f,%edx
lea    0xc01(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x70,%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,%r13
cmp    $0x2,%edi
jle    1315 <main+0x165>
mov    %edi,%ebp
mov    0x8(%r13),%rbx
mov    0x10(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,%r14
mov    $0x77,%r12d
cmp    $0x3,%ebp
je     11f7 <main+0x47>
mov    0x18(%r13),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
mov    %eax,%r12d
mov    0x2dda(%rip),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     133a <main+0x18a>
mov    0x2dd7(%rip),%rsi
mov    0x2d88(%rip),%rcx
mov    (%rcx),%edx
or     (%rsi),%edx
mov    0x2db5(%rip),%rcx
mov    (%rcx),%ecx
mov    %r14,%r9
and    $0xfffffffffffff000,%r9
mov    $0x1000,%esi
xor    %edi,%edi
mov    %eax,0x4(%rsp)
mov    %eax,%r8d
call   1030 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     136a <main+0x1ba>
mov    %rax,%rbx
mov    %r14d,%r15d
and    $0xfff,%r15d
cmp    $0x4,%ebp
ja     12a1 <main+0xf1>
lea    -0x62(%r12),%eax
cmp    $0x15,%eax
ja     13df <main+0x22f>
mov    $0x200041,%ecx
bt     %eax,%ecx
jae    13df <main+0x22f>
mov    (%rbx,%r15,1),%edx
lea    0xf39(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12d7 <main+0x127>
mov    0x20(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
add    $0xffffff9e,%r12d
cmp    $0x15,%r12d
ja     12c7 <main+0x117>
mov    $0x200041,%ecx
bt     %r12d,%ecx
jae    12c7 <main+0x117>
mov    %eax,(%rbx,%r15,1)
lea    0xf1d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    $0x1000,%esi
mov    %rbx,%rdi
call   1090 <munmap@plt>
cmp    $0xffffffff,%eax
je     139a <main+0x1ea>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xcd7(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%ebx
mov    0x2c6e(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10d0 <strerror@plt>
lea    0xda3(%rip),%rsi
lea    0xdc1(%rip),%rcx
mov    %ebx,%edi
mov    $0x49,%edx
jmp    13c8 <main+0x218>
mov    0x2c4f(%rip),%rax
mov    (%rax),%ebx
mov    0x2c3e(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10d0 <strerror@plt>
lea    0xd73(%rip),%rsi
lea    0xd91(%rip),%rcx
mov    %ebx,%edi
mov    $0x51,%edx
jmp    13c8 <main+0x218>
mov    0x2c1f(%rip),%rax
mov    (%rax),%ebx
mov    0x2c0e(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10d0 <strerror@plt>
lea    0xd43(%rip),%rsi
lea    0xd61(%rip),%rcx
mov    %ebx,%edi
mov    $0x7f,%edx
mov    %ebp,%r8d
mov    %rax,%r9
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [253 x i8] c"\0AUsage:\09%s { sys file } { offset } [ type [ data ] ]\0A\09sys file: sysfs file for the pci resource to act on\0A\09offset : offset into pci memory region to act upon\0A\09type : access operation type : [b]yte, [h]alfword, [w]ord\0A\09data : data to be written\0A\0A\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.1 = [37 x i8] c"Error at line %d, file %s (%d) [%s]\0A\00"
@.str.2 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/InnoRoute/packages/refs/heads/master/pcimem/src/pcimem.c\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.3 = [25 x i8] c"Illegal data type '%c'.\0A\00"
@.str.4 = [29 x i8] c"Value at offset 0x%X : 0x%X\0A\00"
@stdout = global i32 0
@.str.5 = [14 x i8] c"Written 0x%X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 119, i32* %13
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([253 x i8], [253 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %11
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i8* @strtoul(i8* %29, i32 0, i32 0)
%31 = ptrtoint i8* %30 to i64
store i64 %31, i64* %12
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 3
br i1 %33, label %34, label %41
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = call i32 @tolower(i8 signext %39)
store i32 %40, i32* %13
br label %41
41: ; preds = %34, %23
%42 = load i8*, i8** %11
%43 = load i32, i32* @O_RDWR
%44 = load i32, i32* @O_SYNC
%45 = or i32 %43, %44
%46 = call i32 @open(i8* %42, i32 %45)
store i32 %46, i32* %6
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %57
48: ; preds = %41
br label %49
49: ; preds = %48
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = load i32, i32* @errno
%53 = call i8* @strerror(i32 %52)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %51, i8* %53)
%55 = call i32 @exit(i32 1)
unreachable
56: ; No predecessors!
br label %57
57: ; preds = %56, %41
%58 = load i32, i32* @PROT_READ
%59 = load i32, i32* @PROT_WRITE
%60 = or i32 %58, %59
%61 = load i32, i32* @MAP_SHARED
%62 = load i32, i32* %6
%63 = load i64, i64* %12
%64 = and i64 %63, -4096
%65 = call i8* @mmap(i32 0, i64 4096, i32 %60, i32 %61, i32 %62, i64 %64)
store i8* %65, i8** %7
%66 = load i8*, i8** %7
%67 = icmp eq i8* %66, inttoptr (i64 -1 to i8*)
br i1 %67, label %68, label %77
68: ; preds = %57
br label %69
69: ; preds = %68
%70 = load i32, i32* @stderr
%71 = load i32, i32* @errno
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %71, i8* %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; No predecessors!
br label %77
77: ; preds = %76, %57
%78 = load i8*, i8** %7
%79 = load i64, i64* %12
%80 = and i64 %79, 4095
%81 = getelementptr i8, i8* %78, i64 %80
store i8* %81, i8** %8
%82 = load i32, i32* %4
%83 = icmp slt i32 %82, 5
br i1 %83, label %84, label %110
84: ; preds = %77
%85 = load i32, i32* %13
switch i32 %85, label %98 [
i32 98, label %86
i32 104, label %90
i32 119, label %94
]
86: ; preds = %84
%87 = load i8*, i8** %8
%88 = bitcast i8* %87 to i32*
%89 = load i32, i32* %88
store i32 %89, i32* %9
br label %103
90: ; preds = %84
%91 = load i8*, i8** %8
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %92
store i32 %93, i32* %9
br label %103
94: ; preds = %84
%95 = load i8*, i8** %8
%96 = bitcast i8* %95 to i32*
%97 = load i32, i32* %96
store i32 %97, i32* %9
br label %103
98: ; preds = %84
%99 = load i32, i32* @stderr
%100 = load i32, i32* %13
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %100)
%102 = call i32 @exit(i32 2)
unreachable
103: ; preds = %94, %90, %86
%104 = load i64, i64* %12
%105 = trunc i64 %104 to i32
%106 = load i32, i32* %9
%107 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %105, i32 %106)
%108 = load i32, i32* @stdout
%109 = call i32 @fflush(i32 %108)
br label %110
110: ; preds = %103, %77
%111 = load i32, i32* %4
%112 = icmp sgt i32 %111, 4
br i1 %112, label %113, label %137
113: ; preds = %110
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 4
%116 = load i8*, i8** %115
%117 = call i8* @strtoul(i8* %116, i32 0, i32 0)
%118 = ptrtoint i8* %117 to i32
store i32 %118, i32* %10
%119 = load i32, i32* %13
switch i32 %119, label %132 [
i32 98, label %120
i32 104, label %124
i32 119, label %128
]
120: ; preds = %113
%121 = load i32, i32* %10
%122 = load i8*, i8** %8
%123 = bitcast i8* %122 to i32*
store i32 %121, i32* %123
br label %132
124: ; preds = %113
%125 = load i32, i32* %10
%126 = load i8*, i8** %8
%127 = bitcast i8* %126 to i32*
store i32 %125, i32* %127
br label %132
128: ; preds = %113
%129 = load i32, i32* %10
%130 = load i8*, i8** %8
%131 = bitcast i8* %130 to i32*
store i32 %129, i32* %131
br label %132
132: ; preds = %113, %128, %124, %120
%133 = load i32, i32* %10
%134 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %133)
%135 = load i32, i32* @stdout
%136 = call i32 @fflush(i32 %135)
br label %137
137: ; preds = %132, %110
%138 = load i8*, i8** %7
%139 = call i32 @munmap(i8* %138, i64 4096)
%140 = icmp eq i32 %139, -1
br i1 %140, label %141, label %150
141: ; preds = %137
br label %142
142: ; preds = %141
%143 = load i32, i32* @stderr
%144 = load i32, i32* @errno
%145 = load i32, i32* @errno
%146 = call i8* @strerror(i32 %145)
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %144, i8* %146)
%148 = call i32 @exit(i32 1)
unreachable
149: ; No predecessors!
br label %150
150: ; preds = %149, %137
%151 = load i32, i32* %6
%152 = call i32 @close(i32 %151)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [253 x i8] c"\0AUsage:\09%s { sys file } { offset } [ type [ data ] ]\0A\09sys file: sysfs file for the pci resource to act on\0A\09offset : offset into pci memory region to act upon\0A\09type : access operation type : [b]yte, [h]alfword, [w]ord\0A\09data : data to be written\0A\0A\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.1 = [37 x i8] c"Error at line %d, file %s (%d) [%s]\0A\00"
@.str.2 = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/InnoRoute/packages/refs/heads/master/pcimem/src/pcimem.c\00"
@errno = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.3 = [25 x i8] c"Illegal data type '%c'.\0A\00"
@.str.4 = [29 x i8] c"Value at offset 0x%X : 0x%X\0A\00"
@stdout = global i32 0
@.str.5 = [14 x i8] c"Written 0x%X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([253 x i8], [253 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i8* @strtoul(i8* %13, i32 0, i32 0)
%15 = ptrtoint i8* %14 to i64
%16 = icmp eq i32 %0, 3
br i1 %16, label %22, label %17
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = load i8, i8* %19
%21 = tail call i32 @tolower(i8 signext %20)
br label %22
22: ; preds = %17, %9
%23 = phi i32 [ %21, %17 ], [ 119, %9 ]
%24 = load i32, i32* @O_RDWR
%25 = load i32, i32* @O_SYNC
%26 = or i32 %25, %24
%27 = tail call i32 @open(i8* %11, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = tail call i8* @strerror(i32 %31)
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %31, i8* %32)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %22
%36 = load i32, i32* @PROT_READ
%37 = load i32, i32* @PROT_WRITE
%38 = or i32 %37, %36
%39 = load i32, i32* @MAP_SHARED
%40 = and i64 %15, -4096
%41 = tail call i8* @mmap(i32 0, i64 4096, i32 %38, i32 %39, i32 %27, i64 %40)
%42 = icmp eq i8* %41, inttoptr (i64 -1 to i8*)
br i1 %42, label %43, label %49
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = tail call i8* @strerror(i32 %45)
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 81, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %45, i8* %46)
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %35
%50 = and i64 %15, 4095
%51 = getelementptr i8, i8* %41, i64 %50
%52 = icmp ult i32 %0, 5
br i1 %52, label %53, label %63
53: ; preds = %49
switch i32 %23, label %54 [
i32 98, label %58
i32 104, label %58
i32 119, label %58
]
54: ; preds = %53
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%57 = tail call i32 @exit(i32 2)
unreachable
58: ; preds = %53, %53, %53
%59 = bitcast i8* %51 to i32*
%60 = load i32, i32* %59
%61 = trunc i64 %15 to i32
%62 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %61, i32 %60)
br label %73
63: ; preds = %49
%64 = getelementptr inbounds i8*, i8** %1, i64 4
%65 = load i8*, i8** %64
%66 = tail call i8* @strtoul(i8* %65, i32 0, i32 0)
%67 = ptrtoint i8* %66 to i64
%68 = trunc i64 %67 to i32
switch i32 %23, label %71 [
i32 98, label %69
i32 104, label %69
i32 119, label %69
]
69: ; preds = %63, %63, %63
%70 = bitcast i8* %51 to i32*
store i32 %68, i32* %70
br label %71
71: ; preds = %69, %63
%72 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %68)
br label %73
73: ; preds = %58, %71
%74 = load i32, i32* @stdout
%75 = tail call i32 @fflush(i32 %74)
%76 = tail call i32 @munmap(i8* %41, i64 4096)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %84
78: ; preds = %73
%79 = load i32, i32* @stderr
%80 = load i32, i32* @errno
%81 = tail call i8* @strerror(i32 %80)
%82 = tail call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.2, i64 0, i64 0), i32 %80, i8* %81)
%83 = tail call i32 @exit(i32 1)
unreachable
84: ; preds = %73
%85 = tail call i32 @close(i32 %27)
ret i32 0
}