#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_symbol {
  int dummy;
};
struct ic_labeller {
  int dummy;
};

/* Variables and functions */
char *ic_labeller_generate(struct ic_labeller *);
struct ic_symbol *ic_symbol_new(char *, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strlen(char *);
struct ic_symbol *ic_labeller_generate_symbol(struct ic_labeller *labeller) {
  struct ic_symbol *sym = 0;
  char *str = 0;
  if (!labeller) {
    puts("ic_labeller_generate_symbol: labeller was null");
    return 0;
  }
  str = ic_labeller_generate(labeller);
  if (!str) {
    puts("ic_labeller_generate_symbol: call to ic_labeller_generate failed");
    return 0;
  }
  sym = ic_symbol_new(str, strlen(str));
  if (!sym) {
    puts("ic_labeller_generate_symbol: call to ic_symbol_new failed");
    return 0;
  }
  return sym;
}


x86 assembly (clang, -O0):
<ic_labeller_generate_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1180 <ic_labeller_generate_symbol+0x40>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11fd <ic_labeller_generate_symbol+0xbd>
mov    -0x10(%rbp),%rdi
call   1050 <ic_labeller_generate@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b1 <ic_labeller_generate_symbol+0x71>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11fd <ic_labeller_generate_symbol+0xbd>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1060 <ic_symbol_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f5 <ic_labeller_generate_symbol+0xb5>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11fd <ic_labeller_generate_symbol+0xbd>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_labeller_generate_symbol>:
push   %rbx
test   %rdi,%rdi
je     116c <ic_labeller_generate_symbol+0x2c>
call   1050 <ic_labeller_generate@plt>
test   %rax,%rax
je     1175 <ic_labeller_generate_symbol+0x35>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <ic_symbol_new@plt>
test   %rax,%rax
je     117e <ic_labeller_generate_symbol+0x3e>
pop    %rbx
ret
lea    0xe8d(%rip),%rdi
jmp    1185 <ic_labeller_generate_symbol+0x45>
lea    0xeb3(%rip),%rdi
jmp    1185 <ic_labeller_generate_symbol+0x45>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.ic_symbol = type { i32 }
%struct.ic_labeller = type { i32 }
@.str = [47 x i8] c"ic_labeller_generate_symbol: labeller was null\00"
@.str.1 = [65 x i8] c"ic_labeller_generate_symbol: call to ic_labeller_generate failed\00"
@.str.2 = [58 x i8] c"ic_labeller_generate_symbol: call to ic_symbol_new failed\00"
define %struct.ic_symbol* @ic_labeller_generate_symbol(%struct.ic_labeller* %0) {
%2 = alloca %struct.ic_symbol*
%3 = alloca %struct.ic_labeller*
%4 = alloca %struct.ic_symbol*
%5 = alloca i8*
store %struct.ic_labeller* %0, %struct.ic_labeller** %3
store %struct.ic_symbol* null, %struct.ic_symbol** %4
store i8* null, i8** %5
%6 = load %struct.ic_labeller*, %struct.ic_labeller** %3
%7 = icmp ne %struct.ic_labeller* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store %struct.ic_symbol* null, %struct.ic_symbol** %2
br label %28
10: ; preds = %1
%11 = load %struct.ic_labeller*, %struct.ic_labeller** %3
%12 = call i8* @ic_labeller_generate(%struct.ic_labeller* %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 ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
store %struct.ic_symbol* null, %struct.ic_symbol** %2
br label %28
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = call %struct.ic_symbol* @ic_symbol_new(i8* %18, i32 %20)
store %struct.ic_symbol* %21, %struct.ic_symbol** %4
%22 = load %struct.ic_symbol*, %struct.ic_symbol** %4
%23 = icmp ne %struct.ic_symbol* %22, null
br i1 %23, label %26, label %24
24: ; preds = %17
%25 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
store %struct.ic_symbol* null, %struct.ic_symbol** %2
br label %28
26: ; preds = %17
%27 = load %struct.ic_symbol*, %struct.ic_symbol** %4
store %struct.ic_symbol* %27, %struct.ic_symbol** %2
br label %28
28: ; preds = %26, %24, %15, %8
%29 = load %struct.ic_symbol*, %struct.ic_symbol** %2
ret %struct.ic_symbol* %29
}

LLVM IR (-O2):
%struct.ic_symbol = type { i32 }
%struct.ic_labeller = type { i32 }
@.str = [47 x i8] c"ic_labeller_generate_symbol: labeller was null\00"
@.str.1 = [65 x i8] c"ic_labeller_generate_symbol: call to ic_labeller_generate failed\00"
@.str.2 = [58 x i8] c"ic_labeller_generate_symbol: call to ic_symbol_new failed\00"
define %struct.ic_symbol* @ic_labeller_generate_symbol(%struct.ic_labeller* %0) {
%2 = icmp eq %struct.ic_labeller* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = tail call i8* @ic_labeller_generate(%struct.ic_labeller* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %4)
%8 = tail call %struct.ic_symbol* @ic_symbol_new(i8* %4, i32 %7)
%9 = icmp eq %struct.ic_symbol* %8, null
br i1 %9, label %10, label %13
10: ; preds = %6, %3, %1
%11 = phi i8* [ getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), %6 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %6
%14 = phi %struct.ic_symbol* [ %8, %6 ], [ null, %10 ]
ret %struct.ic_symbol* %14
}