#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 */
void *zone_acquire(struct vqe_zone *);
struct vqe_zone *zone_alloc(char *, int, int, int, int, int, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ zone_destroy(struct vqe_zone *);
int /*<<< orphan*/ zone_release(struct vqe_zone *, void *);
int main(int argc, const char *argv[]) {
  int i;
  void *p[1002];
  struct vqe_zone *z = zone_alloc("channel1", 0, 1, 133, 1002, 0, 0, 0);
  for (i = 0; i < 1001; i++)
    p[i] = zone_acquire(z);
  for (i = 0; i < 1001; i++)
    zone_release(z, p[i]);
  for (i = 0; i < 1003; i++)
    p[i] = zone_acquire(z);
  for (i = 0; i < 1002; i++)
    zone_release(z, p[i]);
  zone_destroy(z);
  struct vqe_zone *z1 = zone_alloc("channel_2", 1, 0, 133, 1002, 1, 0, 0);
  for (i = 0; i < 1001; i++)
    p[i] = zone_acquire(z1);
  for (i = 0; i < 1001; i++)
    zone_release(z1, p[i]);
  for (i = 0; i < 1003; i++)
    p[i] = zone_acquire(z1);
  for (i = 0; i < 1002; i++)
    zone_release(z1, p[i]);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
xor    %r9d,%r9d
mov    $0x1,%edx
mov    $0x85,%ecx
mov    $0x3ea,%r8d
mov    %r9d,%esi
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1060 <zone_alloc@plt>
mov    %rax,-0x1f78(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e9,-0x14(%rbp)
jge    11ce <main+0x8e>
mov    -0x1f78(%rbp),%rdi
call   1050 <zone_acquire@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x1f70(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1198 <main+0x58>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e9,-0x14(%rbp)
jge    1208 <main+0xc8>
mov    -0x1f78(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x1f70(%rbp,%rax,8),%rsi
ff
call   1030 <zone_release@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d5 <main+0x95>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3eb,-0x14(%rbp)
jge    1245 <main+0x105>
mov    -0x1f78(%rbp),%rdi
call   1050 <zone_acquire@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x1f70(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120f <main+0xcf>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3ea,-0x14(%rbp)
jge    127f <main+0x13f>
mov    -0x1f78(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x1f70(%rbp,%rax,8),%rsi
ff
call   1030 <zone_release@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124c <main+0x10c>
mov    -0x1f78(%rbp),%rdi
call   1040 <zone_destroy@plt>
lea    0xd77(%rip),%rdi
mov    $0x1,%r9d
xor    %edx,%edx
mov    $0x85,%ecx
mov    $0x3ea,%r8d
mov    %r9d,%esi
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1060 <zone_alloc@plt>
mov    %rax,-0x1f80(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e9,-0x14(%rbp)
jge    1300 <main+0x1c0>
mov    -0x1f80(%rbp),%rdi
call   1050 <zone_acquire@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x1f70(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ca <main+0x18a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e9,-0x14(%rbp)
jge    133a <main+0x1fa>
mov    -0x1f80(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x1f70(%rbp,%rax,8),%rsi
ff
call   1030 <zone_release@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1307 <main+0x1c7>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3eb,-0x14(%rbp)
jge    1377 <main+0x237>
mov    -0x1f80(%rbp),%rdi
call   1050 <zone_acquire@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x1f70(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1341 <main+0x201>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3ea,-0x14(%rbp)
jge    13b1 <main+0x271>
mov    -0x1f80(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x1f70(%rbp,%rax,8),%rsi
ff
call   1030 <zone_release@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    137e <main+0x23e>
mov    $0x1,%eax
add    $0x1f90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1f58,%rsp
lea    0xeaf(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x85,%ecx
mov    $0x3ea,%r8d
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1060 <zone_alloc@plt>
add    $0x10,%rsp
mov    %rax,%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <zone_acquire@plt>
mov    %rax,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x3e9,%rbx
jne    1180 <main+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <zone_release@plt>
add    $0x1,%rbx
cmp    $0x3e9,%rbx
jne    11a0 <main+0x60>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <zone_acquire@plt>
mov    %rax,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x3eb,%rbx
jne    11c0 <main+0x80>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <zone_release@plt>
add    $0x1,%rbx
cmp    $0x3ea,%rbx
jne    11e0 <main+0xa0>
mov    %r14,%rdi
call   1040 <zone_destroy@plt>
lea    0xe01(%rip),%rdi
xor    %ebx,%ebx
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x85,%ecx
mov    $0x3ea,%r8d
mov    $0x1,%r9d
push   $0x0
push   $0x0
call   1060 <zone_alloc@plt>
add    $0x10,%rsp
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <zone_acquire@plt>
mov    %rax,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x3e9,%rbx
jne    1240 <main+0x100>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <zone_release@plt>
add    $0x1,%rbx
cmp    $0x3e9,%rbx
jne    1260 <main+0x120>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <zone_acquire@plt>
mov    %rax,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x3eb,%rbx
jne    1280 <main+0x140>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <zone_release@plt>
add    $0x1,%rbx
cmp    $0x3ea,%rbx
jne    12a0 <main+0x160>
mov    $0x1,%eax
add    $0x1f58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.vqe_zone = type { i32 }
@.str = [9 x i8] c"channel1\00"
@.str.1 = [10 x i8] c"channel_2\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1002 x i8*]
%8 = alloca %struct.vqe_zone*
%9 = alloca %struct.vqe_zone*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call %struct.vqe_zone* @zone_alloc(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0, i32 1, i32 133, i32 1002, i32 0, i32 0, i32 0)
store %struct.vqe_zone* %10, %struct.vqe_zone** %8
store i32 0, i32* %6
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 1001
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load %struct.vqe_zone*, %struct.vqe_zone** %8
%16 = call i8* @zone_acquire(%struct.vqe_zone* %15)
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %18
store i8* %16, i8** %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %11
23: ; preds = %11
store i32 0, i32* %6
br label %24
24: ; preds = %34, %23
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 1001
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load %struct.vqe_zone*, %struct.vqe_zone** %8
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @zone_release(%struct.vqe_zone* %28, i8* %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %24
37: ; preds = %24
store i32 0, i32* %6
br label %38
38: ; preds = %47, %37
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 1003
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load %struct.vqe_zone*, %struct.vqe_zone** %8
%43 = call i8* @zone_acquire(%struct.vqe_zone* %42)
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %45
store i8* %43, i8** %46
br label %47
47: ; preds = %41
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %38
50: ; preds = %38
store i32 0, i32* %6
br label %51
51: ; preds = %61, %50
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 1002
br i1 %53, label %54, label %64
54: ; preds = %51
%55 = load %struct.vqe_zone*, %struct.vqe_zone** %8
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @zone_release(%struct.vqe_zone* %55, i8* %59)
br label %61
61: ; preds = %54
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %51
64: ; preds = %51
%65 = load %struct.vqe_zone*, %struct.vqe_zone** %8
%66 = call i32 @zone_destroy(%struct.vqe_zone* %65)
%67 = call %struct.vqe_zone* @zone_alloc(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0, i32 133, i32 1002, i32 1, i32 0, i32 0)
store %struct.vqe_zone* %67, %struct.vqe_zone** %9
store i32 0, i32* %6
br label %68
68: ; preds = %77, %64
%69 = load i32, i32* %6
%70 = icmp slt i32 %69, 1001
br i1 %70, label %71, label %80
71: ; preds = %68
%72 = load %struct.vqe_zone*, %struct.vqe_zone** %9
%73 = call i8* @zone_acquire(%struct.vqe_zone* %72)
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %75
store i8* %73, i8** %76
br label %77
77: ; preds = %71
%78 = load i32, i32* %6
%79 = add nsw i32 %78, 1
store i32 %79, i32* %6
br label %68
80: ; preds = %68
store i32 0, i32* %6
br label %81
81: ; preds = %91, %80
%82 = load i32, i32* %6
%83 = icmp slt i32 %82, 1001
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = load %struct.vqe_zone*, %struct.vqe_zone** %9
%86 = load i32, i32* %6
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = call i32 @zone_release(%struct.vqe_zone* %85, i8* %89)
br label %91
91: ; preds = %84
%92 = load i32, i32* %6
%93 = add nsw i32 %92, 1
store i32 %93, i32* %6
br label %81
94: ; preds = %81
store i32 0, i32* %6
br label %95
95: ; preds = %104, %94
%96 = load i32, i32* %6
%97 = icmp slt i32 %96, 1003
br i1 %97, label %98, label %107
98: ; preds = %95
%99 = load %struct.vqe_zone*, %struct.vqe_zone** %9
%100 = call i8* @zone_acquire(%struct.vqe_zone* %99)
%101 = load i32, i32* %6
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %102
store i8* %100, i8** %103
br label %104
104: ; preds = %98
%105 = load i32, i32* %6
%106 = add nsw i32 %105, 1
store i32 %106, i32* %6
br label %95
107: ; preds = %95
store i32 0, i32* %6
br label %108
108: ; preds = %118, %107
%109 = load i32, i32* %6
%110 = icmp slt i32 %109, 1002
br i1 %110, label %111, label %121
111: ; preds = %108
%112 = load %struct.vqe_zone*, %struct.vqe_zone** %9
%113 = load i32, i32* %6
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %7, i64 0, i64 %114
%116 = load i8*, i8** %115
%117 = call i32 @zone_release(%struct.vqe_zone* %112, i8* %116)
br label %118
118: ; preds = %111
%119 = load i32, i32* %6
%120 = add nsw i32 %119, 1
store i32 %120, i32* %6
br label %108
121: ; preds = %108
ret i32 1
}

LLVM IR (-O2):
%struct.vqe_zone = type { i32 }
@.str = [9 x i8] c"channel1\00"
@.str.1 = [10 x i8] c"channel_2\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1002 x i8*]
%4 = bitcast [1002 x i8*]* %3 to i8*
%5 = tail call %struct.vqe_zone* @zone_alloc(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0, i32 1, i32 133, i32 1002, i32 0, i32 0, i32 0)
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %10, %6 ]
%8 = tail call i8* @zone_acquire(%struct.vqe_zone* %5)
%9 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %7
store i8* %8, i8** %9
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i64 %10, 1001
br i1 %11, label %12, label %6
12: ; preds = %6, %12
%13 = phi i64 [ %17, %12 ], [ 0, %6 ]
%14 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @zone_release(%struct.vqe_zone* %5, i8* %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 1001
br i1 %18, label %19, label %12
19: ; preds = %12, %19
%20 = phi i64 [ %23, %19 ], [ 0, %12 ]
%21 = tail call i8* @zone_acquire(%struct.vqe_zone* %5)
%22 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %20
store i8* %21, i8** %22
%23 = add nuw nsw i64 %20, 1
%24 = icmp eq i64 %23, 1003
br i1 %24, label %25, label %19
25: ; preds = %19, %25
%26 = phi i64 [ %30, %25 ], [ 0, %19 ]
%27 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 @zone_release(%struct.vqe_zone* %5, i8* %28)
%30 = add nuw nsw i64 %26, 1
%31 = icmp eq i64 %30, 1002
br i1 %31, label %32, label %25
32: ; preds = %25
%33 = tail call i32 @zone_destroy(%struct.vqe_zone* %5)
%34 = tail call %struct.vqe_zone* @zone_alloc(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0, i32 133, i32 1002, i32 1, i32 0, i32 0)
br label %35
35: ; preds = %32, %35
%36 = phi i64 [ 0, %32 ], [ %39, %35 ]
%37 = tail call i8* @zone_acquire(%struct.vqe_zone* %34)
%38 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %36
store i8* %37, i8** %38
%39 = add nuw nsw i64 %36, 1
%40 = icmp eq i64 %39, 1001
br i1 %40, label %41, label %35
41: ; preds = %35, %41
%42 = phi i64 [ %46, %41 ], [ 0, %35 ]
%43 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = tail call i32 @zone_release(%struct.vqe_zone* %34, i8* %44)
%46 = add nuw nsw i64 %42, 1
%47 = icmp eq i64 %46, 1001
br i1 %47, label %48, label %41
48: ; preds = %41, %48
%49 = phi i64 [ %52, %48 ], [ 0, %41 ]
%50 = tail call i8* @zone_acquire(%struct.vqe_zone* %34)
%51 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %49
store i8* %50, i8** %51
%52 = add nuw nsw i64 %49, 1
%53 = icmp eq i64 %52, 1003
br i1 %53, label %54, label %48
54: ; preds = %48, %54
%55 = phi i64 [ %59, %54 ], [ 0, %48 ]
%56 = getelementptr inbounds [1002 x i8*], [1002 x i8*]* %3, i64 0, i64 %55
%57 = load i8*, i8** %56
%58 = tail call i32 @zone_release(%struct.vqe_zone* %34, i8* %57)
%59 = add nuw nsw i64 %55, 1
%60 = icmp eq i64 %59, 1002
br i1 %60, label %61, label %54
61: ; preds = %54
ret i32 1
}