#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 void *uint64_t;
typedef void *uint32_t;
struct stat {
  int st_size;
};
typedef int off_t;

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fstat(int, struct stat *);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void *strtoul(char *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ tolower(int);
int main(int argc, char *argv[]) {
  int priv2;
  struct stat sb;
  void *memblk, *adr;
  off_t offset;
  int type;
  uint64_t val64;
  uint32_t val32;
  if (argc < 3) {
    printf("Usage: mmio <r,w> <adr> <Region_file> [dat]\n\n");
    exit(-1);
  }
  if ((priv2 = open(argv[3], O_RDWR)) < 0) {
    printf("Can not open %s\n", argv[1]);
    exit(-1);
  }
  fstat(priv2, &sb);
  memblk = mmap(NULL, sb.st_size, PROT_WRITE | PROT_READ, MAP_SHARED, priv2, 0);
  if (memblk == MAP_FAILED) {
    printf("Can not mmap %s\n", argv[1]);
    exit(-1);
  }
  type = 0;
  if (tolower(argv[1][0] == 'd')) {
    type++;
  }
  if (argc == 5) {
    type += 2;
  }
  offset = strtoul(argv[2], 0, 0);
  adr = memblk + (offset & (sb.st_size - 1));
  printf("\n");
  switch (type) {
  case 0:
    val32 = *((uint32_t *)adr);
    printf("Reading word : [%jx]= 0x%08jx\n", adr, val32);
    break;
  case 1:
    val64 = *((uint64_t *)adr);
    printf("Reading double : [%jx]= 0x%016jx\n", adr, val64);
    break;
  case 2:
    val32 = strtoul(argv[4], 0, 0);
    *((uint32_t *)adr) = val32;
    printf("Writing word : [%jx]= 0x%08jx\n", adr, val32);
    break;
  case 3:
    val64 = strtoul(argv[4], 0, 0);
    *((uint64_t *)adr) = val64;
    printf("Writing double : [%jx]= 0x%016jx\n", adr, val64);
    break;
  other:
    printf("Invalid Parms\n");
    exit(-1);
    break;
  }
  munmap(memblk, sb.st_size);
  printf("\n");
  close(priv2);
}


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)
cmpl   $0x3,-0x8(%rbp)
jge    11c8 <main+0x38>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    120a <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10b0 <fstat@plt>
mov    -0x18(%rbp),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
mov    0x2dcf(%rip),%rax
or     (%rax),%edx
mov    0x2db6(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2d6d(%rip),%rcx
cmp    (%rcx),%rax
jne    127c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <tolower@plt>
cmp    $0x0,%rax
je     12b1 <main+0x121>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    12c4 <main+0x134>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %edx,%edx
mov    %edx,-0x4c(%rbp)
mov    %edx,%esi
call   1090 <strtoul@plt>
mov    %rax,%rcx
mov    -0x4c(%rbp),%eax
mov    %ecx,-0x2c(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%esi
add    $0xffffffff,%esi
and    %esi,%edx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xd3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x3,%rax
ja     13e8 <main+0x258>
mov    -0x48(%rbp),%rax
lea    0xcde(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e8 <main+0x258>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e8 <main+0x258>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <strtoul@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e8 <main+0x258>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <strtoul@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1070 <munmap@plt>
lea    0xc41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    1311 <main+0x161>
mov    %rsi,%r13
mov    %edi,%ebx
mov    0x18(%rsi),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
test   %eax,%eax
js     1327 <main+0x177>
mov    %eax,%r15d
mov    %rsp,%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
mov    (%rsp),%r14d
mov    0x2dcd(%rip),%rax
mov    0x2df6(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ddb(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14d,%esi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r12
mov    0x2d97(%rip),%rax
mov    0x8(%r13),%rsi
cmp    (%rax),%r12
je     1334 <main+0x184>
xor    %edi,%edi
cmpb   $0x64,(%rsi)
sete   %dil
call   1080 <tolower@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0x2(%rcx),%ebp
cmp    $0x5,%ebx
cmovne %ecx,%ebp
mov    0x10(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
lea    -0x1(%r14),%ecx
and    %eax,%ecx
movslq %ecx,%rbx
add    %r12,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd81(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    (%rbx),%rdx
lea    0xda0(%rip),%rdi
mov    %rbx,%rsi
jmp    12dc <main+0x12c>
mov    0x20(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,(%rbx)
lea    0xdc5(%rip),%rdi
jmp    12d6 <main+0x126>
mov    (%rbx),%rdx
lea    0xd97(%rip),%rdi
mov    %rbx,%rsi
jmp    12dc <main+0x12c>
mov    0x20(%r13),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,(%rbx)
lea    0xdbc(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1090 <munmap@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd9c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    0x8(%r13),%rsi
lea    0xcde(%rip),%rdi
jmp    133b <main+0x18b>
lea    0xce6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [46 x i8] c"Usage: mmio <r,w> <adr> <Region_file> [dat]\0A\0A\00"
@O_RDWR = global i32 0
@.str.1 = [17 x i8] c"Can not open %s\0A\00"
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [17 x i8] c"Can not mmap %s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [31 x i8] c"Reading word : [%jx]= 0x%08jx\0A\00"
@.str.5 = [34 x i8] c"Reading double : [%jx]= 0x%016jx\0A\00"
@.str.6 = [31 x i8] c"Writing word : [%jx]= 0x%08jx\0A\00"
@.str.7 = [34 x i8] c"Writing double : [%jx]= 0x%016jx\0A\00"
@.str.8 = [15 x i8] c"Invalid Parms\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDWR
%24 = call i32 @open(i8* %22, i32 %23)
store i32 %24, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %19
%33 = load i32, i32* %6
%34 = call i32 @fstat(i32 %33, %struct.stat* %7)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%36 = load i32, i32* %35
%37 = load i32, i32* @PROT_WRITE
%38 = load i32, i32* @PROT_READ
%39 = or i32 %37, %38
%40 = load i32, i32* @MAP_SHARED
%41 = load i32, i32* %6
%42 = call i8* @mmap(i32* null, i32 %36, i32 %39, i32 %40, i32 %41, i32 0)
store i8* %42, i8** %8
%43 = load i8*, i8** %8
%44 = load i8*, i8** @MAP_FAILED
%45 = icmp eq i8* %43, %44
br i1 %45, label %46, label %52
46: ; preds = %32
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %32
store i32 0, i32* %11
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 100
%60 = zext i1 %59 to i32
%61 = call i64 @tolower(i32 %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %52
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %66
66: ; preds = %63, %52
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 5
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i32, i32* %11
%71 = add nsw i32 %70, 2
store i32 %71, i32* %11
br label %72
72: ; preds = %69, %66
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i8* @strtoul(i8* %75, i32 0, i32 0)
%77 = ptrtoint i8* %76 to i32
store i32 %77, i32* %10
%78 = load i8*, i8** %8
%79 = load i32, i32* %10
%80 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%81 = load i32, i32* %80
%82 = sub nsw i32 %81, 1
%83 = and i32 %79, %82
%84 = sext i32 %83 to i64
%85 = getelementptr i8, i8* %78, i64 %84
store i8* %85, i8** %9
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%87 = load i32, i32* %11
switch i32 %87, label %127 [
i32 0, label %88
i32 1, label %95
i32 2, label %102
i32 3, label %113
]
88: ; preds = %72
%89 = load i8*, i8** %9
%90 = bitcast i8* %89 to i8**
%91 = load i8*, i8** %90
store i8* %91, i8** %13
%92 = load i8*, i8** %9
%93 = load i8*, i8** %13
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %92, i8* %93)
br label %127
95: ; preds = %72
%96 = load i8*, i8** %9
%97 = bitcast i8* %96 to i8**
%98 = load i8*, i8** %97
store i8* %98, i8** %12
%99 = load i8*, i8** %9
%100 = load i8*, i8** %12
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %99, i8* %100)
br label %127
102: ; preds = %72
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 4
%105 = load i8*, i8** %104
%106 = call i8* @strtoul(i8* %105, i32 0, i32 0)
store i8* %106, i8** %13
%107 = load i8*, i8** %13
%108 = load i8*, i8** %9
%109 = bitcast i8* %108 to i8**
store i8* %107, i8** %109
%110 = load i8*, i8** %9
%111 = load i8*, i8** %13
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %110, i8* %111)
br label %127
113: ; preds = %72
%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)
store i8* %117, i8** %12
%118 = load i8*, i8** %12
%119 = load i8*, i8** %9
%120 = bitcast i8* %119 to i8**
store i8* %118, i8** %120
%121 = load i8*, i8** %9
%122 = load i8*, i8** %12
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %121, i8* %122)
br label %127
124: ; No predecessors!
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%126 = call i32 @exit(i32 -1)
unreachable
127: ; preds = %72, %113, %102, %95, %88
%128 = load i8*, i8** %8
%129 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%130 = load i32, i32* %129
%131 = call i32 @munmap(i8* %128, i32 %130)
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%133 = load i32, i32* %6
%134 = call i32 @close(i32 %133)
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@.str.1 = [17 x i8] c"Can not open %s\0A\00"
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [17 x i8] c"Can not mmap %s\0A\00"
@.str.4 = [31 x i8] c"Reading word : [%jx]= 0x%08jx\0A\00"
@.str.5 = [34 x i8] c"Reading double : [%jx]= 0x%016jx\0A\00"
@.str.6 = [31 x i8] c"Writing word : [%jx]= 0x%08jx\0A\00"
@.str.7 = [34 x i8] c"Writing double : [%jx]= 0x%016jx\0A\00"
@str = [45 x i8] c"Usage: mmio <r,w> <adr> <Region_file> [dat]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDWR
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %9
%21 = call i32 @fstat(i32 %13, %struct.stat* %3)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @PROT_WRITE
%25 = load i32, i32* @PROT_READ
%26 = or i32 %25, %24
%27 = load i32, i32* @MAP_SHARED
%28 = tail call i8* @mmap(i32* null, i32 %23, i32 %26, i32 %27, i32 %13, i32 0)
%29 = load i8*, i8** @MAP_FAILED
%30 = icmp eq i8* %28, %29
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
br i1 %30, label %33, label %36
33: ; preds = %20
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%35 = tail call i32 @exit(i32 -1)
unreachable
36: ; preds = %20
%37 = load i8, i8* %32
%38 = icmp eq i8 %37, 100
%39 = zext i1 %38 to i32
%40 = tail call i64 @tolower(i32 %39)
%41 = icmp ne i64 %40, 0
%42 = zext i1 %41 to i32
%43 = icmp eq i32 %0, 5
%44 = or i32 %42, 2
%45 = select i1 %43, i32 %44, i32 %42
%46 = getelementptr inbounds i8*, i8** %1, i64 2
%47 = load i8*, i8** %46
%48 = tail call i8* @strtoul(i8* %47, i32 0, i32 0)
%49 = ptrtoint i8* %48 to i64
%50 = trunc i64 %49 to i32
%51 = add nsw i32 %23, -1
%52 = and i32 %51, %50
%53 = sext i32 %52 to i64
%54 = getelementptr i8, i8* %28, i64 %53
%55 = tail call i32 @putchar(i32 10)
switch i32 %45, label %76 [
i32 0, label %56
i32 1, label %60
i32 2, label %64
i32 3, label %70
]
56: ; preds = %36
%57 = bitcast i8* %54 to i8**
%58 = load i8*, i8** %57
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %54, i8* %58)
br label %77
60: ; preds = %36
%61 = bitcast i8* %54 to i8**
%62 = load i8*, i8** %61
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %54, i8* %62)
br label %77
64: ; preds = %36
%65 = getelementptr inbounds i8*, i8** %1, i64 4
%66 = load i8*, i8** %65
%67 = tail call i8* @strtoul(i8* %66, i32 0, i32 0)
%68 = bitcast i8* %54 to i8**
store i8* %67, i8** %68
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %54, i8* %67)
br label %77
70: ; preds = %36
%71 = getelementptr inbounds i8*, i8** %1, i64 4
%72 = load i8*, i8** %71
%73 = tail call i8* @strtoul(i8* %72, i32 0, i32 0)
%74 = bitcast i8* %54 to i8**
store i8* %73, i8** %74
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %54, i8* %73)
br label %77
76: ; preds = %36
unreachable
77: ; preds = %70, %64, %60, %56
%78 = tail call i32 @munmap(i8* %28, i32 %23)
%79 = tail call i32 @putchar(i32 10)
%80 = tail call i32 @close(i32 %13)
ret i32 0
}