#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 queue {
  int dummy;
};
struct arrayStack {
  int dummy;
};

/* Variables and functions */
int DeQueue(struct queue *);
int /*<<< orphan*/ EnQueue(struct queue *, int);
struct queue *createQueue(int);
struct arrayStack *createStack(int);
int getQSize(struct queue *);
int /*<<< orphan*/ isEmpty(struct queue *);
int /*<<< orphan*/ isStackEmpty(struct arrayStack *);
int pop(struct arrayStack *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(struct arrayStack *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  struct queue *Q = createQueue(11);
  int i, k;
  for (i = 0; i < 10; i++)
    EnQueue(Q, (i + 1) * 10);
  printf("Enter the value till the elements of queue is reversed : ");
  scanf("%d", &k);
  struct arrayStack *S = createStack(k);
  for (i = 0; i < k; i++) {
    push(S, DeQueue(Q));
  }
  while (!isStackEmpty(S)) {
    EnQueue(Q, pop(S));
  }
  int size = getQSize(Q);
  for (i = 0; i < size - k; i++) {
    int t = DeQueue(Q);
    EnQueue(Q, t);
  }
  while (!isEmpty(Q)) {
    int d = DeQueue(Q);
    printf(" %d  ", d);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xb,%edi
call   1030 <createQueue@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11fe <main+0x4e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   $0xa,%eax,%esi
call   1040 <EnQueue@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0x24>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe27(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x18(%rbp),%edi
call   1080 <createStack@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1265 <main+0xb5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <DeQueue@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   10b0 <push@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122f <main+0x7f>
jmp    126a <main+0xba>
mov    -0x20(%rbp),%rdi
call   10c0 <isStackEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1288 <main+0xd8>
jmp    12a9 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <pop@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
jmp    126a <main+0xba>
mov    -0x10(%rbp),%rdi
call   10d0 <getQSize@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    12f3 <main+0x143>
mov    -0x10(%rbp),%rdi
call   1050 <DeQueue@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1040 <EnQueue@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12bc <main+0x10c>
jmp    12f8 <main+0x148>
mov    -0x10(%rbp),%rdi
call   1090 <isEmpty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1316 <main+0x166>
jmp    1338 <main+0x188>
mov    -0x10(%rbp),%rdi
call   1050 <DeQueue@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12f8 <main+0x148>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xb,%edi
call   1030 <createQueue@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x14,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x1e,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x28,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x32,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x3c,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x46,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x50,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x5a,%esi
call   1040 <EnQueue@plt>
mov    %r14,%rdi
mov    $0x64,%esi
call   1040 <EnQueue@plt>
lea    0xdb2(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xddc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%edi
call   1080 <createStack@plt>
mov    %rax,%rbx
cmpl   $0x0,0xc(%rsp)
jle    12b2 <main+0x102>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <DeQueue@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10b0 <push@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1280 <main+0xd0>
jmp    12b2 <main+0x102>
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
mov    %rbx,%rdi
call   10c0 <isStackEmpty@plt>
test   %eax,%eax
je     12a0 <main+0xf0>
mov    %r14,%rdi
call   10d0 <getQSize@plt>
cmp    0xc(%rsp),%eax
jle    12ef <main+0x13f>
mov    %eax,%ebx
xor    %ebp,%ebp
mov    %r14,%rdi
call   1050 <DeQueue@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <EnQueue@plt>
add    $0x1,%ebp
mov    %ebx,%eax
sub    0xc(%rsp),%eax
cmp    %eax,%ebp
jl     12d0 <main+0x120>
mov    %r14,%rdi
call   1090 <isEmpty@plt>
test   %eax,%eax
jne    1330 <main+0x180>
lea    0xd3b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <DeQueue@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1090 <isEmpty@plt>
test   %eax,%eax
je     1310 <main+0x160>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.queue = type { i32 }
%struct.arrayStack = type { i32 }
@.str = [58 x i8] c"Enter the value till the elements of queue is reversed : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c" %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.queue*
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.arrayStack*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call %struct.queue* @createQueue(i32 11)
store %struct.queue* %9, %struct.queue** %2
store i32 0, i32* %3
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load %struct.queue*, %struct.queue** %2
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = mul nsw i32 %16, 10
%18 = call i32 @EnQueue(%struct.queue* %14, i32 %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%25 = load i32, i32* %4
%26 = call %struct.arrayStack* @createStack(i32 %25)
store %struct.arrayStack* %26, %struct.arrayStack** %5
store i32 0, i32* %3
br label %27
27: ; preds = %36, %22
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load %struct.arrayStack*, %struct.arrayStack** %5
%33 = load %struct.queue*, %struct.queue** %2
%34 = call i32 @DeQueue(%struct.queue* %33)
%35 = call i32 @push(%struct.arrayStack* %32, i32 %34)
br label %36
36: ; preds = %31
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %27
39: ; preds = %27
br label %40
40: ; preds = %45, %39
%41 = load %struct.arrayStack*, %struct.arrayStack** %5
%42 = call i32 @isStackEmpty(%struct.arrayStack* %41)
%43 = icmp ne i32 %42, 0
%44 = xor i1 %43, true
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load %struct.queue*, %struct.queue** %2
%47 = load %struct.arrayStack*, %struct.arrayStack** %5
%48 = call i32 @pop(%struct.arrayStack* %47)
%49 = call i32 @EnQueue(%struct.queue* %46, i32 %48)
br label %40
50: ; preds = %40
%51 = load %struct.queue*, %struct.queue** %2
%52 = call i32 @getQSize(%struct.queue* %51)
store i32 %52, i32* %6
store i32 0, i32* %3
br label %53
53: ; preds = %65, %50
%54 = load i32, i32* %3
%55 = load i32, i32* %6
%56 = load i32, i32* %4
%57 = sub nsw i32 %55, %56
%58 = icmp slt i32 %54, %57
br i1 %58, label %59, label %68
59: ; preds = %53
%60 = load %struct.queue*, %struct.queue** %2
%61 = call i32 @DeQueue(%struct.queue* %60)
store i32 %61, i32* %7
%62 = load %struct.queue*, %struct.queue** %2
%63 = load i32, i32* %7
%64 = call i32 @EnQueue(%struct.queue* %62, i32 %63)
br label %65
65: ; preds = %59
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
store i32 %67, i32* %3
br label %53
68: ; preds = %53
br label %69
69: ; preds = %74, %68
%70 = load %struct.queue*, %struct.queue** %2
%71 = call i32 @isEmpty(%struct.queue* %70)
%72 = icmp ne i32 %71, 0
%73 = xor i1 %72, true
br i1 %73, label %74, label %79
74: ; preds = %69
%75 = load %struct.queue*, %struct.queue** %2
%76 = call i32 @DeQueue(%struct.queue* %75)
store i32 %76, i32* %8
%77 = load i32, i32* %8
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %77)
br label %69
79: ; preds = %69
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
%struct.queue = type { i32 }
%struct.arrayStack = type { i32 }
@.str = [58 x i8] c"Enter the value till the elements of queue is reversed : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c" %d \00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.queue* @createQueue(i32 11)
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @EnQueue(%struct.queue* %2, i32 10)
%5 = tail call i32 @EnQueue(%struct.queue* %2, i32 20)
%6 = tail call i32 @EnQueue(%struct.queue* %2, i32 30)
%7 = tail call i32 @EnQueue(%struct.queue* %2, i32 40)
%8 = tail call i32 @EnQueue(%struct.queue* %2, i32 50)
%9 = tail call i32 @EnQueue(%struct.queue* %2, i32 60)
%10 = tail call i32 @EnQueue(%struct.queue* %2, i32 70)
%11 = tail call i32 @EnQueue(%struct.queue* %2, i32 80)
%12 = tail call i32 @EnQueue(%struct.queue* %2, i32 90)
%13 = tail call i32 @EnQueue(%struct.queue* %2, i32 100)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 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* %1)
%16 = load i32, i32* %1
%17 = call %struct.arrayStack* @createStack(i32 %16)
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %23, %0
%21 = call i32 @isStackEmpty(%struct.arrayStack* %17)
%22 = icmp eq i32 %21, 0
br i1 %22, label %30, label %35
23: ; preds = %0, %23
%24 = phi i32 [ %27, %23 ], [ 0, %0 ]
%25 = call i32 @DeQueue(%struct.queue* %2)
%26 = call i32 @push(%struct.arrayStack* %17, i32 %25)
%27 = add nuw nsw i32 %24, 1
%28 = load i32, i32* %1
%29 = icmp slt i32 %27, %28
br i1 %29, label %23, label %20
30: ; preds = %20, %30
%31 = call i32 @pop(%struct.arrayStack* %17)
%32 = call i32 @EnQueue(%struct.queue* %2, i32 %31)
%33 = call i32 @isStackEmpty(%struct.arrayStack* %17)
%34 = icmp eq i32 %33, 0
br i1 %34, label %30, label %35
35: ; preds = %30, %20
%36 = call i32 @getQSize(%struct.queue* %2)
%37 = load i32, i32* %1
%38 = icmp sgt i32 %36, %37
br i1 %38, label %42, label %39
39: ; preds = %42, %35
%40 = call i32 @isEmpty(%struct.queue* %2)
%41 = icmp eq i32 %40, 0
br i1 %41, label %50, label %55
42: ; preds = %35, %42
%43 = phi i32 [ %46, %42 ], [ 0, %35 ]
%44 = call i32 @DeQueue(%struct.queue* %2)
%45 = call i32 @EnQueue(%struct.queue* %2, i32 %44)
%46 = add nuw nsw i32 %43, 1
%47 = load i32, i32* %1
%48 = sub nsw i32 %36, %47
%49 = icmp slt i32 %46, %48
br i1 %49, label %42, label %39
50: ; preds = %39, %50
%51 = call i32 @DeQueue(%struct.queue* %2)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = call i32 @isEmpty(%struct.queue* %2)
%54 = icmp eq i32 %53, 0
br i1 %54, label %50, label %55
55: ; preds = %50, %39
ret i32 0
}