#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;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int *queue_int(struct queue *);
int /*<<< orphan*/ queue_push_close(struct queue *, int);
int queue_push_open(struct queue *);
int queue_push_int(struct queue *q, int v) {
  assert(v != 0);
  int tail = queue_push_open(q);
  if (tail < 0)
    return 1;
  int *data = queue_int(q);
  data[tail] = v;
  queue_push_close(q, tail);
  return 0;
}


x86 assembly (clang, -O0):
<queue_push_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <queue_push_open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1182 <queue_push_int+0x42>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <queue_push_int+0x70>
mov    -0x10(%rbp),%rdi
call   1030 <queue_int@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <queue_push_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queue_push_int>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edi,%edi
test   %esi,%esi
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1060 <queue_push_open@plt>
test   %eax,%eax
js     1181 <queue_push_int+0x41>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <queue_int@plt>
mov    %ebp,%ecx
mov    %r14d,(%rax,%rcx,4)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <queue_push_close@plt>
xor    %eax,%eax
jmp    1186 <queue_push_int+0x46>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.queue = type { i32 }
define i32 @queue_push_int(%struct.queue* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.queue*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store %struct.queue* %0, %struct.queue** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load %struct.queue*, %struct.queue** %4
%13 = call i32 @queue_push_open(%struct.queue* %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %28
17: ; preds = %2
%18 = load %struct.queue*, %struct.queue** %4
%19 = call i32* @queue_int(%struct.queue* %18)
store i32* %19, i32** %7
%20 = load i32, i32* %5
%21 = load i32*, i32** %7
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
%25 = load %struct.queue*, %struct.queue** %4
%26 = load i32, i32* %6
%27 = call i32 @queue_push_close(%struct.queue* %25, i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %17, %16
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.queue = type { i32 }
define i32 @queue_push_int(%struct.queue* %0, i32 %1) {
%3 = icmp ne i32 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @queue_push_open(%struct.queue* %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = tail call i32* @queue_int(%struct.queue* %0)
%10 = zext i32 %6 to i64
%11 = getelementptr inbounds i32, i32* %9, i64 %10
store i32 %1, i32* %11
%12 = tail call i32 @queue_push_close(%struct.queue* %0, i32 %6)
br label %13
13: ; preds = %2, %8
%14 = phi i32 [ 0, %8 ], [ 1, %2 ]
ret i32 %14
}