#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 */
struct pollfd {
  int fd;
  int /*<<< orphan*/ events;
};
typedef int /*<<< orphan*/ mode_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ POLLIN;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _IO(char, int);
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(unsigned int *);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ memcpy(unsigned int *, unsigned int *, unsigned int);
scalar_t__ mmap(int /*<<< orphan*/, unsigned int, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ munmap(unsigned int *, unsigned int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i, ii;
  int fid_dma;
  unsigned int *map;
  int size;
  int iters;
  int read_return;
  unsigned int filesize;
  unsigned int *data;
  struct pollfd pfds[1];
  if (argc != 3) {
    printf("usage: $radar_dma_tester <Nvals> <Niter>\n");
    return 1;
  }
  size = atoi(argv[1]);
  iters = atoi(argv[2]);
  if (!size || !iters) {
    printf("improper argument(s)\n");
    return 1;
  }
  printf("will read %d ints\n", size);
  filesize = (unsigned int)(size * sizeof(int));
  data = (unsigned int *)malloc(filesize);
  printf("filesize is %d bytes\n", filesize);
  fid_dma = open("/dev/radar_dma", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
  printf("mapping kernel space to user\n");
  map = (unsigned int *)mmap(0, filesize, PROT_READ | PROT_WRITE, MAP_SHARED,
                             fid_dma, 0);
  printf("spooling up dma\n");
  ioctl(fid_dma, _IO('m', 1), NULL);
  pfds[0].fd = fid_dma;
  pfds[0].events = POLLIN;
  for (i = 0; i < iters; i++) {
    poll(pfds, 1, 1000);
    memcpy(data, map, filesize);
    for (ii = 0; ii < size; ii++)
      printf("%d, ", data[ii]);
    printf("\n");
  }
  printf("stopping dma\n");
  ioctl(fid_dma, _IO('m', 2), NULL);
  munmap(map, filesize);
  close(fid_dma);
  free(data);
  return 0;
}


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)
je     11fa <main+0x3a>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1413 <main+0x253>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     122e <main+0x6e>
cmpl   $0x0,-0x30(%rbp)
jne    1248 <main+0x88>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1413 <main+0x253>
mov    -0x2c(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
mov    0x2d67(%rip),%rax
or     (%rax),%esi
mov    0x2d56(%rip),%rax
or     (%rax),%esi
lea    0xdc6(%rip),%rdi
mov    $0x180,%edx
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%esi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
mov    0x2cdf(%rip),%rax
or     (%rax),%edx
mov    0x2cfe(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1040 <mmap@plt>
mov    %rax,-0x28(%rbp)
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    $0x6d,%edi
mov    $0x1,%esi
call   1060 <_IO@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <ioctl@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    13be <main+0x1fe>
lea    -0x48(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   10c0 <poll@plt>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1090 <memcpy@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    13a2 <main+0x1e2>
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    136f <main+0x1af>
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1339 <main+0x179>
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    $0x6d,%edi
mov    $0x2,%esi
call   1060 <_IO@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <ioctl@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10b0 <munmap@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
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
sub    $0x28,%rsp
cmp    $0x3,%edi
jne    1399 <main+0x1b9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1100 <atoi@plt>
mov    %rbp,0x8(%rsp)
test   %ebp,%ebp
je     13a2 <main+0x1c2>
mov    %eax,%r13d
test   %eax,%eax
je     13a2 <main+0x1c2>
lea    0xdd3(%rip),%rdi
mov    0x8(%rsp),%rbx
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x0(,%rbx,4),%r14d
mov    %r14d,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
lea    0xdbe(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d62(%rip),%rax
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d78(%rip),%rax
or     (%rax),%esi
lea    0xda8(%rip),%rdi
mov    $0x180,%edx
call   10f0 <open@plt>
mov    %eax,%ebp
lea    0xdbe(%rip),%rdi
call   1050 <puts@plt>
mov    0x2d48(%rip),%rax
mov    0x2d09(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d26(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14d,0x4(%rsp)
mov    %r14d,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,0x18(%rsp)
lea    0xd9a(%rip),%rdi
call   1050 <puts@plt>
mov    $0x6d,%edi
mov    $0x1,%esi
call   1080 <_IO@plt>
mov    %ebp,%edi
mov    %eax,%esi
xor    %edx,%edx
call   1090 <ioctl@plt>
mov    %ebp,0x14(%rsp)
mov    %ebp,0x20(%rsp)
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
test   %r13d,%r13d
jle    13b5 <main+0x1d5>
mov    0x8(%rsp),%r14d
lea    0xd1a(%rip),%r12
xor    %ebp,%ebp
jmp    1342 <main+0x162>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%ebp
cmp    %r13d,%ebp
je     13b5 <main+0x1d5>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   10e0 <poll@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    0x4(%rsp),%edx
call   10b0 <memcpy@plt>
cmpl   $0x0,0x8(%rsp)
jle    1330 <main+0x150>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1380 <main+0x1a0>
jmp    1330 <main+0x150>
lea    0xcec(%rip),%rdi
jmp    13a9 <main+0x1c9>
lea    0xc94(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
jmp    13fe <main+0x21e>
lea    0xcc3(%rip),%rdi
call   1050 <puts@plt>
mov    $0x6d,%edi
mov    $0x2,%esi
call   1080 <_IO@plt>
mov    0x14(%rsp),%ebp
mov    %ebp,%edi
mov    %eax,%esi
xor    %edx,%edx
call   1090 <ioctl@plt>
mov    0x18(%rsp),%rdi
mov    0x4(%rsp),%esi
call   10d0 <munmap@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pollfd = type { i32, i32 }
@.str = [42 x i8] c"usage: $radar_dma_tester <Nvals> <Niter>\0A\00"
@.str.1 = [22 x i8] c"improper argument(s)\0A\00"
@.str.2 = [19 x i8] c"will read %d ints\0A\00"
@.str.3 = [22 x i8] c"filesize is %d bytes\0A\00"
@.str.4 = [15 x i8] c"/dev/radar_dma\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.5 = [30 x i8] c"mapping kernel space to user\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [17 x i8] c"spooling up dma\0A\00"
@POLLIN = global i32 0
@.str.7 = [5 x i8] c"%d, \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [14 x i8] c"stopping dma\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca [1 x %struct.pollfd]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %115
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %10
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %11
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %20
%32 = load i32, i32* %11
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31, %20
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %115
36: ; preds = %31
%37 = load i32, i32* %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
store i32 %42, i32* %13
%43 = load i32, i32* %13
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i32*
store i32* %45, i32** %14
%46 = load i32, i32* %13
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @O_RDWR
%49 = load i32, i32* @O_CREAT
%50 = or i32 %48, %49
%51 = load i32, i32* @O_TRUNC
%52 = or i32 %50, %51
%53 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 384)
store i32 %53, i32* %8
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* %13
%56 = load i32, i32* @PROT_READ
%57 = load i32, i32* @PROT_WRITE
%58 = or i32 %56, %57
%59 = load i32, i32* @MAP_SHARED
%60 = load i32, i32* %8
%61 = call i64 @mmap(i32 0, i32 %55, i32 %58, i32 %59, i32 %60, i32 0)
%62 = inttoptr i64 %61 to i32*
store i32* %62, i32** %9
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%64 = load i32, i32* %8
%65 = call i32 @_IO(i8 signext 109, i32 1)
%66 = call i32 @ioctl(i32 %64, i32 %65, i32* null)
%67 = load i32, i32* %8
%68 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %15, i64 0, i64 0
%69 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %68, i32 0, i32 0
store i32 %67, i32* %69
%70 = load i32, i32* @POLLIN
%71 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %15, i64 0, i64 0
%72 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %71, i32 0, i32 1
store i32 %70, i32* %72
store i32 0, i32* %6
br label %73
73: ; preds = %100, %36
%74 = load i32, i32* %6
%75 = load i32, i32* %11
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %103
77: ; preds = %73
%78 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %15, i64 0, i64 0
%79 = call i32 @poll(%struct.pollfd* %78, i32 1, i32 1000)
%80 = load i32*, i32** %14
%81 = load i32*, i32** %9
%82 = load i32, i32* %13
%83 = call i32 @memcpy(i32* %80, i32* %81, i32 %82)
store i32 0, i32* %7
br label %84
84: ; preds = %95, %77
%85 = load i32, i32* %7
%86 = load i32, i32* %10
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %98
88: ; preds = %84
%89 = load i32*, i32** %14
%90 = load i32, i32* %7
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %89, i64 %91
%93 = load i32, i32* %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %88
%96 = load i32, i32* %7
%97 = add nsw i32 %96, 1
store i32 %97, i32* %7
br label %84
98: ; preds = %84
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %100
100: ; preds = %98
%101 = load i32, i32* %6
%102 = add nsw i32 %101, 1
store i32 %102, i32* %6
br label %73
103: ; preds = %73
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
%105 = load i32, i32* %8
%106 = call i32 @_IO(i8 signext 109, i32 2)
%107 = call i32 @ioctl(i32 %105, i32 %106, i32* null)
%108 = load i32*, i32** %9
%109 = load i32, i32* %13
%110 = call i32 @munmap(i32* %108, i32 %109)
%111 = load i32, i32* %8
%112 = call i32 @close(i32 %111)
%113 = load i32*, i32** %14
%114 = call i32 @free(i32* %113)
store i32 0, i32* %3
br label %115
115: ; preds = %103, %34, %18
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32 }
@.str.2 = [19 x i8] c"will read %d ints\0A\00"
@.str.3 = [22 x i8] c"filesize is %d bytes\0A\00"
@.str.4 = [15 x i8] c"/dev/radar_dma\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@POLLIN = global i32 0
@.str.7 = [5 x i8] c"%d, \00"
@str = [21 x i8] c"improper argument(s)\00"
@str.10 = [29 x i8] c"mapping kernel space to user\00"
@str.11 = [16 x i8] c"spooling up dma\00"
@str.12 = [13 x i8] c"stopping dma\00"
@str.13 = [41 x i8] c"usage: $radar_dma_tester <Nvals> <Niter>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x %struct.pollfd]
%4 = bitcast [1 x %struct.pollfd]* %3 to i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.13, i64 0, i64 0))
br label %72
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp ne i32 %11, 0
%16 = icmp ne i32 %14, 0
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %20, label %18
18: ; preds = %8
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %72
20: ; preds = %8
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%22 = shl i32 %11, 2
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%26 = load i32, i32* @O_RDWR
%27 = load i32, i32* @O_CREAT
%28 = or i32 %27, %26
%29 = load i32, i32* @O_TRUNC
%30 = or i32 %28, %29
%31 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 384)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.10, i64 0, i64 0))
%33 = load i32, i32* @PROT_READ
%34 = load i32, i32* @PROT_WRITE
%35 = or i32 %34, %33
%36 = load i32, i32* @MAP_SHARED
%37 = tail call i64 @mmap(i32 0, i32 %22, i32 %35, i32 %36, i32 %31, i32 0)
%38 = inttoptr i64 %37 to i32*
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%40 = tail call i32 @_IO(i8 signext 109, i32 1)
%41 = tail call i32 @ioctl(i32 %31, i32 %40, i32* null)
%42 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %3, i64 0, i64 0
%43 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %3, i64 0, i64 0, i32 0
store i32 %31, i32* %43
%44 = load i32, i32* @POLLIN
%45 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %3, i64 0, i64 0, i32 1
store i32 %44, i32* %45
%46 = icmp sgt i32 %14, 0
br i1 %46, label %47, label %65
47: ; preds = %20
%48 = icmp sgt i32 %11, 0
%49 = zext i32 %11 to i64
br label %50
50: ; preds = %47, %61
%51 = phi i32 [ 0, %47 ], [ %63, %61 ]
%52 = call i32 @poll(%struct.pollfd* %42, i32 1, i32 1000)
%53 = call i32 @memcpy(i32* %24, i32* %38, i32 %22)
br i1 %48, label %54, label %61
54: ; preds = %50, %54
%55 = phi i64 [ %59, %54 ], [ 0, %50 ]
%56 = getelementptr inbounds i32, i32* %24, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %57)
%59 = add nuw nsw i64 %55, 1
%60 = icmp eq i64 %59, %49
br i1 %60, label %61, label %54
61: ; preds = %54, %50
%62 = call i32 @putchar(i32 10)
%63 = add nuw nsw i32 %51, 1
%64 = icmp eq i32 %63, %14
br i1 %64, label %65, label %50
65: ; preds = %61, %20
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%67 = call i32 @_IO(i8 signext 109, i32 2)
%68 = call i32 @ioctl(i32 %31, i32 %67, i32* null)
%69 = call i32 @munmap(i32* %38, i32 %22)
%70 = call i32 @close(i32 %31)
%71 = call i32 @free(i32* %24)
br label %72
72: ; preds = %65, %18, %6
%73 = phi i32 [ 1, %6 ], [ 0, %65 ], [ 1, %18 ]
ret i32 %73
}