#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 */

/* Variables and functions */
int /*<<< orphan*/ die(char *);
scalar_t__ errno;
void sc_string_init(char *buf, size_t buf_size) {
  errno = 0;
  if (buf == NULL) {
    die("cannot initialize string, buffer is NULL");
  }
  if (buf_size == 0) {
    die("cannot initialize string, buffer is too small");
  }
  buf[0] = '\0';
}


x86 assembly (clang, -O0):
<sc_string_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb9(%rip),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    1145 <sc_string_init+0x35>
lea    0xec0(%rip),%rdi
call   1030 <die@plt>
cmpq   $0x0,-0x10(%rbp)
jne    115c <sc_string_init+0x4c>
lea    0xed2(%rip),%rdi
call   1030 <die@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_string_init>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ebf(%rip),%rax
movq   $0x0,(%rax)
test   %rdi,%rdi
je     113d <sc_string_init+0x2d>
test   %r14,%r14
je     114e <sc_string_init+0x3e>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xebc(%rip),%rdi
call   1030 <die@plt>
test   %r14,%r14
jne    1132 <sc_string_init+0x22>
lea    0xed4(%rip),%rdi
call   1030 <die@plt>
jmp    1132 <sc_string_init+0x22>

LLVM IR (-O0):
@errno = global i64 0
@.str = [41 x i8] c"cannot initialize string, buffer is NULL\00"
@.str.1 = [46 x i8] c"cannot initialize string, buffer is too small\00"
define void @sc_string_init(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* @errno
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = load i64, i64* %4
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @die(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %16
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [41 x i8] c"cannot initialize string, buffer is NULL\00"
@.str.1 = [46 x i8] c"cannot initialize string, buffer is too small\00"
define void @sc_string_init(i8* writeonly %0, i64 %1) {
store i64 0, i64* @errno
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = icmp eq i64 %1, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @die(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
store i8 0, i8* %0
ret void
}