#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 u_int32_t;

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ show_usage();
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  void *virtual_base;
  void *h2p_lw_axi_mem_addr = NULL;
  int fd;
  u_int32_t index, inval;
  if ((fd = open("/dev/uio0", (O_RDWR | O_SYNC))) == -1) {
    printf("    ERROR: could not open \"/dev/uio0\"...\n");
    return (1);
  }
  virtual_base =
      mmap(NULL, (65536), (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
  if (virtual_base == MAP_FAILED) {
    printf("    ERROR: mmap() failed...\n");
    close(fd);
    return (1);
  }
  h2p_lw_axi_mem_addr = virtual_base;
  if (argc > 2) {
    if (argv[2][0] == '0' && argv[2][1] == 'x') {
      printf("Hex address value input found\n");
      index = (u_int32_t)strtoul(argv[2], NULL, 16);
    } else {
      printf("Assuming decimal address value input\n");
      index = (u_int32_t)strtoul(argv[2], NULL, 10);
    }
    u_int32_t value = *((u_int32_t *)(h2p_lw_axi_mem_addr + index));
    switch (argv[1][1]) {
    case 'r':
      printf("Read: ");
      printf("Address   0x%08X\t%u\n \tvalue = 0x%08X\t%u \n", index, index,
             value, value);
      break;
    case 'w':
      if (argc == 4) {
        printf("Write: ");
        if (argv[3][0] == '0' && argv[3][1] == 'x') {
          inval = (u_int32_t)strtoul(argv[3], NULL, 16);
        } else {
          inval = (u_int32_t)strtoul(argv[3], NULL, 10);
        }
        *((u_int32_t *)(h2p_lw_axi_mem_addr + index)) = inval;
        printf("Wrote:  0x%08X\t %u\tto Address --> 0x%08X\t%u \n", inval,
               inval, index, index);
      } else {
        printf("Value missing use: mksocmemio -h to show valid options and "
               "argunemts\n");
      }
      break;
    default:
      printf("Wrong option: %s\n use: mksocmemio -h to show valid options and "
             "argunemts\n",
             argv[1]);
      break;
    }
  } else if (argc == 2) {
    switch (argv[1][1]) {
    case 'h':
      show_usage();
      break;
    default:
      printf("Wrong option %s\n use: mksocmemio -h to show valid options and "
             "argunemts\n",
             argv[1]);
      break;
    }
  }
  close(fd);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    0x2e42(%rip),%rax
or     (%rax),%esi
lea    0xe69(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    11c2 <main+0x62>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1455 <main+0x2f5>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
mov    0x2dee(%rip),%rax
or     (%rax),%edx
mov    0x2e0d(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x10000,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
jne    122c <main+0xcc>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1455 <main+0x2f5>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    13f8 <main+0x298>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1293 <main+0x133>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    1293 <main+0x133>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x28(%rbp)
jmp    12ba <main+0x15a>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x34(%rbp)
sub    $0x72,%eax
je     12f6 <main+0x196>
jmp    12e5 <main+0x185>
mov    -0x34(%rbp),%eax
sub    $0x77,%eax
je     1324 <main+0x1c4>
jmp    13dd <main+0x27d>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f3 <main+0x293>
cmpl   $0x4,-0x8(%rbp)
jne    13ca <main+0x26a>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1383 <main+0x223>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    1383 <main+0x223>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
jmp    139c <main+0x23c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x2c(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d8 <main+0x278>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f3 <main+0x293>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1446 <main+0x2e6>
cmpl   $0x2,-0x8(%rbp)
jne    1441 <main+0x2e1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x1(%rax),%al
sub    $0x68,%al
jne    1426 <main+0x2c6>
jmp    141a <main+0x2ba>
mov    $0x0,%al
call   1060 <show_usage@plt>
jmp    143c <main+0x2dc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1441 <main+0x2e1>
jmp    1446 <main+0x2e6>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e54(%rip),%rax
mov    0x2e45(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe6a(%rip),%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     1201 <main+0x91>
mov    %eax,%ebx
mov    0x2e4f(%rip),%rax
mov    0x2e10(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e2d(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x10000,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r15
mov    0x2ddf(%rip),%rax
cmp    (%rax),%r15
je     1217 <main+0xa7>
cmp    $0x3,%ebp
jl     1234 <main+0xc4>
mov    0x10(%r14),%rax
cmpb   $0x30,(%rax)
jne    1257 <main+0xe7>
cmpb   $0x78,0x1(%rax)
jne    1257 <main+0xe7>
mov    $0x10,%r12d
lea    0xf6f(%rip),%rdi
jmp    1264 <main+0xf4>
lea    0xfa0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1331 <main+0x1c1>
lea    0xf6e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    $0x1,%eax
jmp    1331 <main+0x1c1>
cmp    $0x2,%ebp
jne    1328 <main+0x1b8>
mov    0x8(%r14),%rsi
cmpb   $0x68,0x1(%rsi)
jne    130c <main+0x19c>
xor    %eax,%eax
call   1070 <show_usage@plt>
jmp    1328 <main+0x1b8>
mov    $0xa,%r12d
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%r14),%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1090 <strtoul@plt>
movslq %eax,%r12
mov    0x8(%r14),%rsi
movsbl 0x1(%rsi),%eax
cmp    $0x77,%eax
je     12b2 <main+0x142>
cmp    $0x72,%eax
jne    1303 <main+0x193>
mov    (%r15,%r12,1),%ebp
lea    0xd73(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd6c(%rip),%rdi
mov    %r12d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
jmp    12fa <main+0x18a>
cmp    $0x4,%ebp
jne    131c <main+0x1ac>
lea    0xd7d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%r14),%rdi
cmpb   $0x30,(%rdi)
jne    12d9 <main+0x169>
mov    $0x10,%edx
cmpb   $0x78,0x1(%rdi)
je     12de <main+0x16e>
mov    $0xa,%edx
xor    %esi,%esi
call   1090 <strtoul@plt>
mov    %eax,(%r15,%r12,1)
lea    0xd53(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %r12d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1328 <main+0x1b8>
lea    0xd67(%rip),%rdi
jmp    1313 <main+0x1a3>
lea    0xda8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1328 <main+0x1b8>
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/uio0\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.1 = [42 x i8] c" ERROR: could not open \22/dev/uio0\22...\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [29 x i8] c" ERROR: mmap() failed...\0A\00"
@.str.3 = [31 x i8] c"Hex address value input found\0A\00"
@.str.4 = [38 x i8] c"Assuming decimal address value input\0A\00"
@.str.5 = [7 x i8] c"Read: \00"
@.str.6 = [42 x i8] c"Address 0x%08X\09%u\0A \09value = 0x%08X\09%u \0A\00"
@.str.7 = [8 x i8] c"Write: \00"
@.str.8 = [46 x i8] c"Wrote: 0x%08X\09 %u\09to Address --> 0x%08X\09%u \0A\00"
@.str.9 = [70 x i8] c"Value missing use: mksocmemio -h to show valid options and argunemts\0A\00"
@.str.10 = [74 x i8] c"Wrong option: %s\0A use: mksocmemio -h to show valid options and argunemts\0A\00"
@.str.11 = [73 x i8] c"Wrong option %s\0A use: mksocmemio -h to show valid options and argunemts\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_SYNC
%14 = or i32 %12, %13
%15 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 %15, i32* %8
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %162
19: ; preds = %2
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @PROT_WRITE
%22 = or i32 %20, %21
%23 = load i32, i32* @MAP_SHARED
%24 = load i32, i32* %8
%25 = call i8* @mmap(i32* null, i32 65536, i32 %22, i32 %23, i32 %24, i32 0)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = load i8*, i8** @MAP_FAILED
%28 = icmp eq i8* %26, %27
br i1 %28, label %29, label %33
29: ; preds = %19
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %8
%32 = call i32 @close(i32 %31)
store i32 1, i32* %3
br label %162
33: ; preds = %19
%34 = load i8*, i8** %6
store i8* %34, i8** %7
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 2
br i1 %36, label %37, label %140
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 48
br i1 %44, label %45, label %60
45: ; preds = %37
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 120
br i1 %52, label %53, label %60
53: ; preds = %45
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i64 @strtoul(i8* %57, i32* null, i32 16)
%59 = trunc i64 %58 to i32
store i32 %59, i32* %9
br label %67
60: ; preds = %45, %37
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 2
%64 = load i8*, i8** %63
%65 = call i64 @strtoul(i8* %64, i32* null, i32 10)
%66 = trunc i64 %65 to i32
store i32 %66, i32* %9
br label %67
67: ; preds = %60, %53
%68 = load i8*, i8** %7
%69 = load i32, i32* %9
%70 = sext i32 %69 to i64
%71 = getelementptr i8, i8* %68, i64 %70
%72 = bitcast i8* %71 to i32*
%73 = load i32, i32* %72
store i32 %73, i32* %11
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
switch i32 %79, label %134 [
i32 114, label %80
i32 119, label %87
]
80: ; preds = %67
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%82 = load i32, i32* %9
%83 = load i32, i32* %9
%84 = load i32, i32* %11
%85 = load i32, i32* %11
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %82, i32 %83, i32 %84, i32 %85)
br label %139
87: ; preds = %67
%88 = load i32, i32* %4
%89 = icmp eq i32 %88, 4
br i1 %89, label %90, label %131
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 3
%94 = load i8*, i8** %93
%95 = getelementptr inbounds i8, i8* %94, i64 0
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp eq i32 %97, 48
br i1 %98, label %99, label %113
99: ; preds = %90
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 3
%102 = load i8*, i8** %101
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 120
br i1 %106, label %107, label %113
107: ; preds = %99
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 3
%110 = load i8*, i8** %109
%111 = call i64 @strtoul(i8* %110, i32* null, i32 16)
%112 = trunc i64 %111 to i32
store i32 %112, i32* %10
br label %119
113: ; preds = %99, %90
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 3
%116 = load i8*, i8** %115
%117 = call i64 @strtoul(i8* %116, i32* null, i32 10)
%118 = trunc i64 %117 to i32
store i32 %118, i32* %10
br label %119
119: ; preds = %113, %107
%120 = load i32, i32* %10
%121 = load i8*, i8** %7
%122 = load i32, i32* %9
%123 = sext i32 %122 to i64
%124 = getelementptr i8, i8* %121, i64 %123
%125 = bitcast i8* %124 to i32*
store i32 %120, i32* %125
%126 = load i32, i32* %10
%127 = load i32, i32* %10
%128 = load i32, i32* %9
%129 = load i32, i32* %9
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i32 %126, i32 %127, i32 %128, i32 %129)
br label %133
131: ; preds = %87
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.9, i64 0, i64 0))
br label %133
133: ; preds = %131, %119
br label %139
134: ; preds = %67
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 1
%137 = load i8*, i8** %136
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i8* %137)
br label %139
139: ; preds = %134, %133, %80
br label %159
140: ; preds = %33
%141 = load i32, i32* %4
%142 = icmp eq i32 %141, 2
br i1 %142, label %143, label %158
143: ; preds = %140
%144 = load i8**, i8*** %5
%145 = getelementptr inbounds i8*, i8** %144, i64 1
%146 = load i8*, i8** %145
%147 = getelementptr inbounds i8, i8* %146, i64 1
%148 = load i8, i8* %147
%149 = sext i8 %148 to i32
switch i32 %149, label %152 [
i32 104, label %150
]
150: ; preds = %143
%151 = call i32 (...) @show_usage()
br label %157
152: ; preds = %143
%153 = load i8**, i8*** %5
%154 = getelementptr inbounds i8*, i8** %153, i64 1
%155 = load i8*, i8** %154
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.11, i64 0, i64 0), i8* %155)
br label %157
157: ; preds = %152, %150
br label %158
158: ; preds = %157, %140
br label %159
159: ; preds = %158, %139
%160 = load i32, i32* %8
%161 = call i32 @close(i32 %160)
store i32 0, i32* %3
br label %162
162: ; preds = %159, %29, %17
%163 = load i32, i32* %3
ret i32 %163
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/uio0\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [7 x i8] c"Read: \00"
@.str.6 = [42 x i8] c"Address 0x%08X\09%u\0A \09value = 0x%08X\09%u \0A\00"
@.str.7 = [8 x i8] c"Write: \00"
@.str.8 = [46 x i8] c"Wrote: 0x%08X\09 %u\09to Address --> 0x%08X\09%u \0A\00"
@.str.10 = [74 x i8] c"Wrong option: %s\0A use: mksocmemio -h to show valid options and argunemts\0A\00"
@.str.11 = [73 x i8] c"Wrong option %s\0A use: mksocmemio -h to show valid options and argunemts\0A\00"
@str = [37 x i8] c"Assuming decimal address value input\00"
@str.12 = [69 x i8] c"Value missing use: mksocmemio -h to show valid options and argunemts\00"
@str.13 = [30 x i8] c"Hex address value input found\00"
@str.14 = [28 x i8] c" ERROR: mmap() failed...\00"
@str.15 = [41 x i8] c" ERROR: could not open \22/dev/uio0\22...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @O_RDWR
%4 = load i32, i32* @O_SYNC
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.15, i64 0, i64 0))
br label %89
10: ; preds = %2
%11 = load i32, i32* @PROT_READ
%12 = load i32, i32* @PROT_WRITE
%13 = or i32 %12, %11
%14 = load i32, i32* @MAP_SHARED
%15 = tail call i8* @mmap(i32* null, i32 65536, i32 %13, i32 %14, i32 %6, i32 0)
%16 = load i8*, i8** @MAP_FAILED
%17 = icmp eq i8* %15, %16
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.14, i64 0, i64 0))
%20 = tail call i32 @close(i32 %6)
br label %89
21: ; preds = %10
%22 = icmp sgt i32 %0, 2
br i1 %22, label %23, label %75
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 48
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 120
br i1 %31, label %33, label %32
32: ; preds = %28, %23
br label %33
33: ; preds = %28, %32
%34 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0), %32 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0), %28 ]
%35 = phi i32 [ 10, %32 ], [ 16, %28 ]
%36 = tail call i32 @puts(i8* dereferenceable(1) %34)
%37 = load i8*, i8** %24
%38 = tail call i64 @strtoul(i8* nocapture %37, i32* null, i32 %35)
%39 = trunc i64 %38 to i32
%40 = shl i64 %38, 32
%41 = ashr exact i64 %40, 32
%42 = getelementptr i8, i8* %15, i64 %41
%43 = bitcast i8* %42 to i32*
%44 = getelementptr inbounds i8*, i8** %1, i64 1
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
switch i32 %48, label %73 [
i32 114, label %49
i32 119, label %53
]
49: ; preds = %33
%50 = load i32, i32* %43
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %39, i32 %39, i32 %50, i32 %50)
br label %87
53: ; preds = %33
%54 = icmp eq i32 %0, 4
br i1 %54, label %55, label %71
55: ; preds = %53
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%57 = getelementptr inbounds i8*, i8** %1, i64 3
%58 = load i8*, i8** %57
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 48
br i1 %60, label %61, label %65
61: ; preds = %55
%62 = getelementptr inbounds i8, i8* %58, i64 1
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 120
br i1 %64, label %66, label %65
65: ; preds = %61, %55
br label %66
66: ; preds = %61, %65
%67 = phi i32 [ 10, %65 ], [ 16, %61 ]
%68 = tail call i64 @strtoul(i8* nocapture %58, i32* null, i32 %67)
%69 = trunc i64 %68 to i32
store i32 %69, i32* %43
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i32 %69, i32 %69, i32 %39, i32 %39)
br label %87
71: ; preds = %53
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.12, i64 0, i64 0))
br label %87
73: ; preds = %33
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i8* %45)
br label %87
75: ; preds = %21
%76 = icmp eq i32 %0, 2
br i1 %76, label %77, label %87
77: ; preds = %75
%78 = getelementptr inbounds i8*, i8** %1, i64 1
%79 = load i8*, i8** %78
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8, i8* %80
%82 = icmp eq i8 %81, 104
br i1 %82, label %83, label %85
83: ; preds = %77
%84 = tail call i32 (...) @show_usage()
br label %87
85: ; preds = %77
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.11, i64 0, i64 0), i8* %79)
br label %87
87: ; preds = %49, %73, %71, %66, %75, %85, %83
%88 = tail call i32 @close(i32 %6)
br label %89
89: ; preds = %87, %18, %8
%90 = phi i32 [ 1, %8 ], [ 1, %18 ], [ 0, %87 ]
ret i32 %90
}