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

/* Variables and functions */
int /*<<< orphan*/ dequeue(struct queuenode *);
int /*<<< orphan*/ free(struct queuenode *);
struct queuenode *front(struct queuenode *);
void freequeue(struct queue *q) {
  struct queuenode *temp;
  while ((temp = front(q))) {
    dequeue(q);
    free(temp);
  }
  free(q);
}


x86 assembly (clang, -O0):
<freequeue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <front@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     116a <freequeue+0x3a>
mov    -0x8(%rbp),%rdi
call   1040 <dequeue@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    113c <freequeue+0xc>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freequeue>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <front@plt>
test   %rax,%rax
je     1170 <freequeue+0x40>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <dequeue@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <front@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1150 <freequeue+0x20>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.queue = type opaque
%struct.queuenode = type { i32 }
define void @freequeue(%struct.queue* %0) {
%2 = alloca %struct.queue*
%3 = alloca %struct.queuenode*
store %struct.queue* %0, %struct.queue** %2
br label %4
4: ; preds = %9, %1
%5 = load %struct.queue*, %struct.queue** %2
%6 = bitcast %struct.queue* %5 to %struct.queuenode*
%7 = call %struct.queuenode* @front(%struct.queuenode* %6)
store %struct.queuenode* %7, %struct.queuenode** %3
%8 = icmp ne %struct.queuenode* %7, null
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = load %struct.queue*, %struct.queue** %2
%11 = bitcast %struct.queue* %10 to %struct.queuenode*
%12 = call i32 @dequeue(%struct.queuenode* %11)
%13 = load %struct.queuenode*, %struct.queuenode** %3
%14 = call i32 @free(%struct.queuenode* %13)
br label %4
15: ; preds = %4
%16 = load %struct.queue*, %struct.queue** %2
%17 = bitcast %struct.queue* %16 to %struct.queuenode*
%18 = call i32 @free(%struct.queuenode* %17)
ret void
}

LLVM IR (-O2):
%struct.queue = type opaque
%struct.queuenode = type { i32 }
define void @freequeue(%struct.queue* %0) {
%2 = bitcast %struct.queue* %0 to %struct.queuenode*
%3 = tail call %struct.queuenode* @front(%struct.queuenode* %2)
%4 = icmp eq %struct.queuenode* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1, %5
%6 = phi %struct.queuenode* [ %9, %5 ], [ %3, %1 ]
%7 = tail call i32 @dequeue(%struct.queuenode* %2)
%8 = tail call i32 @free(%struct.queuenode* %6)
%9 = tail call %struct.queuenode* @front(%struct.queuenode* %2)
%10 = icmp eq %struct.queuenode* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %1
%12 = tail call i32 @free(%struct.queuenode* %2)
ret void
}