#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*/ DMA_BUF_SYNC_END;
int /*<<< orphan*/ DMA_BUF_SYNC_START;
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int dmabuf_heap_alloc(int, size_t, int /*<<< orphan*/, int *);
int dmabuf_heap_open(char *);
int /*<<< orphan*/ dmabuf_sync(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(void *, int, size_t);
void *mmap(int /*<<< orphan*/ *, size_t, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, size_t);
int /*<<< orphan*/ printf(char *, ...);
int test_alloc_zeroed(char *heap_name, size_t size) {
  int heap_fd = -1, dmabuf_fd[32];
  int i, j, ret;
  void *p = NULL;
  char *c;
  printf("  Testing alloced %ldk buffers are zeroed:  ", size / 1024);
  heap_fd = dmabuf_heap_open(heap_name);
  if (heap_fd < 0)
    return -1;
  for (i = 0; i < 32; i++) {
    ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]);
    if (ret < 0) {
      printf("FAIL (Allocation (%i) failed)\n", i);
      goto out;
    }
    p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0);
    if (p == MAP_FAILED) {
      printf("FAIL (mmap() failed!)\n");
      ret = -1;
      goto out;
    }
    dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START);
    memset(p, 0xff, size);
    dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END);
    munmap(p, size);
  }
  for (i = 0; i < 32; i++)
    close(dmabuf_fd[i]);
  for (i = 0; i < 32; i++) {
    ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]);
    if (ret < 0) {
      printf("FAIL (Allocation (%i) failed)\n", i);
      goto out;
    }
    p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0);
    if (p == MAP_FAILED) {
      printf("FAIL (mmap() failed!)\n");
      ret = -1;
      goto out;
    }
    dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START);
    c = (char *)p;
    for (j = 0; j < size; j++) {
      if (c[j] != 0) {
        printf("FAIL (Allocated buffer not zeroed @ %i)\n", j);
        break;
      }
    }
    dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END);
    munmap(p, size);
  }
  for (i = 0; i < 32; i++)
    close(dmabuf_fd[i]);
  close(heap_fd);
  printf("OK\n");
  return 0;
out:
  while (i > 0) {
    close(dmabuf_fd[i]);
    i--;
  }
  close(heap_fd);
  return ret;
}


