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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ buf_free(struct buf *);
int buf_isempty(struct buf *);
struct buf *buf_new(char *);
void case_buf_isempty() {
  struct buf *buf1 = buf_new("test");
  struct buf *buf2 = buf_new(NULL);
  assert(!buf_isempty(buf1));
  assert(buf_isempty(buf2));
  buf_free(buf1);
  buf_free(buf2);
}


x86 assembly (clang, -O0):
<case_buf_isempty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <buf_new@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <buf_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <buf_isempty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <buf_isempty@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1060 <buf_free@plt>
mov    -0x10(%rbp),%rdi
call   1060 <buf_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<case_buf_isempty>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1030 <buf_new@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1030 <buf_new@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <buf_isempty@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <buf_isempty@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %r14,%rdi
call   1060 <buf_free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <buf_free@plt>

LLVM IR (-O0):
%struct.buf = type { i32 }
@.str = [5 x i8] c"test\00"
define void @case_buf_isempty() {
%1 = alloca %struct.buf*
%2 = alloca %struct.buf*
%3 = call %struct.buf* @buf_new(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.buf* %3, %struct.buf** %1
%4 = call %struct.buf* @buf_new(i8* null)
store %struct.buf* %4, %struct.buf** %2
%5 = load %struct.buf*, %struct.buf** %1
%6 = call i32 @buf_isempty(%struct.buf* %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load %struct.buf*, %struct.buf** %2
%12 = call i32 @buf_isempty(%struct.buf* %11)
%13 = call i32 @assert(i32 %12)
%14 = load %struct.buf*, %struct.buf** %1
%15 = call i32 @buf_free(%struct.buf* %14)
%16 = load %struct.buf*, %struct.buf** %2
%17 = call i32 @buf_free(%struct.buf* %16)
ret void
}

LLVM IR (-O2):
%struct.buf = type { i32 }
@.str = [5 x i8] c"test\00"
define void @case_buf_isempty() {
%1 = tail call %struct.buf* @buf_new(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call %struct.buf* @buf_new(i8* null)
%3 = tail call i32 @buf_isempty(%struct.buf* %1)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @buf_isempty(%struct.buf* %2)
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @buf_free(%struct.buf* %1)
%10 = tail call i32 @buf_free(%struct.buf* %2)
ret void
}