#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__ inflate(void **, int, size_t);
int manage_size(void **inflatable, int cur_size, int *p_max_size, int step,
                size_t ptrsize) {
  int ret = 0;
  int max_size;
  max_size = *p_max_size;
  if (cur_size == max_size) {
    ret = inflate(inflatable, max_size + step, ptrsize) != 0;
    if (ret == 0) {
      max_size += step;
    }
  }
  *p_max_size = max_size;
  return ret;
}


x86 assembly (clang, -O0):
<manage_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1180 <manage_size+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <inflate@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    117b <manage_size+0x6b>
mov    -0x1c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1180 <manage_size+0x70>
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manage_size>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    (%rdx),%ecx
xor    %eax,%eax
cmp    %esi,%ecx
jne    113f <manage_size+0x2f>
mov    %esi,%ebx
add    %esi,%ebp
mov    %ebp,%esi
mov    %r8,%rdx
call   1030 <inflate@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
cmovne %ebx,%ebp
mov    %ebp,%ecx
mov    %ecx,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @manage_size(i8** %0, i32 %1, i32* %2, i32 %3, i64 %4) {
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i64 %4, i64* %10
store i32 0, i32* %11
%13 = load i32*, i32** %8
%14 = load i32, i32* %13
store i32 %14, i32* %12
%15 = load i32, i32* %7
%16 = load i32, i32* %12
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %5
%19 = load i8**, i8*** %6
%20 = load i32, i32* %12
%21 = load i32, i32* %9
%22 = add nsw i32 %20, %21
%23 = load i64, i64* %10
%24 = call i64 @inflate(i8** %19, i32 %22, i64 %23)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %11
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %18
%30 = load i32, i32* %9
%31 = load i32, i32* %12
%32 = add nsw i32 %31, %30
store i32 %32, i32* %12
br label %33
33: ; preds = %29, %18
br label %34
34: ; preds = %33, %5
%35 = load i32, i32* %12
%36 = load i32*, i32** %8
store i32 %35, i32* %36
%37 = load i32, i32* %11
ret i32 %37
}

LLVM IR (-O2):
define i32 @manage_size(i8** %0, i32 %1, i32* nocapture %2, i32 %3, i64 %4) {
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, %1
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = add nsw i32 %1, %3
%10 = tail call i64 @inflate(i8** %0, i32 %9, i64 %4)
%11 = icmp eq i64 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = select i1 %11, i32 %9, i32 %1
br label %15
15: ; preds = %8, %5
%16 = phi i32 [ 0, %5 ], [ %13, %8 ]
%17 = phi i32 [ %6, %5 ], [ %14, %8 ]
store i32 %17, i32* %2
ret i32 %16
}