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

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
scalar_t__ close(int);
unsigned int getpagesize();
void *mmap(int /*<<< orphan*/, size_t, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ munmap(void *, size_t);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int regio_wr32(unsigned int addr, unsigned int data, int verbose) {
  int fd;
  unsigned int page_size, mapped_pages;
  void *pmem;
  void *vaddr;
  volatile unsigned int *reg_addr;
  off_t phy_addr;
  size_t phy_length;
  if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) {
    printf("ERROR : failed to open /dev/mem\n");
    return (-1);
  }
  phy_addr = 0x43c00000;
  phy_length = (16 * 64 * 1024);
  page_size = getpagesize();
  mapped_pages = phy_length / page_size;
  if (verbose > 1) {
    printf("off_t size            : %lu\n", (long unsigned int)sizeof(off_t));
    printf("phy_addr & map_mask   : 0x%llx\n",
           (unsigned long long)(phy_addr & ~((off_t)((16 * 64 * 1024) - 1))));
    printf("page size             : 0x%x (%d)\n", page_size, page_size);
    printf("num pages             : %d\n", mapped_pages);
  }
  pmem = mmap(0, phy_length, (PROT_READ | PROT_WRITE), MAP_SHARED, fd,
              phy_addr & ~((off_t)((16 * 64 * 1024) - 1)));
  if ((pmem == MAP_FAILED) || (pmem == NULL)) {
    printf("ERROR: failed to mmap /dev/mem\n");
    return (-1);
  } else {
    if (verbose > 1) {
      printf("pmem                  : 0x%lx\n", (long unsigned int)pmem);
      printf("pmem (ptr)            : %p\n", pmem);
    }
  }
  if (close(fd)) {
    printf("ERROR: failed to close /dev/mem\n");
    return (-1);
  }
  vaddr = (void *)((char *)pmem + (phy_addr & ((off_t)((16 * 64 * 1024) - 1))));
  reg_addr = ((volatile unsigned int *)((char *)vaddr + addr));
  *reg_addr = data;
  if (verbose > 1) {
    printf("reg_addr              : 0x%08x\n", (unsigned int)reg_addr);
    printf("reg_data              : 0x%08x\n", data);
  }
  munmap(pmem, phy_length);
  if (verbose > 0)
    printf("HREG W 0x%08x 0x%08x\n", addr, data);
  return (0);
}


