#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 */
typedef int /*<<< orphan*/ data;

/* Variables and functions */
scalar_t__ buffer_append(int /*<<< orphan*/, int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, int, char *);
void _ensure_buffer_append_copes_with_null_buffer(void) {
  int data = 123;
  if (!(buffer_append(0, sizeof(data), &data) == 0)) {
    printf("%s:%d - test '%s' failed\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/"
           "buffer_tests.c",
           317, "buffer_append( 0, sizeof( data ), &data ) == 0");
    exit(1);
  };
}


x86 assembly (clang, -O0):
<_ensure_buffer_append_copes_with_null_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x7b,-0x4(%rbp)
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x4(%rbp),%rdx
call   1040 <buffer_append@plt>
cmp    $0x0,%rax
je     1182 <_ensure_buffer_append_copes_with_null_buffer+0x52>
lea    0xea0(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x13d,%edx
lea    0xf38(%rip),%rcx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ensure_buffer_append_copes_with_null_buffer>:
push   %rax
movl   $0x7b,0x4(%rsp)
lea    0x4(%rsp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   1040 <buffer_append@plt>
test   %rax,%rax
jne    1151 <_ensure_buffer_append_copes_with_null_buffer+0x21>
pop    %rax
ret
lea    0xea8(%rip),%rdi
lea    0xebb(%rip),%rsi
lea    0xf45(%rip),%rcx
mov    $0x13d,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"%s:%d - test '%s' failed\0A\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/buffer_tests.c\00"
@.str.2 = [47 x i8] c"buffer_append( 0, sizeof( data ), &data ) == 0\00"
define void @_ensure_buffer_append_copes_with_null_buffer() {
%1 = alloca i32
store i32 123, i32* %1
%2 = call i64 @buffer_append(i32 0, i32 4, i32* %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 317, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"%s:%d - test '%s' failed\0A\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/buffer_tests.c\00"
@.str.2 = [47 x i8] c"buffer_append( 0, sizeof( data ), &data ) == 0\00"
define void @_ensure_buffer_append_copes_with_null_buffer() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 123, i32* %1
%3 = call i64 @buffer_append(i32 0, i32 4, i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 317, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
ret void
}