#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 *);
struct buf *buf_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ buf_puts(struct buf *, char *);
int /*<<< orphan*/ buf_str(struct buf *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
void case_buf_str() {
  struct buf *buf = buf_new(NULL);
  assert(strcmp(buf_str(buf), "") == 0);
  buf_puts(buf, "abcdef");
  assert(strcmp(buf_str(buf), "abcdef") == 0);
  buf_free(buf);
}


x86 assembly (clang, -O0):
<case_buf_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1030 <buf_new@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <buf_str@plt>
mov    %eax,%edi
lea    0xe7f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1040 <buf_puts@plt>
mov    -0x8(%rbp),%rdi
call   1080 <buf_str@plt>
mov    %eax,%edi
lea    0xe41(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1070 <buf_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<case_buf_str>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <buf_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <buf_str@plt>
lea    0xe89(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe67(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <buf_puts@plt>
mov    %rbx,%rdi
call   1080 <buf_str@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <buf_free@plt>

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

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