#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 getClientAddressBookSize(int);
int /*<<< orphan*/ setClientAddressBookSize(int, int);
int createClientAddressBookEntry(int handle) {
  int retValue_acc;
  int size;
  int tmp;
  int __cil_tmp5;
  {
    {
      tmp = getClientAddressBookSize(handle);
      size = tmp;
    }
    if (size < 3) {
      {
        __cil_tmp5 = size + 1;
        setClientAddressBookSize(handle, __cil_tmp5);
        retValue_acc = size + 1;
      }
      return (retValue_acc);
    } else {
      retValue_acc = -1;
      return (retValue_acc);
    }
    return (retValue_acc);
  }
}


x86 assembly (clang, -O0):
<createClientAddressBookEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <getClientAddressBookSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    116e <createClientAddressBookEntry+0x4e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <setClientAddressBookSize@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <createClientAddressBookEntry+0x5b>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createClientAddressBookEntry>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <getClientAddressBookSize@plt>
mov    %eax,%ebp
mov    $0xffffffff,%eax
cmp    $0x2,%ebp
jg     1144 <createClientAddressBookEntry+0x24>
add    $0x1,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <setClientAddressBookSize@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @createClientAddressBookEntry(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = call i32 @getClientAddressBookSize(i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %22
13: ; preds = %1
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %7
%16 = load i32, i32* %3
%17 = load i32, i32* %7
%18 = call i32 @setClientAddressBookSize(i32 %16, i32 %17)
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %24
22: ; preds = %1
store i32 -1, i32* %4
%23 = load i32, i32* %4
store i32 %23, i32* %2
br label %24
24: ; preds = %22, %13
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @createClientAddressBookEntry(i32 %0) {
%2 = tail call i32 @getClientAddressBookSize(i32 %0)
%3 = icmp slt i32 %2, 3
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = add nsw i32 %2, 1
%6 = tail call i32 @setClientAddressBookSize(i32 %0, i32 %5)
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ %5, %4 ], [ -1, %1 ]
ret i32 %8
}