#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 */
scalar_t__ alloc_pagecache(int, int);
int getppid();
int /*<<< orphan*/ sleep(int);
int alloc_pagecache_50M_noexit(const char *cgroup, void *arg) {
  int fd = (long)arg;
  int ppid = getppid();
  if (alloc_pagecache(fd, (50 << 20)))
    return -1;
  while (getppid() == ppid)
    sleep(1);
  return 0;
}


x86 assembly (clang, -O0):
<alloc_pagecache_50M_noexit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getppid@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x3200000,%esi
call   1030 <alloc_pagecache@plt>
cmp    $0x0,%rax
je     1174 <alloc_pagecache_50M_noexit+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <alloc_pagecache_50M_noexit+0x6f>
jmp    1179 <alloc_pagecache_50M_noexit+0x49>
mov    $0x0,%al
call   1040 <getppid@plt>
cmp    -0x20(%rbp),%eax
jne    1198 <alloc_pagecache_50M_noexit+0x68>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    1179 <alloc_pagecache_50M_noexit+0x49>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_pagecache_50M_noexit>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
xor    %eax,%eax
call   1040 <getppid@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x3200000,%esi
call   1030 <alloc_pagecache@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1185 <alloc_pagecache_50M_noexit+0x55>
xor    %eax,%eax
call   1040 <getppid@plt>
mov    $0x0,%ebp
cmp    %ebx,%eax
jne    1185 <alloc_pagecache_50M_noexit+0x55>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
call   1040 <getppid@plt>
cmp    %ebx,%eax
je     1170 <alloc_pagecache_50M_noexit+0x40>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @alloc_pagecache_50M_noexit(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = call i32 (...) @getppid()
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = call i64 @alloc_pagecache(i32 %12, i32 52428800)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %24
16: ; preds = %2
br label %17
17: ; preds = %21, %16
%18 = call i32 (...) @getppid()
%19 = load i32, i32* %7
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @sleep(i32 1)
br label %17
23: ; preds = %17
store i32 0, i32* %3
br label %24
24: ; preds = %23, %15
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @alloc_pagecache_50M_noexit(i8* nocapture readnone %0, i8* %1) {
%3 = ptrtoint i8* %1 to i64
%4 = trunc i64 %3 to i32
%5 = tail call i32 (...) @getppid()
%6 = tail call i64 @alloc_pagecache(i32 %4, i32 52428800)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = tail call i32 (...) @getppid()
%10 = icmp eq i32 %9, %5
br i1 %10, label %11, label %15
11: ; preds = %8, %11
%12 = tail call i32 @sleep(i32 1)
%13 = tail call i32 (...) @getppid()
%14 = icmp eq i32 %13, %5
br i1 %14, label %11, label %15
15: ; preds = %11, %8, %2
%16 = phi i32 [ -1, %2 ], [ 0, %8 ], [ 0, %11 ]
ret i32 %16
}