#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 ring_buffer {
  int dummy;
};

/* Variables and functions */
struct ring_buffer *ring_buffer_create(int);
int /*<<< orphan*/ ring_buffer_dispose(struct ring_buffer *);
int ring_buffer_pop(struct ring_buffer *);
int /*<<< orphan*/ ring_buffer_push(struct ring_buffer *, int);
void harness(int x, int y, int z) {
  struct ring_buffer *b = ring_buffer_create(2);
  if (b == 0)
    return;
  ring_buffer_push(b, x);
  ring_buffer_push(b, y);
  int h = ring_buffer_pop(b);
  ring_buffer_push(b, z);
  h = ring_buffer_pop(b);
  h = ring_buffer_pop(b);
  ring_buffer_dispose(b);
}


x86 assembly (clang, -O0):
<harness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x2,%edi
call   1040 <ring_buffer_create@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116f <harness+0x2f>
jmp    11c0 <harness+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <ring_buffer_push@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <ring_buffer_push@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ring_buffer_pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <ring_buffer_push@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ring_buffer_pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <ring_buffer_pop@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ring_buffer_dispose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<harness>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x2,%edi
call   1040 <ring_buffer_create@plt>
test   %rax,%rax
je     11ab <harness+0x6b>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
call   1060 <ring_buffer_push@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <ring_buffer_push@plt>
mov    %rbx,%rdi
call   1050 <ring_buffer_pop@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <ring_buffer_push@plt>
mov    %rbx,%rdi
call   1050 <ring_buffer_pop@plt>
mov    %rbx,%rdi
call   1050 <ring_buffer_pop@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ring_buffer_dispose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ring_buffer = type { i32 }
define void @harness(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.ring_buffer*
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = call %struct.ring_buffer* @ring_buffer_create(i32 2)
store %struct.ring_buffer* %9, %struct.ring_buffer** %7
%10 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%11 = icmp eq %struct.ring_buffer* %10, null
br i1 %11, label %12, label %13
12: ; preds = %3
br label %31
13: ; preds = %3
%14 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%15 = load i32, i32* %4
%16 = call i32 @ring_buffer_push(%struct.ring_buffer* %14, i32 %15)
%17 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%18 = load i32, i32* %5
%19 = call i32 @ring_buffer_push(%struct.ring_buffer* %17, i32 %18)
%20 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%21 = call i32 @ring_buffer_pop(%struct.ring_buffer* %20)
store i32 %21, i32* %8
%22 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%23 = load i32, i32* %6
%24 = call i32 @ring_buffer_push(%struct.ring_buffer* %22, i32 %23)
%25 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%26 = call i32 @ring_buffer_pop(%struct.ring_buffer* %25)
store i32 %26, i32* %8
%27 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%28 = call i32 @ring_buffer_pop(%struct.ring_buffer* %27)
store i32 %28, i32* %8
%29 = load %struct.ring_buffer*, %struct.ring_buffer** %7
%30 = call i32 @ring_buffer_dispose(%struct.ring_buffer* %29)
br label %31
31: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
%struct.ring_buffer = type { i32 }
define void @harness(i32 %0, i32 %1, i32 %2) {
%4 = tail call %struct.ring_buffer* @ring_buffer_create(i32 2)
%5 = icmp eq %struct.ring_buffer* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i32 @ring_buffer_push(%struct.ring_buffer* %4, i32 %0)
%8 = tail call i32 @ring_buffer_push(%struct.ring_buffer* %4, i32 %1)
%9 = tail call i32 @ring_buffer_pop(%struct.ring_buffer* %4)
%10 = tail call i32 @ring_buffer_push(%struct.ring_buffer* %4, i32 %2)
%11 = tail call i32 @ring_buffer_pop(%struct.ring_buffer* %4)
%12 = tail call i32 @ring_buffer_pop(%struct.ring_buffer* %4)
%13 = tail call i32 @ring_buffer_dispose(%struct.ring_buffer* %4)
br label %14
14: ; preds = %3, %6
ret void
}