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

/* Variables and functions */
int /*<<< orphan*/ ic_type_ref_init(struct ic_type_ref *);
int /*<<< orphan*/ ic_type_ref_set_symbol(struct ic_type_ref *, char *,
                                          unsigned int);
int /*<<< orphan*/ puts(char *);
unsigned int ic_type_ref_symbol_init(struct ic_type_ref *type, char *type_str,
                                     unsigned int type_len) {
  if (!type) {
    puts("ic_type_ref_symbol_init: type_str was null");
    return 0;
  }
  if (!type_str) {
    puts("ic_type_ref_symbol_init: type_str was null");
    return 0;
  }
  if (!ic_type_ref_init(type)) {
    puts("ic_type_ref_symbol_init: call to ic_type_init failed");
    return 0;
  }
  if (!ic_type_ref_set_symbol(type, type_str, type_len)) {
    puts("ic_type_ref_symbol_init: call to ic_type_set_symbol failed");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ic_type_ref_symbol_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <ic_type_ref_symbol_init+0x36>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ic_type_ref_symbol_init+0xbb>
cmpq   $0x0,-0x18(%rbp)
jne    1189 <ic_type_ref_symbol_init+0x59>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ic_type_ref_symbol_init+0xbb>
mov    -0x10(%rbp),%rdi
call   1050 <ic_type_ref_init@plt>
cmp    $0x0,%eax
jne    11b3 <ic_type_ref_symbol_init+0x83>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ic_type_ref_symbol_init+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <ic_type_ref_set_symbol@plt>
cmp    $0x0,%eax
jne    11e4 <ic_type_ref_symbol_init+0xb4>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ic_type_ref_symbol_init+0xbb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_type_ref_symbol_init>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
lea    0xec2(%rip),%rdi
test   %rbp,%rbp
je     1183 <ic_type_ref_symbol_init+0x53>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1183 <ic_type_ref_symbol_init+0x53>
mov    %edx,%r14d
mov    %rbp,%rdi
call   1050 <ic_type_ref_init@plt>
test   %eax,%eax
je     117c <ic_type_ref_symbol_init+0x4c>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1040 <ic_type_ref_set_symbol@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    118a <ic_type_ref_symbol_init+0x5a>
lea    0xee6(%rip),%rdi
jmp    1183 <ic_type_ref_symbol_init+0x53>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ic_type_ref = type { i32 }
@.str = [43 x i8] c"ic_type_ref_symbol_init: type_str was null\00"
@.str.1 = [53 x i8] c"ic_type_ref_symbol_init: call to ic_type_init failed\00"
@.str.2 = [59 x i8] c"ic_type_ref_symbol_init: call to ic_type_set_symbol failed\00"
define i32 @ic_type_ref_symbol_init(%struct.ic_type_ref* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.ic_type_ref*
%6 = alloca i8*
%7 = alloca i32
store %struct.ic_type_ref* %0, %struct.ic_type_ref** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load %struct.ic_type_ref*, %struct.ic_type_ref** %5
%9 = icmp ne %struct.ic_type_ref* %8, null
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %32
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %32
17: ; preds = %12
%18 = load %struct.ic_type_ref*, %struct.ic_type_ref** %5
%19 = call i32 @ic_type_ref_init(%struct.ic_type_ref* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %32
23: ; preds = %17
%24 = load %struct.ic_type_ref*, %struct.ic_type_ref** %5
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = call i32 @ic_type_ref_set_symbol(%struct.ic_type_ref* %24, i8* %25, i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = call i32 @puts(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %32
31: ; preds = %23
store i32 1, i32* %4
br label %32
32: ; preds = %31, %29, %21, %15, %10
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
%struct.ic_type_ref = type { i32 }
@.str = [43 x i8] c"ic_type_ref_symbol_init: type_str was null\00"
@.str.1 = [53 x i8] c"ic_type_ref_symbol_init: call to ic_type_init failed\00"
@.str.2 = [59 x i8] c"ic_type_ref_symbol_init: call to ic_type_set_symbol failed\00"
define i32 @ic_type_ref_symbol_init(%struct.ic_type_ref* %0, i8* %1, i32 %2) {
%4 = icmp eq %struct.ic_type_ref* %0, null
%5 = icmp eq i8* %1, null
%6 = or i1 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = tail call i32 @ic_type_ref_init(%struct.ic_type_ref* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @ic_type_ref_set_symbol(%struct.ic_type_ref* %0, i8* %1, i32 %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10, %7, %3
%14 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), %10 ]
%15 = tail call i32 @puts(i8* dereferenceable(1) %14)
br label %16
16: ; preds = %13, %10
%17 = phi i32 [ 1, %10 ], [ 0, %13 ]
ret i32 %17
}