x86 assembly (clang, -O0):
<regio_wr32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    0x2e4f(%rip),%rax
or     (%rax),%esi
lea    0xe76(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11b5 <regio_wr32+0x55>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1398 <regio_wr32+0x238>
movl   $0x43c00000,-0x3c(%rbp)
movq   $0x100000,-0x48(%rbp)
mov    $0x0,%al
call   1080 <getpagesize@plt>
mov    %eax,-0x18(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x10(%rbp)
jle    1238 <regio_wr32+0xd8>
lea    0xe3c(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
and    $0xfff00000,%eax
movslq %eax,%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rsi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
mov    0x2d74(%rip),%rax
or     (%rax),%edx
mov    0x2d93(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
and    $0xfff00000,%r9d
xor    %edi,%edi
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2d3c(%rip),%rcx
cmp    (%rcx),%rax
je     1290 <regio_wr32+0x130>
cmpq   $0x0,-0x28(%rbp)
jne    12aa <regio_wr32+0x14a>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1398 <regio_wr32+0x238>
cmpl   $0x1,-0x10(%rbp)
jle    12d8 <regio_wr32+0x178>
mov    -0x28(%rbp),%rsi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12dd <regio_wr32+0x17d>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
je     1309 <regio_wr32+0x1a9>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1398 <regio_wr32+0x238>
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
and    $0xfffff,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x10(%rbp)
jle    1366 <regio_wr32+0x206>
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1060 <munmap@plt>
cmpl   $0x0,-0x10(%rbp)
jle    1391 <regio_wr32+0x231>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regio_wr32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r15d
mov    %edi,%r14d
mov    0x2e4d(%rip),%rax
mov    0x2e3e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xf87(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     12c8 <regio_wr32+0x158>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <getpagesize@plt>
cmp    $0x2,%r12d
jl     1210 <regio_wr32+0xa0>
mov    %eax,%ebp
mov    $0x100000,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%r13d
lea    0xe32(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    $0x43c00000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2de1(%rip),%rax
mov    0x2da2(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2dbf(%rip),%rax
mov    (%rax),%ecx
mov    $0x100000,%esi
xor    %edi,%edi
mov    %ebx,%r8d
mov    $0x43c00000,%r9d
call   1040 <mmap@plt>
test   %rax,%rax
je     12d1 <regio_wr32+0x161>
mov    %rax,%rbp
mov    0x2d65(%rip),%rax
cmp    (%rax),%rbp
je     12d1 <regio_wr32+0x161>
cmp    $0x2,%r12d
jl     12da <regio_wr32+0x16a>
lea    0xe17(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe25(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <close@plt>
test   %rax,%rax
jne    12e6 <regio_wr32+0x176>
mov    %r14d,%eax
mov    %rbp,%rsi
add    %rax,%rsi
mov    %r15d,0x0(%rbp,%rax,1)
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe28(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x100000,%esi
mov    %rbp,%rdi
call   1070 <munmap@plt>
jmp    1322 <regio_wr32+0x1b2>
lea    0xe7d(%rip),%rdi
jmp    12ed <regio_wr32+0x17d>
lea    0xe55(%rip),%rdi
jmp    12ed <regio_wr32+0x17d>
mov    %ebx,%edi
call   1060 <close@plt>
test   %rax,%rax
je     1308 <regio_wr32+0x198>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%eax
mov    %r15d,0x0(%rbp,%rax,1)
mov    $0x100000,%esi
mov    %rbp,%rdi
call   1070 <munmap@plt>
test   %r12d,%r12d
jle    133a <regio_wr32+0x1ca>
lea    0xdce(%rip),%rdi
xor    %ebx,%ebx
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12f7 <regio_wr32+0x187>
xor    %ebx,%ebx
jmp    12f7 <regio_wr32+0x187>

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.1 = [33 x i8] c"ERROR : failed to open /dev/mem\0A\00"
@.str.2 = [29 x i8] c"off_t size : %lu\0A\00"
@.str.3 = [32 x i8] c"phy_addr & map_mask : 0x%llx\0A\00"
@.str.4 = [35 x i8] c"page size : 0x%x (%d)\0A\00"
@.str.5 = [28 x i8] c"num pages : %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.6 = [32 x i8] c"ERROR: failed to mmap /dev/mem\0A\00"
@.str.7 = [31 x i8] c"pmem : 0x%lx\0A\00"
@.str.8 = [28 x i8] c"pmem (ptr) : %p\0A\00"
@.str.9 = [33 x i8] c"ERROR: failed to close /dev/mem\0A\00"
@.str.10 = [32 x i8] c"reg_addr : 0x%08x\0A\00"
@.str.11 = [32 x i8] c"reg_data : 0x%08x\0A\00"
@.str.12 = [22 x i8] c"HREG W 0x%08x 0x%08x\0A\00"
define i32 @regio_wr32(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_SYNC
%18 = or i32 %16, %17
%19 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 %19, i32* %8
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %109
23: ; preds = %3
store i32 1136656384, i32* %14
store i64 1048576, i64* %15
%24 = call i32 (...) @getpagesize()
store i32 %24, i32* %9
%25 = load i64, i64* %15
%26 = load i32, i32* %9
%27 = zext i32 %26 to i64
%28 = udiv i64 %25, %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* %10
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %43
32: ; preds = %23
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 4)
%34 = load i32, i32* %14
%35 = and i32 %34, -1048576
%36 = sext i32 %35 to i64
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %36)
%38 = load i32, i32* %9
%39 = load i32, i32* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %32, %23
%44 = load i64, i64* %15
%45 = load i32, i32* @PROT_READ
%46 = load i32, i32* @PROT_WRITE
%47 = or i32 %45, %46
%48 = load i32, i32* @MAP_SHARED
%49 = load i32, i32* %8
%50 = load i32, i32* %14
%51 = and i32 %50, -1048576
%52 = call i8* @mmap(i32 0, i64 %44, i32 %47, i32 %48, i32 %49, i32 %51)
store i8* %52, i8** %11
%53 = load i8*, i8** %11
%54 = load i8*, i8** @MAP_FAILED
%55 = icmp eq i8* %53, %54
br i1 %55, label %59, label %56
56: ; preds = %43
%57 = load i8*, i8** %11
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %61
59: ; preds = %56, %43
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %4
br label %109
61: ; preds = %56
%62 = load i32, i32* %7
%63 = icmp sgt i32 %62, 1
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i8*, i8** %11
%66 = ptrtoint i8* %65 to i64
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i64 %66)
%68 = load i8*, i8** %11
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %64, %61
br label %71
71: ; preds = %70
%72 = load i32, i32* %8
%73 = call i64 @close(i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %4
br label %109
77: ; preds = %71
%78 = load i8*, i8** %11
%79 = load i32, i32* %14
%80 = and i32 %79, 1048575
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
store i8* %82, i8** %12
%83 = load i8*, i8** %12
%84 = load i32, i32* %5
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = bitcast i8* %86 to i32*
store i32* %87, i32** %13
%88 = load i32, i32* %6
%89 = load i32*, i32** %13
store volatile i32 %88, i32* %89
%90 = load i32, i32* %7
%91 = icmp sgt i32 %90, 1
br i1 %91, label %92, label %98
92: ; preds = %77
%93 = load i32*, i32** %13
%94 = ptrtoint i32* %93 to i32
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %6
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %92, %77
%99 = load i8*, i8** %11
%100 = load i64, i64* %15
%101 = call i32 @munmap(i8* %99, i64 %100)
%102 = load i32, i32* %7
%103 = icmp sgt i32 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %98
%105 = load i32, i32* %5
%106 = load i32, i32* %6
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %105, i32 %106)
br label %108
108: ; preds = %104, %98
store i32 0, i32* %4
br label %109
109: ; preds = %108, %75, %59, %21
%110 = load i32, i32* %4
ret i32 %110
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [29 x i8] c"off_t size : %lu\0A\00"
@.str.3 = [32 x i8] c"phy_addr & map_mask : 0x%llx\0A\00"
@.str.4 = [35 x i8] c"page size : 0x%x (%d)\0A\00"
@.str.5 = [28 x i8] c"num pages : %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [31 x i8] c"pmem : 0x%lx\0A\00"
@.str.8 = [28 x i8] c"pmem (ptr) : %p\0A\00"
@.str.10 = [32 x i8] c"reg_addr : 0x%08x\0A\00"
@.str.11 = [32 x i8] c"reg_data : 0x%08x\0A\00"
@.str.12 = [22 x i8] c"HREG W 0x%08x 0x%08x\0A\00"
@str = [32 x i8] c"ERROR: failed to close /dev/mem\00"
@str.13 = [31 x i8] c"ERROR: failed to mmap /dev/mem\00"
@str.14 = [32 x i8] c"ERROR : failed to open /dev/mem\00"
define i32 @regio_wr32(i32 %0, i32 %1, i32 %2) {
%4 = load i32, i32* @O_RDWR
%5 = load i32, i32* @O_SYNC
%6 = or i32 %5, %4
%7 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.14, i64 0, i64 0))
br label %61
11: ; preds = %3
%12 = tail call i32 (...) @getpagesize()
%13 = icmp sgt i32 %2, 1
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = udiv i32 1048576, %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 4)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 1136656384)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %12, i32 %12)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %15)
br label %20
20: ; preds = %14, %11
%21 = load i32, i32* @PROT_READ
%22 = load i32, i32* @PROT_WRITE
%23 = or i32 %22, %21
%24 = load i32, i32* @MAP_SHARED
%25 = tail call i8* @mmap(i32 0, i64 1048576, i32 %23, i32 %24, i32 %7, i32 1136656384)
%26 = load i8*, i8** @MAP_FAILED
%27 = icmp eq i8* %25, %26
%28 = icmp eq i8* %25, null
%29 = or i1 %28, %27
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
br label %61
32: ; preds = %20
br i1 %13, label %33, label %39
33: ; preds = %32
%34 = ptrtoint i8* %25 to i64
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i64 %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %25)
%37 = tail call i64 @close(i32 %7)
%38 = icmp eq i64 %37, 0
br i1 %38, label %44, label %42
39: ; preds = %32
%40 = tail call i64 @close(i32 %7)
%41 = icmp eq i64 %40, 0
br i1 %41, label %53, label %42
42: ; preds = %39, %33
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %61
44: ; preds = %33
%45 = zext i32 %0 to i64
%46 = getelementptr inbounds i8, i8* %25, i64 %45
%47 = bitcast i8* %46 to i32*
store volatile i32 %1, i32* %47
%48 = ptrtoint i8* %46 to i64
%49 = trunc i64 %48 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %49)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %1)
%52 = tail call i32 @munmap(i8* %25, i64 1048576)
br label %59
53: ; preds = %39
%54 = zext i32 %0 to i64
%55 = getelementptr inbounds i8, i8* %25, i64 %54
%56 = bitcast i8* %55 to i32*
store volatile i32 %1, i32* %56
%57 = tail call i32 @munmap(i8* %25, i64 1048576)
%58 = icmp sgt i32 %2, 0
br i1 %58, label %59, label %61
59: ; preds = %44, %53
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %0, i32 %1)
br label %61
61: ; preds = %53, %59, %42, %30, %9
%62 = phi i32 [ -1, %9 ], [ -1, %30 ], [ -1, %42 ], [ 0, %59 ], [ 0, %53 ]
ret i32 %62
}