x86 assembly (clang, -O0):
<test_alloc_zeroed>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movq   $0x0,-0xb8(%rbp)
mov    -0x18(%rbp),%rsi
shr    $0xa,%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <dmabuf_heap_open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11dd <test_alloc_zeroed+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    15be <test_alloc_zeroed+0x43e>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    1329 <test_alloc_zeroed+0x1a9>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
movslq -0xa4(%rbp),%rax
lea    -0xa0(%rbp),%rcx
shl    $0x2,%rax
add    %rax,%rcx
xor    %edx,%edx
call   1090 <dmabuf_heap_alloc@plt>
mov    %eax,-0xac(%rbp)
cmpl   $0x0,-0xac(%rbp)
jge    1243 <test_alloc_zeroed+0xc3>
mov    -0xa4(%rbp),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1574 <test_alloc_zeroed+0x3f4>
mov    -0x18(%rbp),%rsi
mov    0x2daa(%rip),%rax
mov    (%rax),%edx
mov    0x2d71(%rip),%rax
or     (%rax),%edx
mov    0x2d88(%rip),%rax
mov    (%rax),%ecx
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%r8d
ff
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
mov    0x2d26(%rip),%rcx
cmp    (%rcx),%rax
jne    12b8 <test_alloc_zeroed+0x138>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0xac(%rbp)
ff ff ff
jmp    1574 <test_alloc_zeroed+0x3f4>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
call   1060 <dmabuf_sync@plt>
mov    -0xb8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xff,%esi
call   1070 <memset@plt>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
mov    0x2cda(%rip),%rax
mov    (%rax),%esi
call   1060 <dmabuf_sync@plt>
mov    -0xb8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <munmap@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11e7 <test_alloc_zeroed+0x67>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    1367 <test_alloc_zeroed+0x1e7>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
call   1080 <close@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1333 <test_alloc_zeroed+0x1b3>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    1514 <test_alloc_zeroed+0x394>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
movslq -0xa4(%rbp),%rax
lea    -0xa0(%rbp),%rcx
shl    $0x2,%rax
add    %rax,%rcx
xor    %edx,%edx
call   1090 <dmabuf_heap_alloc@plt>
mov    %eax,-0xac(%rbp)
cmpl   $0x0,-0xac(%rbp)
jge    13cd <test_alloc_zeroed+0x24d>
mov    -0xa4(%rbp),%esi
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1574 <test_alloc_zeroed+0x3f4>
mov    -0x18(%rbp),%rsi
mov    0x2c20(%rip),%rax
mov    (%rax),%edx
mov    0x2be7(%rip),%rax
or     (%rax),%edx
mov    0x2bfe(%rip),%rax
mov    (%rax),%ecx
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%r8d
ff
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
mov    0x2b9c(%rip),%rcx
cmp    (%rcx),%rax
jne    1442 <test_alloc_zeroed+0x2c2>
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0xac(%rbp)
ff ff ff
jmp    1574 <test_alloc_zeroed+0x3f4>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
mov    0x2b69(%rip),%rax
mov    (%rax),%esi
call   1060 <dmabuf_sync@plt>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x0,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    14d4 <test_alloc_zeroed+0x354>
mov    -0xc0(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     14bb <test_alloc_zeroed+0x33b>
mov    -0xa8(%rbp),%esi
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14d4 <test_alloc_zeroed+0x354>
jmp    14c0 <test_alloc_zeroed+0x340>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    1476 <test_alloc_zeroed+0x2f6>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
mov    0x2aef(%rip),%rax
mov    (%rax),%esi
call   1060 <dmabuf_sync@plt>
mov    -0xb8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <munmap@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1371 <test_alloc_zeroed+0x1f1>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    1552 <test_alloc_zeroed+0x3d2>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
call   1080 <close@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    151e <test_alloc_zeroed+0x39e>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
lea    0xb2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15be <test_alloc_zeroed+0x43e>
jmp    1579 <test_alloc_zeroed+0x3f9>
cmpl   $0x0,-0xa4(%rbp)
jle    15ad <test_alloc_zeroed+0x42d>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edi
call   1080 <close@plt>
mov    -0xa4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xa4(%rbp)
jmp    1579 <test_alloc_zeroed+0x3f9>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0xac(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_alloc_zeroed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r12
mov    %rdi,%rbx
shr    $0xa,%rsi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <dmabuf_heap_open@plt>
test   %eax,%eax
js     1478 <test_alloc_zeroed+0x2e8>
mov    %eax,%r14d
mov    %rsp,%rbp
xor    %r13d,%r13d
mov    0x2ddf(%rip),%r15
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %r12,%rsi
xor    %edx,%edx
mov    %rbp,%rcx
call   10a0 <dmabuf_heap_alloc@plt>
test   %eax,%eax
js     1482 <test_alloc_zeroed+0x2f2>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
mov    0x2df0(%rip),%rax
or     (%rax),%edx
mov    0x2dd7(%rip),%rax
mov    (%rax),%ecx
mov    0x0(%rbp),%r8d
xor    %edi,%edi
mov    %r12,%rsi
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    (%r15),%rax
je     148c <test_alloc_zeroed+0x2fc>
mov    %rax,%rbx
mov    0x0(%rbp),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
call   1070 <dmabuf_sync@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <memset@plt>
mov    0x0(%rbp),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
call   1070 <dmabuf_sync@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <munmap@plt>
add    $0xffffffffffffffff,%r13
add    $0x4,%rbp
cmp    $0xffffffffffffffe0,%r13
jne    11e0 <test_alloc_zeroed+0x50>
mov    (%rsp),%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    0x10(%rsp),%edi
call   1090 <close@plt>
mov    0x14(%rsp),%edi
call   1090 <close@plt>
mov    0x18(%rsp),%edi
call   1090 <close@plt>
mov    0x1c(%rsp),%edi
call   1090 <close@plt>
mov    0x20(%rsp),%edi
call   1090 <close@plt>
mov    0x24(%rsp),%edi
call   1090 <close@plt>
mov    0x28(%rsp),%edi
call   1090 <close@plt>
mov    0x2c(%rsp),%edi
call   1090 <close@plt>
mov    0x30(%rsp),%edi
call   1090 <close@plt>
mov    0x34(%rsp),%edi
call   1090 <close@plt>
mov    0x38(%rsp),%edi
call   1090 <close@plt>
mov    0x3c(%rsp),%edi
call   1090 <close@plt>
mov    0x40(%rsp),%edi
call   1090 <close@plt>
mov    0x44(%rsp),%edi
call   1090 <close@plt>
mov    0x48(%rsp),%edi
call   1090 <close@plt>
mov    0x4c(%rsp),%edi
call   1090 <close@plt>
mov    0x50(%rsp),%edi
call   1090 <close@plt>
mov    0x54(%rsp),%edi
call   1090 <close@plt>
mov    0x58(%rsp),%edi
call   1090 <close@plt>
mov    0x5c(%rsp),%edi
call   1090 <close@plt>
mov    0x60(%rsp),%edi
call   1090 <close@plt>
mov    0x64(%rsp),%edi
call   1090 <close@plt>
mov    0x68(%rsp),%edi
call   1090 <close@plt>
mov    0x6c(%rsp),%edi
call   1090 <close@plt>
mov    0x70(%rsp),%edi
call   1090 <close@plt>
mov    0x74(%rsp),%edi
call   1090 <close@plt>
mov    0x78(%rsp),%edi
call   1090 <close@plt>
mov    0x7c(%rsp),%edi
call   1090 <close@plt>
xor    %r13d,%r13d
jmp    13e9 <test_alloc_zeroed+0x259>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xc95(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp,%r13,4),%edi
mov    0x2c0f(%rip),%rax
mov    (%rax),%esi
call   1070 <dmabuf_sync@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <munmap@plt>
add    $0x1,%r13
cmp    $0x20,%r13
je     14ae <test_alloc_zeroed+0x31e>
lea    (%rsp,%r13,4),%rbp
mov    %r14d,%edi
mov    %r12,%rsi
xor    %edx,%edx
mov    %rbp,%rcx
call   10a0 <dmabuf_heap_alloc@plt>
test   %eax,%eax
js     15e5 <test_alloc_zeroed+0x455>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edx
mov    0x2be3(%rip),%rax
or     (%rax),%edx
mov    0x2bca(%rip),%rax
mov    (%rax),%ecx
mov    0x0(%rbp),%r8d
xor    %edi,%edi
mov    %r12,%rsi
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    (%r15),%rax
je     148f <test_alloc_zeroed+0x2ff>
mov    %rax,%rbx
mov    0x0(%rbp),%edi
mov    0x2b7d(%rip),%rax
mov    (%rax),%esi
call   1070 <dmabuf_sync@plt>
test   %r12,%r12
je     13be <test_alloc_zeroed+0x22e>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,(%rbx,%rsi,1)
jne    13b0 <test_alloc_zeroed+0x220>
add    $0x1,%rsi
cmp    %rsi,%r12
jne    1460 <test_alloc_zeroed+0x2d0>
jmp    13be <test_alloc_zeroed+0x22e>
mov    $0xffffffff,%ebx
jmp    162b <test_alloc_zeroed+0x49b>
mov    %eax,%ebx
neg    %r13d
jmp    15e7 <test_alloc_zeroed+0x457>
neg    %r13d
lea    0xbe2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
test   %r13d,%r13d
jne    15fd <test_alloc_zeroed+0x46d>
jmp    1623 <test_alloc_zeroed+0x493>
mov    (%rsp),%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    0x10(%rsp),%edi
call   1090 <close@plt>
mov    0x14(%rsp),%edi
call   1090 <close@plt>
mov    0x18(%rsp),%edi
call   1090 <close@plt>
mov    0x1c(%rsp),%edi
call   1090 <close@plt>
mov    0x20(%rsp),%edi
call   1090 <close@plt>
mov    0x24(%rsp),%edi
call   1090 <close@plt>
mov    0x28(%rsp),%edi
call   1090 <close@plt>
mov    0x2c(%rsp),%edi
call   1090 <close@plt>
mov    0x30(%rsp),%edi
call   1090 <close@plt>
mov    0x34(%rsp),%edi
call   1090 <close@plt>
mov    0x38(%rsp),%edi
call   1090 <close@plt>
mov    0x3c(%rsp),%edi
call   1090 <close@plt>
mov    0x40(%rsp),%edi
call   1090 <close@plt>
mov    0x44(%rsp),%edi
call   1090 <close@plt>
mov    0x48(%rsp),%edi
call   1090 <close@plt>
mov    0x4c(%rsp),%edi
call   1090 <close@plt>
mov    0x50(%rsp),%edi
call   1090 <close@plt>
mov    0x54(%rsp),%edi
call   1090 <close@plt>
mov    0x58(%rsp),%edi
call   1090 <close@plt>
mov    0x5c(%rsp),%edi
call   1090 <close@plt>
mov    0x60(%rsp),%edi
call   1090 <close@plt>
mov    0x64(%rsp),%edi
call   1090 <close@plt>
mov    0x68(%rsp),%edi
call   1090 <close@plt>
mov    0x6c(%rsp),%edi
call   1090 <close@plt>
mov    0x70(%rsp),%edi
call   1090 <close@plt>
mov    0x74(%rsp),%edi
call   1090 <close@plt>
mov    0x78(%rsp),%edi
call   1090 <close@plt>
mov    0x7c(%rsp),%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   1090 <close@plt>
lea    0xa99(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    162b <test_alloc_zeroed+0x49b>
mov    %eax,%ebx
lea    0xa3f(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
je     1623 <test_alloc_zeroed+0x493>
mov    %r13d,%ebp
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x4(%rsp,%rbp,4),%edi
call   1090 <close@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1610 <test_alloc_zeroed+0x480>
mov    %r14d,%edi
call   1090 <close@plt>
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c" Testing alloced %ldk buffers are zeroed: \00"
@.str.1 = [31 x i8] c"FAIL (Allocation (%i) failed)\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [23 x i8] c"FAIL (mmap() failed!)\0A\00"
@DMA_BUF_SYNC_START = global i32 0
@DMA_BUF_SYNC_END = global i32 0
@.str.3 = [41 x i8] c"FAIL (Allocated buffer not zeroed @ %i)\0A\00"
@.str.4 = [4 x i8] c"OK\0A\00"
define i32 @test_alloc_zeroed(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca [32 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 -1, i32* %6
store i8* null, i8** %11
%13 = load i64, i64* %5
%14 = udiv i64 %13, 1024
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %14)
%16 = load i8*, i8** %4
%17 = call i32 @dmabuf_heap_open(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 -1, i32* %3
br label %194
21: ; preds = %2
store i32 0, i32* %8
br label %22
22: ; preds = %72, %21
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 32
br i1 %24, label %25, label %75
25: ; preds = %22
%26 = load i32, i32* %6
%27 = load i64, i64* %5
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %29
%31 = call i32 @dmabuf_heap_alloc(i32 %26, i64 %27, i32 0, i32* %30)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %25
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %178
37: ; preds = %25
%38 = load i64, i64* %5
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @PROT_WRITE
%41 = or i32 %39, %40
%42 = load i32, i32* @MAP_SHARED
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i8* @mmap(i32* null, i64 %38, i32 %41, i32 %42, i32 %46, i32 0)
store i8* %47, i8** %11
%48 = load i8*, i8** %11
%49 = load i8*, i8** @MAP_FAILED
%50 = icmp eq i8* %48, %49
br i1 %50, label %51, label %53
51: ; preds = %37
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %10
br label %178
53: ; preds = %37
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* @DMA_BUF_SYNC_START
%59 = call i32 @dmabuf_sync(i32 %57, i32 %58)
%60 = load i8*, i8** %11
%61 = load i64, i64* %5
%62 = call i32 @memset(i8* %60, i32 255, i64 %61)
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = load i32, i32* @DMA_BUF_SYNC_END
%68 = call i32 @dmabuf_sync(i32 %66, i32 %67)
%69 = load i8*, i8** %11
%70 = load i64, i64* %5
%71 = call i32 @munmap(i8* %69, i64 %70)
br label %72
72: ; preds = %53
%73 = load i32, i32* %8
%74 = add nsw i32 %73, 1
store i32 %74, i32* %8
br label %22
75: ; preds = %22
store i32 0, i32* %8
br label %76
76: ; preds = %85, %75
%77 = load i32, i32* %8
%78 = icmp slt i32 %77, 32
br i1 %78, label %79, label %88
79: ; preds = %76
%80 = load i32, i32* %8
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
br label %85
85: ; preds = %79
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
br label %76
88: ; preds = %76
store i32 0, i32* %8
br label %89
89: ; preds = %158, %88
%90 = load i32, i32* %8
%91 = icmp slt i32 %90, 32
br i1 %91, label %92, label %161
92: ; preds = %89
%93 = load i32, i32* %6
%94 = load i64, i64* %5
%95 = load i32, i32* %8
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %96
%98 = call i32 @dmabuf_heap_alloc(i32 %93, i64 %94, i32 0, i32* %97)
store i32 %98, i32* %10
%99 = load i32, i32* %10
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %92
%102 = load i32, i32* %8
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %102)
br label %178
104: ; preds = %92
%105 = load i64, i64* %5
%106 = load i32, i32* @PROT_READ
%107 = load i32, i32* @PROT_WRITE
%108 = or i32 %106, %107
%109 = load i32, i32* @MAP_SHARED
%110 = load i32, i32* %8
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %111
%113 = load i32, i32* %112
%114 = call i8* @mmap(i32* null, i64 %105, i32 %108, i32 %109, i32 %113, i32 0)
store i8* %114, i8** %11
%115 = load i8*, i8** %11
%116 = load i8*, i8** @MAP_FAILED
%117 = icmp eq i8* %115, %116
br i1 %117, label %118, label %120
118: ; preds = %104
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %10
br label %178
120: ; preds = %104
%121 = load i32, i32* %8
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %122
%124 = load i32, i32* %123
%125 = load i32, i32* @DMA_BUF_SYNC_START
%126 = call i32 @dmabuf_sync(i32 %124, i32 %125)
%127 = load i8*, i8** %11
store i8* %127, i8** %12
store i32 0, i32* %9
br label %128
128: ; preds = %145, %120
%129 = load i32, i32* %9
%130 = sext i32 %129 to i64
%131 = load i64, i64* %5
%132 = icmp ult i64 %130, %131
br i1 %132, label %133, label %148
133: ; preds = %128
%134 = load i8*, i8** %12
%135 = load i32, i32* %9
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %134, i64 %136
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp ne i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %133
%142 = load i32, i32* %9
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %142)
br label %148
144: ; preds = %133
br label %145
145: ; preds = %144
%146 = load i32, i32* %9
%147 = add nsw i32 %146, 1
store i32 %147, i32* %9
br label %128
148: ; preds = %141, %128
%149 = load i32, i32* %8
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %150
%152 = load i32, i32* %151
%153 = load i32, i32* @DMA_BUF_SYNC_END
%154 = call i32 @dmabuf_sync(i32 %152, i32 %153)
%155 = load i8*, i8** %11
%156 = load i64, i64* %5
%157 = call i32 @munmap(i8* %155, i64 %156)
br label %158
158: ; preds = %148
%159 = load i32, i32* %8
%160 = add nsw i32 %159, 1
store i32 %160, i32* %8
br label %89
161: ; preds = %89
store i32 0, i32* %8
br label %162
162: ; preds = %171, %161
%163 = load i32, i32* %8
%164 = icmp slt i32 %163, 32
br i1 %164, label %165, label %174
165: ; preds = %162
%166 = load i32, i32* %8
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %167
%169 = load i32, i32* %168
%170 = call i32 @close(i32 %169)
br label %171
171: ; preds = %165
%172 = load i32, i32* %8
%173 = add nsw i32 %172, 1
store i32 %173, i32* %8
br label %162
174: ; preds = %162
%175 = load i32, i32* %6
%176 = call i32 @close(i32 %175)
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %194
178: ; preds = %118, %101, %51, %34
br label %179
179: ; preds = %182, %178
%180 = load i32, i32* %8
%181 = icmp sgt i32 %180, 0
br i1 %181, label %182, label %190
182: ; preds = %179
%183 = load i32, i32* %8
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [32 x i32], [32 x i32]* %7, i64 0, i64 %184
%186 = load i32, i32* %185
%187 = call i32 @close(i32 %186)
%188 = load i32, i32* %8
%189 = add nsw i32 %188, -1
store i32 %189, i32* %8
br label %179
190: ; preds = %179
%191 = load i32, i32* %6
%192 = call i32 @close(i32 %191)
%193 = load i32, i32* %10
store i32 %193, i32* %3
br label %194
194: ; preds = %190, %174, %20
%195 = load i32, i32* %3
ret i32 %195
}

LLVM IR (-O2):
@.str = [45 x i8] c" Testing alloced %ldk buffers are zeroed: \00"
@.str.1 = [31 x i8] c"FAIL (Allocation (%i) failed)\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@DMA_BUF_SYNC_START = global i32 0
@DMA_BUF_SYNC_END = global i32 0
@.str.3 = [41 x i8] c"FAIL (Allocated buffer not zeroed @ %i)\0A\00"
@str = [3 x i8] c"OK\00"
@str.6 = [22 x i8] c"FAIL (mmap() failed!)\00"
define i32 @test_alloc_zeroed(i8* %0, i64 %1) {
%3 = alloca [32 x i32]
%4 = bitcast [32 x i32]* %3 to i8*
%5 = lshr i64 %1, 10
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i64 %5)
%7 = tail call i32 @dmabuf_heap_open(i8* %0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %262, label %9
9: ; preds = %2, %29
%10 = phi i64 [ %38, %29 ], [ 0, %2 ]
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %10
%12 = call i32 @dmabuf_heap_alloc(i32 %7, i64 %1, i32 0, i32* %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = trunc i64 %10 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %247
17: ; preds = %9
%18 = load i32, i32* @PROT_READ
%19 = load i32, i32* @PROT_WRITE
%20 = or i32 %19, %18
%21 = load i32, i32* @MAP_SHARED
%22 = load i32, i32* %11
%23 = call i8* @mmap(i32* null, i64 %1, i32 %20, i32 %21, i32 %22, i32 0)
%24 = load i8*, i8** @MAP_FAILED
%25 = icmp eq i8* %23, %24
br i1 %25, label %26, label %29
26: ; preds = %17
%27 = trunc i64 %10 to i32
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
br label %247
29: ; preds = %17
%30 = load i32, i32* %11
%31 = load i32, i32* @DMA_BUF_SYNC_START
%32 = call i32 @dmabuf_sync(i32 %30, i32 %31)
%33 = call i32 @memset(i8* %23, i32 255, i64 %1)
%34 = load i32, i32* %11
%35 = load i32, i32* @DMA_BUF_SYNC_END
%36 = call i32 @dmabuf_sync(i32 %34, i32 %35)
%37 = call i32 @munmap(i8* %23, i64 %1)
%38 = add nuw nsw i64 %10, 1
%39 = icmp eq i64 %38, 32
br i1 %39, label %40, label %9
40: ; preds = %29
%41 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 1
%45 = load i32, i32* %44
%46 = call i32 @close(i32 %45)
%47 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 2
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
%50 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 3
%51 = load i32, i32* %50
%52 = call i32 @close(i32 %51)
%53 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 4
%54 = load i32, i32* %53
%55 = call i32 @close(i32 %54)
%56 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 5
%57 = load i32, i32* %56
%58 = call i32 @close(i32 %57)
%59 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 6
%60 = load i32, i32* %59
%61 = call i32 @close(i32 %60)
%62 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 7
%63 = load i32, i32* %62
%64 = call i32 @close(i32 %63)
%65 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 8
%66 = load i32, i32* %65
%67 = call i32 @close(i32 %66)
%68 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 9
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 10
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 11
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 12
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 13
%81 = load i32, i32* %80
%82 = call i32 @close(i32 %81)
%83 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 14
%84 = load i32, i32* %83
%85 = call i32 @close(i32 %84)
%86 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 15
%87 = load i32, i32* %86
%88 = call i32 @close(i32 %87)
%89 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 16
%90 = load i32, i32* %89
%91 = call i32 @close(i32 %90)
%92 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 17
%93 = load i32, i32* %92
%94 = call i32 @close(i32 %93)
%95 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 18
%96 = load i32, i32* %95
%97 = call i32 @close(i32 %96)
%98 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 19
%99 = load i32, i32* %98
%100 = call i32 @close(i32 %99)
%101 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 20
%102 = load i32, i32* %101
%103 = call i32 @close(i32 %102)
%104 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 21
%105 = load i32, i32* %104
%106 = call i32 @close(i32 %105)
%107 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 22
%108 = load i32, i32* %107
%109 = call i32 @close(i32 %108)
%110 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 23
%111 = load i32, i32* %110
%112 = call i32 @close(i32 %111)
%113 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 24
%114 = load i32, i32* %113
%115 = call i32 @close(i32 %114)
%116 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 25
%117 = load i32, i32* %116
%118 = call i32 @close(i32 %117)
%119 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 26
%120 = load i32, i32* %119
%121 = call i32 @close(i32 %120)
%122 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 27
%123 = load i32, i32* %122
%124 = call i32 @close(i32 %123)
%125 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 28
%126 = load i32, i32* %125
%127 = call i32 @close(i32 %126)
%128 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 29
%129 = load i32, i32* %128
%130 = call i32 @close(i32 %129)
%131 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 30
%132 = load i32, i32* %131
%133 = call i32 @close(i32 %132)
%134 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 31
%135 = load i32, i32* %134
%136 = call i32 @close(i32 %135)
%137 = icmp eq i64 %1, 0
br label %138
138: ; preds = %40, %173
%139 = phi i64 [ 0, %40 ], [ %178, %173 ]
%140 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %139
%141 = call i32 @dmabuf_heap_alloc(i32 %7, i64 %1, i32 0, i32* %140)
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %138
%144 = trunc i64 %139 to i32
%145 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %144)
br label %247
146: ; preds = %138
%147 = load i32, i32* @PROT_READ
%148 = load i32, i32* @PROT_WRITE
%149 = or i32 %148, %147
%150 = load i32, i32* @MAP_SHARED
%151 = load i32, i32* %140
%152 = call i8* @mmap(i32* null, i64 %1, i32 %149, i32 %150, i32 %151, i32 0)
%153 = load i8*, i8** @MAP_FAILED
%154 = icmp eq i8* %152, %153
br i1 %154, label %155, label %158
155: ; preds = %146
%156 = trunc i64 %139 to i32
%157 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
br label %247
158: ; preds = %146
%159 = load i32, i32* %140
%160 = load i32, i32* @DMA_BUF_SYNC_START
%161 = call i32 @dmabuf_sync(i32 %159, i32 %160)
br i1 %137, label %173, label %162
162: ; preds = %158, %170
%163 = phi i64 [ %171, %170 ], [ 0, %158 ]
%164 = getelementptr inbounds i8, i8* %152, i64 %163
%165 = load i8, i8* %164
%166 = icmp eq i8 %165, 0
br i1 %166, label %170, label %167
167: ; preds = %162
%168 = trunc i64 %163 to i32
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %168)
br label %173
170: ; preds = %162
%171 = add nuw i64 %163, 1
%172 = icmp eq i64 %171, %1
br i1 %172, label %173, label %162
173: ; preds = %170, %158, %167
%174 = load i32, i32* %140
%175 = load i32, i32* @DMA_BUF_SYNC_END
%176 = call i32 @dmabuf_sync(i32 %174, i32 %175)
%177 = call i32 @munmap(i8* %152, i64 %1)
%178 = add nuw nsw i64 %139, 1
%179 = icmp eq i64 %178, 32
br i1 %179, label %180, label %138
180: ; preds = %173
%181 = load i32, i32* %41
%182 = call i32 @close(i32 %181)
%183 = load i32, i32* %44
%184 = call i32 @close(i32 %183)
%185 = load i32, i32* %47
%186 = call i32 @close(i32 %185)
%187 = load i32, i32* %50
%188 = call i32 @close(i32 %187)
%189 = load i32, i32* %53
%190 = call i32 @close(i32 %189)
%191 = load i32, i32* %56
%192 = call i32 @close(i32 %191)
%193 = load i32, i32* %59
%194 = call i32 @close(i32 %193)
%195 = load i32, i32* %62
%196 = call i32 @close(i32 %195)
%197 = load i32, i32* %65
%198 = call i32 @close(i32 %197)
%199 = load i32, i32* %68
%200 = call i32 @close(i32 %199)
%201 = load i32, i32* %71
%202 = call i32 @close(i32 %201)
%203 = load i32, i32* %74
%204 = call i32 @close(i32 %203)
%205 = load i32, i32* %77
%206 = call i32 @close(i32 %205)
%207 = load i32, i32* %80
%208 = call i32 @close(i32 %207)
%209 = load i32, i32* %83
%210 = call i32 @close(i32 %209)
%211 = load i32, i32* %86
%212 = call i32 @close(i32 %211)
%213 = load i32, i32* %89
%214 = call i32 @close(i32 %213)
%215 = load i32, i32* %92
%216 = call i32 @close(i32 %215)
%217 = load i32, i32* %95
%218 = call i32 @close(i32 %217)
%219 = load i32, i32* %98
%220 = call i32 @close(i32 %219)
%221 = load i32, i32* %101
%222 = call i32 @close(i32 %221)
%223 = load i32, i32* %104
%224 = call i32 @close(i32 %223)
%225 = load i32, i32* %107
%226 = call i32 @close(i32 %225)
%227 = load i32, i32* %110
%228 = call i32 @close(i32 %227)
%229 = load i32, i32* %113
%230 = call i32 @close(i32 %229)
%231 = load i32, i32* %116
%232 = call i32 @close(i32 %231)
%233 = load i32, i32* %119
%234 = call i32 @close(i32 %233)
%235 = load i32, i32* %122
%236 = call i32 @close(i32 %235)
%237 = load i32, i32* %125
%238 = call i32 @close(i32 %237)
%239 = load i32, i32* %128
%240 = call i32 @close(i32 %239)
%241 = load i32, i32* %131
%242 = call i32 @close(i32 %241)
%243 = load i32, i32* %134
%244 = call i32 @close(i32 %243)
%245 = call i32 @close(i32 %7)
%246 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %262
247: ; preds = %155, %143, %26, %14
%248 = phi i32 [ %15, %14 ], [ %27, %26 ], [ %144, %143 ], [ %156, %155 ]
%249 = phi i32 [ %12, %14 ], [ -1, %26 ], [ %141, %143 ], [ -1, %155 ]
%250 = icmp eq i32 %248, 0
br i1 %250, label %260, label %251
251: ; preds = %247
%252 = zext i32 %248 to i64
br label %253
253: ; preds = %251, %253
%254 = phi i64 [ %252, %251 ], [ %258, %253 ]
%255 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %254
%256 = load i32, i32* %255
%257 = call i32 @close(i32 %256)
%258 = add nsw i64 %254, -1
%259 = icmp ugt i64 %254, 1
br i1 %259, label %253, label %260
260: ; preds = %253, %247
%261 = call i32 @close(i32 %7)
br label %262
262: ; preds = %2, %260, %180
%263 = phi i32 [ %249, %260 ], [ 0, %180 ], [ -1, %2 ]
ret i32 %263
}