#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 */

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int Xil_In32(unsigned int *, unsigned int);
int /*<<< orphan*/ Xil_Out32(unsigned int *, unsigned int, int);
int /*<<< orphan*/ close(int);
unsigned int *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
                   int);
int /*<<< orphan*/ munmap(unsigned int *, int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int do_pr(int pr_size, unsigned int pr_begin_addr, unsigned int vsm) {
  unsigned int vsm_off = vsm << 7;
  printf("PR DDR address:0x%X; pr_size: %d; vsm: %d\n", pr_begin_addr, pr_size,
         vsm);
  int devmemfd = open("/dev/mem", O_RDWR | O_SYNC);
  if (devmemfd < 1) {
    printf("apploadpr: devmem open failed.\n");
    return 0;
  }
  unsigned int *icap = mmap(NULL, 0xFFFF, PROT_READ | PROT_WRITE, MAP_SHARED,
                            devmemfd, 0x42000000);
  unsigned int Status;
  unsigned int loading_done = 0;
  Xil_Out32(icap, vsm_off | 0X00000, 0);
  while (!(Xil_In32(icap, vsm_off | 0X00000) & 0x80))
    ;
  Xil_Out32(icap, vsm_off | 0X00064, pr_begin_addr + vsm * pr_size);
  Xil_Out32(icap, vsm_off | 0X00068, pr_size);
  Xil_Out32(icap, vsm_off | 0X00020, 0);
  Xil_Out32(icap, vsm_off | 0X00040, 0);
  Xil_Out32(icap, vsm_off | 0X00044, 0x1FF0);
  printf("Reading RM bitstreams address and size registers for Math and Shift "
         "RMs\n");
  printf("Adder RM address  = %x\n", Xil_In32(icap, vsm_off | 0X00064));
  printf("Adder RM size     = %d Bytes\n", Xil_In32(icap, vsm_off | 0X00068));
  Xil_Out32(icap, vsm_off | 0X00000, 2);
  Status = Xil_In32(icap, vsm_off | 0X00004);
  if (!(Status & 0x8000)) {
    Xil_Out32(icap, vsm_off | 0X00004, 0);
  }
  loading_done = 0;
  while (!loading_done) {
    Status = Xil_In32(icap, vsm_off | 0X00000) & 0x07;
    switch (Status) {
    case 7:
      printf("RM loaded\n");
      loading_done = 1;
      break;
    case 6:
      printf("RM is being reset\n");
      break;
    case 5:
      printf("Software start-up step\n");
      break;
    case 4:
      break;
    case 2:
      printf("Software shutdown\n");
      break;
    case 1:
      printf("Hardware shutdown\n");
      break;
    default:
      break;
    }
  }
  printf("VADD Reconfiguration Completed!\n\n");
pr_exit:
  munmap(icap, 0xFFFF);
  close(devmemfd);
  return 1;
}


x86 assembly (clang, -O0):
<do_pr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
mov    0x2e1f(%rip),%rax
or     (%rax),%esi
lea    0xe8d(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    11e6 <do_pr+0x76>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1452 <do_pr+0x2e2>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
mov    0x2dca(%rip),%rax
or     (%rax),%edx
mov    0x2de9(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffff,%esi
mov    $0x42000000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x0,%esi
xor    %edx,%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x0,%esi
call   1030 <Xil_In32@plt>
and    $0x80,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    125e <do_pr+0xee>
jmp    1263 <do_pr+0xf3>
jmp    1235 <do_pr+0xc5>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x64,%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%eax
imul   -0x8(%rbp),%eax
add    %eax,%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x68,%esi
mov    -0x8(%rbp),%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x20,%esi
xor    %edx,%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x40,%esi
xor    %edx,%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x44,%esi
mov    $0x1ff0,%edx
call   1040 <Xil_Out32@plt>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x64,%esi
call   1030 <Xil_In32@plt>
mov    %eax,%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x68,%esi
call   1030 <Xil_In32@plt>
mov    %eax,%esi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x0,%esi
mov    $0x2,%edx
call   1040 <Xil_Out32@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x4,%esi
call   1030 <Xil_In32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
jne    135a <do_pr+0x1ea>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
or     $0x4,%esi
xor    %edx,%edx
call   1040 <Xil_Out32@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1377 <do_pr+0x207>
jmp    1427 <do_pr+0x2b7>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <Xil_In32@plt>
and    $0x7,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x6,%eax
ja     141d <do_pr+0x2ad>
mov    -0x30(%rbp),%rax
lea    0xc57(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    1422 <do_pr+0x2b2>
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1422 <do_pr+0x2b2>
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1422 <do_pr+0x2b2>
jmp    1422 <do_pr+0x2b2>
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1422 <do_pr+0x2b2>
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1422 <do_pr+0x2b2>
jmp    1422 <do_pr+0x2b2>
jmp    1361 <do_pr+0x1f1>
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    $0xffff,%esi
call   1080 <munmap@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_pr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%ebp
mov    %edi,%r15d
lea    0xe82(%rip),%rdi
xor    %ebx,%ebx
mov    %r15d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e28(%rip),%rax
mov    0x2e19(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe85(%rip),%rdi
call   10a0 <open@plt>
test   %eax,%eax
jle    139a <do_pr+0x21a>
mov    %ebp,%ebx
mov    %r12d,%r14d
shl    $0x7,%r14d
mov    0x2e19(%rip),%rsi
mov    0x2dda(%rip),%rcx
mov    (%rcx),%edx
or     (%rsi),%edx
mov    0x2df7(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    $0xffff,%esi
mov    %eax,0x4(%rsp)
mov    %eax,%r8d
mov    $0x42000000,%r9d
call   1060 <mmap@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1050 <Xil_Out32@plt>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r14d,%esi
call   1030 <Xil_In32@plt>
test   $0x80,%al
je     1220 <do_pr+0xa0>
mov    %r14d,%ebp
or     $0x64,%ebp
imul   %r15d,%r12d
add    %ebx,%r12d
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
call   1050 <Xil_Out32@plt>
mov    %r14d,%r12d
or     $0x68,%r12d
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1050 <Xil_Out32@plt>
mov    %r14d,%esi
or     $0x20,%esi
mov    %r13,%rdi
xor    %edx,%edx
call   1050 <Xil_Out32@plt>
mov    %r14d,%esi
or     $0x40,%esi
mov    %r13,%rdi
xor    %edx,%edx
call   1050 <Xil_Out32@plt>
mov    %r14d,%esi
or     $0x44,%esi
mov    %r13,%rdi
mov    $0x1ff0,%edx
call   1050 <Xil_Out32@plt>
lea    0xdee(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <Xil_In32@plt>
lea    0xda2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   1030 <Xil_In32@plt>
lea    0xd9f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %r14d,%esi
mov    $0x2,%edx
call   1050 <Xil_Out32@plt>
mov    %r14d,%ebp
or     $0x4,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <Xil_In32@plt>
test   $0x8000,%eax
jne    1305 <do_pr+0x185>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1050 <Xil_Out32@plt>
lea    0xe1e(%rip),%rbp
lea    0xced(%rip),%rbx
lea    0xdd5(%rip),%r12
lea    0xdf2(%rip),%r15
jmp    132f <do_pr+0x1af>
lea    0xdd7(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r14d,%esi
call   1030 <Xil_In32@plt>
and    $0x7,%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     132f <do_pr+0x1af>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
mov    %rbp,%rdi
jmp    *%rax
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    132f <do_pr+0x1af>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    132f <do_pr+0x1af>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
lea    0xd56(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    $0xffff,%esi
call   1090 <munmap@plt>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
mov    $0x1,%ebx
jmp    13a6 <do_pr+0x226>
lea    0xda5(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"PR DDR address:0x%X; pr_size: %d; vsm: %d\0A\00"
@.str.1 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.2 = [32 x i8] c"apploadpr: devmem open failed.\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.3 = [73 x i8] c"Reading RM bitstreams address and size registers for Math and Shift RMs\0A\00"
@.str.4 = [24 x i8] c"Adder RM address = %x\0A\00"
@.str.5 = [30 x i8] c"Adder RM size = %d Bytes\0A\00"
@.str.6 = [11 x i8] c"RM loaded\0A\00"
@.str.7 = [19 x i8] c"RM is being reset\0A\00"
@.str.8 = [24 x i8] c"Software start-up step\0A\00"
@.str.9 = [19 x i8] c"Software shutdown\0A\00"
@.str.10 = [19 x i8] c"Hardware shutdown\0A\00"
@.str.11 = [34 x i8] c"VADD Reconfiguration Completed!\0A\0A\00"
define i32 @do_pr(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 i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%13 = load i32, i32* %7
%14 = shl i32 %13, 7
store i32 %14, i32* %8
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = load i32, i32* %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* @O_RDWR
%20 = load i32, i32* @O_SYNC
%21 = or i32 %19, %20
%22 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %133
27: ; preds = %3
%28 = load i32, i32* @PROT_READ
%29 = load i32, i32* @PROT_WRITE
%30 = or i32 %28, %29
%31 = load i32, i32* @MAP_SHARED
%32 = load i32, i32* %9
%33 = call i32* @mmap(i32* null, i32 65535, i32 %30, i32 %31, i32 %32, i32 1107296256)
store i32* %33, i32** %10
store i32 0, i32* %12
%34 = load i32*, i32** %10
%35 = load i32, i32* %8
%36 = or i32 %35, 0
%37 = call i32 @Xil_Out32(i32* %34, i32 %36, i32 0)
br label %38
38: ; preds = %46, %27
%39 = load i32*, i32** %10
%40 = load i32, i32* %8
%41 = or i32 %40, 0
%42 = call i32 @Xil_In32(i32* %39, i32 %41)
%43 = and i32 %42, 128
%44 = icmp ne i32 %43, 0
%45 = xor i1 %44, true
br i1 %45, label %46, label %47
46: ; preds = %38
br label %38
47: ; preds = %38
%48 = load i32*, i32** %10
%49 = load i32, i32* %8
%50 = or i32 %49, 100
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = load i32, i32* %5
%54 = mul i32 %52, %53
%55 = add i32 %51, %54
%56 = call i32 @Xil_Out32(i32* %48, i32 %50, i32 %55)
%57 = load i32*, i32** %10
%58 = load i32, i32* %8
%59 = or i32 %58, 104
%60 = load i32, i32* %5
%61 = call i32 @Xil_Out32(i32* %57, i32 %59, i32 %60)
%62 = load i32*, i32** %10
%63 = load i32, i32* %8
%64 = or i32 %63, 32
%65 = call i32 @Xil_Out32(i32* %62, i32 %64, i32 0)
%66 = load i32*, i32** %10
%67 = load i32, i32* %8
%68 = or i32 %67, 64
%69 = call i32 @Xil_Out32(i32* %66, i32 %68, i32 0)
%70 = load i32*, i32** %10
%71 = load i32, i32* %8
%72 = or i32 %71, 68
%73 = call i32 @Xil_Out32(i32* %70, i32 %72, i32 8176)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0))
%75 = load i32*, i32** %10
%76 = load i32, i32* %8
%77 = or i32 %76, 100
%78 = call i32 @Xil_In32(i32* %75, i32 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %78)
%80 = load i32*, i32** %10
%81 = load i32, i32* %8
%82 = or i32 %81, 104
%83 = call i32 @Xil_In32(i32* %80, i32 %82)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = load i32*, i32** %10
%86 = load i32, i32* %8
%87 = or i32 %86, 0
%88 = call i32 @Xil_Out32(i32* %85, i32 %87, i32 2)
%89 = load i32*, i32** %10
%90 = load i32, i32* %8
%91 = or i32 %90, 4
%92 = call i32 @Xil_In32(i32* %89, i32 %91)
store i32 %92, i32* %11
%93 = load i32, i32* %11
%94 = and i32 %93, 32768
%95 = icmp ne i32 %94, 0
br i1 %95, label %101, label %96
96: ; preds = %47
%97 = load i32*, i32** %10
%98 = load i32, i32* %8
%99 = or i32 %98, 4
%100 = call i32 @Xil_Out32(i32* %97, i32 %99, i32 0)
br label %101
101: ; preds = %96, %47
store i32 0, i32* %12
br label %102
102: ; preds = %125, %101
%103 = load i32, i32* %12
%104 = icmp ne i32 %103, 0
%105 = xor i1 %104, true
br i1 %105, label %106, label %126
106: ; preds = %102
%107 = load i32*, i32** %10
%108 = load i32, i32* %8
%109 = or i32 %108, 0
%110 = call i32 @Xil_In32(i32* %107, i32 %109)
%111 = and i32 %110, 7
store i32 %111, i32* %11
%112 = load i32, i32* %11
switch i32 %112, label %124 [
i32 7, label %113
i32 6, label %115
i32 5, label %117
i32 4, label %119
i32 2, label %120
i32 1, label %122
]
113: ; preds = %106
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %12
br label %125
115: ; preds = %106
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %125
117: ; preds = %106
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %125
119: ; preds = %106
br label %125
120: ; preds = %106
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %125
122: ; preds = %106
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %125
124: ; preds = %106
br label %125
125: ; preds = %124, %122, %120, %119, %117, %115, %113
br label %102
126: ; preds = %102
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
br label %128
128: ; preds = %126
%129 = load i32*, i32** %10
%130 = call i32 @munmap(i32* %129, i32 65535)
%131 = load i32, i32* %9
%132 = call i32 @close(i32 %131)
store i32 1, i32* %4
br label %133
133: ; preds = %128, %25
%134 = load i32, i32* %4
ret i32 %134
}

LLVM IR (-O2):
@.str = [43 x i8] c"PR DDR address:0x%X; pr_size: %d; vsm: %d\0A\00"
@.str.1 = [9 x i8] c"/dev/mem\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
@.str.4 = [24 x i8] c"Adder RM address = %x\0A\00"
@.str.5 = [30 x i8] c"Adder RM size = %d Bytes\0A\00"
@str = [72 x i8] c"Reading RM bitstreams address and size registers for Math and Shift RMs\00"
@str.12 = [33 x i8] c"VADD Reconfiguration Completed!\0A\00"
@str.13 = [18 x i8] c"Software shutdown\00"
@str.14 = [18 x i8] c"Hardware shutdown\00"
@str.15 = [23 x i8] c"Software start-up step\00"
@str.16 = [18 x i8] c"RM is being reset\00"
@str.17 = [10 x i8] c"RM loaded\00"
@str.18 = [31 x i8] c"apploadpr: devmem open failed.\00"
define i32 @do_pr(i32 %0, i32 %1, i32 %2) {
%4 = shl i32 %2, 7
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0, i32 %2)
%6 = load i32, i32* @O_RDWR
%7 = load i32, i32* @O_SYNC
%8 = or i32 %7, %6
%9 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
br label %65
13: ; preds = %3
%14 = load i32, i32* @PROT_READ
%15 = load i32, i32* @PROT_WRITE
%16 = or i32 %15, %14
%17 = load i32, i32* @MAP_SHARED
%18 = tail call i32* @mmap(i32* null, i32 65535, i32 %16, i32 %17, i32 %9, i32 1107296256)
%19 = tail call i32 @Xil_Out32(i32* %18, i32 %4, i32 0)
br label %20
20: ; preds = %20, %13
%21 = tail call i32 @Xil_In32(i32* %18, i32 %4)
%22 = and i32 %21, 128
%23 = icmp eq i32 %22, 0
br i1 %23, label %20, label %24
24: ; preds = %20
%25 = or i32 %4, 100
%26 = mul i32 %2, %0
%27 = add i32 %26, %1
%28 = tail call i32 @Xil_Out32(i32* %18, i32 %25, i32 %27)
%29 = or i32 %4, 104
%30 = tail call i32 @Xil_Out32(i32* %18, i32 %29, i32 %0)
%31 = or i32 %4, 32
%32 = tail call i32 @Xil_Out32(i32* %18, i32 %31, i32 0)
%33 = or i32 %4, 64
%34 = tail call i32 @Xil_Out32(i32* %18, i32 %33, i32 0)
%35 = or i32 %4, 68
%36 = tail call i32 @Xil_Out32(i32* %18, i32 %35, i32 8176)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%38 = tail call i32 @Xil_In32(i32* %18, i32 %25)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = tail call i32 @Xil_In32(i32* %18, i32 %29)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = tail call i32 @Xil_Out32(i32* %18, i32 %4, i32 2)
%43 = or i32 %4, 4
%44 = tail call i32 @Xil_In32(i32* %18, i32 %43)
%45 = and i32 %44, 32768
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %24
%48 = tail call i32 @Xil_Out32(i32* %18, i32 %43, i32 0)
br label %49
49: ; preds = %47, %24
br label %50
50: ; preds = %59, %49
%51 = tail call i32 @Xil_In32(i32* %18, i32 %4)
%52 = and i32 %51, 7
switch i32 %52, label %59 [
i32 7, label %60
i32 6, label %56
i32 5, label %53
i32 1, label %55
i32 2, label %54
]
53: ; preds = %50
br label %56
54: ; preds = %50
br label %56
55: ; preds = %50
br label %56
56: ; preds = %50, %53, %54, %55
%57 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0), %55 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0), %54 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %53 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0), %50 ]
%58 = tail call i32 @puts(i8* dereferenceable(1) %57)
br label %59
59: ; preds = %56, %50
br label %50
60: ; preds = %50
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.17, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
%63 = tail call i32 @munmap(i32* %18, i32 65535)
%64 = tail call i32 @close(i32 %9)
br label %65
65: ; preds = %60, %11
%66 = phi i32 [ 0, %11 ], [ 1, %60 ]
ret i32 %66
}