#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 dequeue();
int enqueue(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int input[100];
  int output[100];
  int select;
  int i_count = 0;
  int o_count = 0;
  int loop = 1;
  int i, temp;
  while (loop) {
    printf("[1]输入 [2]取出 [3]退出 ==>");
    scanf("%d", &select);
    switch (select) {
    case 1:
      printf("请输入存入列队的值(%d) ==>", i_count + 1);
      scanf("%d", &temp);
      if (enqueue(temp) == -1)
        printf("队列全满.\n");
      else
        input[i_count++] = temp;
      break;
    case 2:
      if ((temp = dequeue()) == -1)
        printf("队列是空的.\n");
      else {
        printf("取出队列元素：%d\n", temp);
        output[o_count++] = temp;
      }
      break;
    case 3:
      loop = 0;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x338(%rbp)
movl   $0x0,-0x33c(%rbp)
movl   $0x1,-0x340(%rbp)
cmpl   $0x0,-0x340(%rbp)
je     12c7 <main+0x187>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x334(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x334(%rbp),%eax
mov    %eax,-0x34c(%rbp)
sub    $0x1,%eax
je     11e0 <main+0xa0>
jmp    11b8 <main+0x78>
mov    -0x34c(%rbp),%eax
sub    $0x2,%eax
je     1256 <main+0x116>
jmp    11cc <main+0x8c>
mov    -0x34c(%rbp),%eax
sub    $0x3,%eax
je     12b8 <main+0x178>
jmp    12c2 <main+0x182>
mov    -0x338(%rbp),%esi
add    $0x1,%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe24(%rip),%rdi
lea    -0x348(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x348(%rbp),%edi
call   1060 <enqueue@plt>
cmp    $0xffffffff,%eax
jne    1231 <main+0xf1>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1251 <main+0x111>
mov    -0x348(%rbp),%ecx
mov    -0x338(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x338(%rbp)
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    12c2 <main+0x182>
mov    $0x0,%al
call   1040 <dequeue@plt>
mov    %eax,-0x348(%rbp)
cmp    $0xffffffff,%eax
jne    127f <main+0x13f>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b3 <main+0x173>
mov    -0x348(%rbp),%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x348(%rbp),%ecx
mov    -0x33c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x33c(%rbp)
cltq
mov    %ecx,-0x330(%rbp,%rax,4)
jmp    12c2 <main+0x182>
movl   $0x0,-0x340(%rbp)
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%r14
lea    0xeb9(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xeb0(%rip),%r12
mov    %rsp,%r13
xor    %ebp,%ebp
add    $0x1,%ebp
jmp    1189 <main+0x39>
nop
cmp    $0x3,%eax
je     1213 <main+0xc3>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11d0 <main+0x80>
cmp    $0x2,%eax
jne    1180 <main+0x30>
xor    %eax,%eax
call   1050 <dequeue@plt>
mov    %eax,(%rsp)
cmp    $0xffffffff,%eax
je     1202 <main+0xb2>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1189 <main+0x39>
nopl   (%rax)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
call   1070 <enqueue@plt>
cmp    $0xffffffff,%eax
jne    117a <main+0x2a>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
jmp    1189 <main+0x39>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
jmp    1189 <main+0x39>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"[1]\E8\BE\93\E5\85\A5 [2]\E5\8F\96\E5\87\BA [3]\E9\80\80\E5\87\BA ==>\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\98\E5\85\A5\E5\88\97\E9\98\9F\E7\9A\84\E5\80\BC(%d) ==>\00"
@.str.3 = [15 x i8] c"\E9\98\9F\E5\88\97\E5\85\A8\E6\BB\A1.\0A\00"
@.str.4 = [18 x i8] c"\E9\98\9F\E5\88\97\E6\98\AF\E7\A9\BA\E7\9A\84.\0A\00"
@.str.5 = [25 x i8] c"\E5\8F\96\E5\87\BA\E9\98\9F\E5\88\97\E5\85\83\E7\B4\A0\EF\BC\9A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %10
10: ; preds = %49, %0
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %50
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%16 = load i32, i32* %4
switch i32 %16, label %49 [
i32 1, label %17
i32 2, label %34
i32 3, label %48
]
17: ; preds = %13
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%22 = load i32, i32* %9
%23 = call i32 @enqueue(i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %33
27: ; preds = %17
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %27, %25
br label %49
34: ; preds = %13
%35 = call i32 (...) @dequeue()
store i32 %35, i32* %9
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %47
39: ; preds = %34
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %9
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %45
store i32 %42, i32* %46
br label %47
47: ; preds = %39, %37
br label %49
48: ; preds = %13
store i32 0, i32* %7
br label %49
49: ; preds = %13, %48, %47, %33
br label %10
50: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"[1]\E8\BE\93\E5\85\A5 [2]\E5\8F\96\E5\87\BA [3]\E9\80\80\E5\87\BA ==>\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\98\E5\85\A5\E5\88\97\E9\98\9F\E7\9A\84\E5\80\BC(%d) ==>\00"
@.str.5 = [25 x i8] c"\E5\8F\96\E5\87\BA\E9\98\9F\E5\88\97\E5\85\83\E7\B4\A0\EF\BC\9A%d\0A\00"
@str = [17 x i8] c"\E9\98\9F\E5\88\97\E6\98\AF\E7\A9\BA\E7\9A\84.\00"
@str.6 = [14 x i8] c"\E9\98\9F\E5\88\97\E5\85\A8\E6\BB\A1.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %12, %0
%6 = phi i32 [ 0, %0 ], [ %7, %12 ]
%7 = add nuw nsw i32 %6, 1
br label %8
8: ; preds = %25, %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %25 [
i32 1, label %12
i32 2, label %20
i32 3, label %28
]
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = call i32 @enqueue(i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %5
18: ; preds = %12
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
br label %25
20: ; preds = %8
%21 = call i32 (...) @dequeue()
store i32 %21, i32* %2
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %23, %26, %18, %8
br label %8
26: ; preds = %20
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %25
28: ; preds = %8
ret i32 0
}