#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_string {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
char *ic_string_contents(struct ic_string *);
int /*<<< orphan*/ puts(char *);
void ic_string_print(FILE *fd, struct ic_string *string) {
  char *con;
  if (!string) {
    puts("ic_string_print: string was null");
    return;
  }
  con = ic_string_contents(string);
  if (!con) {
    puts("ic_string_print: call to ic_string_contents failed");
    return;
  }
  fprintf(fd, "%s", con);
}


x86 assembly (clang, -O0):
<ic_string_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <ic_string_print+0x2c>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
jmp    1199 <ic_string_print+0x69>
mov    -0x10(%rbp),%rdi
call   1040 <ic_string_contents@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1185 <ic_string_print+0x55>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
jmp    1199 <ic_string_print+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_string_print>:
push   %rbx
test   %rsi,%rsi
je     1152 <ic_string_print+0x22>
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <ic_string_contents@plt>
test   %rax,%rax
je     115f <ic_string_print+0x2f>
mov    %rax,%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <fputs@plt>
lea    0xea7(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xebb(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.ic_string = type { i32 }
@.str = [33 x i8] c"ic_string_print: string was null\00"
@.str.1 = [51 x i8] c"ic_string_print: call to ic_string_contents failed\00"
@.str.2 = [3 x i8] c"%s\00"
define void @ic_string_print(i32* %0, %struct.ic_string* %1) {
%3 = alloca i32*
%4 = alloca %struct.ic_string*
%5 = alloca i8*
store i32* %0, i32** %3
store %struct.ic_string* %1, %struct.ic_string** %4
%6 = load %struct.ic_string*, %struct.ic_string** %4
%7 = icmp ne %struct.ic_string* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %21
10: ; preds = %2
%11 = load %struct.ic_string*, %struct.ic_string** %4
%12 = call i8* @ic_string_contents(%struct.ic_string* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = load i32*, i32** %3
%19 = load i8*, i8** %5
%20 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %15, %8
ret void
}

LLVM IR (-O2):
%struct.ic_string = type { i32 }
@.str = [33 x i8] c"ic_string_print: string was null\00"
@.str.1 = [51 x i8] c"ic_string_print: call to ic_string_contents failed\00"
define void @ic_string_print(i32* nocapture %0, %struct.ic_string* %1) {
%3 = icmp eq %struct.ic_string* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %13
6: ; preds = %2
%7 = tail call i8* @ic_string_contents(%struct.ic_string* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %6
%12 = tail call i32 @fputs(i8* %7, i32* %0)
br label %13
13: ; preds = %11, %9, %4
ret void
}