#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 vqe_zone {
  int dummy;
};

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
struct vqe_zone *zone_instance_get_loc(char *, int, int, int, void (*)(void *),
                                       void (*)(void *));
struct vqe_zone *zone_alloc(char *zone_name, int type, int flags, int size,
                            int max, int proj_id, void (*ctor)(void *),
                            void (*dtor)(void *)) {
  int n_flags = O_CREAT;
  if (type == 0) {
    fprintf(stderr, "This API is deprecated; replace with "
                    "zone_instance_get_loc()\n");
    if (flags == 1)
      n_flags |= O_APPEND;
    return (zone_instance_get_loc(zone_name, n_flags, size, max, ctor, dtor));
  } else {
    fprintf(stderr, "Use zone_instance_get_sm() API ...\n");
    return (NULL);
  }
}


x86 assembly (clang, -O0):
<zone_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ac <zone_alloc+0x8c>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1189 <zone_alloc+0x69>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
call   1040 <zone_instance_get_loc@plt>
mov    %rax,-0x8(%rbp)
jmp    11c9 <zone_alloc+0xa9>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zone_alloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1155 <zone_alloc+0x35>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeff(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%ebp
mov    %rdi,%rbx
mov    0x48(%rsp),%rax
mov    %rax,(%rsp)
mov    0x40(%rsp),%r12
mov    0x2e83(%rip),%rax
mov    (%rax),%r15d
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
xor    %esi,%esi
cmp    $0x1,%ebp
jne    119d <zone_alloc+0x7d>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
or     %r15d,%esi
mov    %rbx,%rdi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %r12,%r8
mov    (%rsp),%r9
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <zone_instance_get_loc@plt>

LLVM IR (-O0):
%struct.vqe_zone = type { i32 }
@O_CREAT = global i32 0
@stderr = global i32 0
@.str = [62 x i8] c"This API is deprecated; replace with zone_instance_get_loc()\0A\00"
@O_APPEND = global i32 0
@.str.1 = [36 x i8] c"Use zone_instance_get_sm() API ...\0A\00"
define %struct.vqe_zone* @zone_alloc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, void (i8*)* %6, void (i8*)* %7) {
%9 = alloca %struct.vqe_zone*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca void (i8*)*
%17 = alloca void (i8*)*
%18 = alloca i32
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store void (i8*)* %6, void (i8*)** %16
store void (i8*)* %7, void (i8*)** %17
%19 = load i32, i32* @O_CREAT
store i32 %19, i32* %18
%20 = load i32, i32* %11
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %39
22: ; preds = %8
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %12
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32, i32* @O_APPEND
%29 = load i32, i32* %18
%30 = or i32 %29, %28
store i32 %30, i32* %18
br label %31
31: ; preds = %27, %22
%32 = load i8*, i8** %10
%33 = load i32, i32* %18
%34 = load i32, i32* %13
%35 = load i32, i32* %14
%36 = load void (i8*)*, void (i8*)** %16
%37 = load void (i8*)*, void (i8*)** %17
%38 = call %struct.vqe_zone* @zone_instance_get_loc(i8* %32, i32 %33, i32 %34, i32 %35, void (i8*)* %36, void (i8*)* %37)
store %struct.vqe_zone* %38, %struct.vqe_zone** %9
br label %42
39: ; preds = %8
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store %struct.vqe_zone* null, %struct.vqe_zone** %9
br label %42
42: ; preds = %39, %31
%43 = load %struct.vqe_zone*, %struct.vqe_zone** %9
ret %struct.vqe_zone* %43
}

LLVM IR (-O2):
%struct.vqe_zone = type { i32 }
@O_CREAT = global i32 0
@stderr = global i32 0
@.str = [62 x i8] c"This API is deprecated; replace with zone_instance_get_loc()\0A\00"
@O_APPEND = global i32 0
@.str.1 = [36 x i8] c"Use zone_instance_get_sm() API ...\0A\00"
define %struct.vqe_zone* @zone_alloc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, void (i8*)* %6, void (i8*)* %7) {
%9 = icmp eq i32 %1, 0
br i1 %9, label %10, label %19
10: ; preds = %8
%11 = load i32, i32* @O_CREAT
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %2, 1
%15 = load i32, i32* @O_APPEND
%16 = select i1 %14, i32 %15, i32 0
%17 = or i32 %16, %11
%18 = tail call %struct.vqe_zone* @zone_instance_get_loc(i8* %0, i32 %17, i32 %3, i32 %4, void (i8*)* %6, void (i8*)* %7)
br label %22
19: ; preds = %8
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %19, %10
%23 = phi %struct.vqe_zone* [ %18, %10 ], [ null, %19 ]
ret %struct.vqe_zone* %23
}