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

/* Variables and functions */
void *ic_scope_get(struct ic_scope *, char *);
char *ic_symbol_contents(struct ic_symbol *);
int /*<<< orphan*/ puts(char *);
void *ic_scope_get_from_symbol(struct ic_scope *scope, struct ic_symbol *key) {
  char *key_chars = 0;
  if (!scope) {
    puts("ic_scope_get_from_symbol: scope was null");
    return 0;
  }
  if (!key) {
    puts("ic_scope_get_from_symbol: key was null");
    return 0;
  }
  key_chars = ic_symbol_contents(key);
  if (!key_chars) {
    puts("ic_scope_get_from_symbol: call to ic_symbol_contents failed");
    return 0;
  }
  return ic_scope_get(scope, key_chars);
}


x86 assembly (clang, -O0):
<ic_scope_get_from_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116c <ic_scope_get_from_symbol+0x3c>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <ic_scope_get_from_symbol+0xa2>
cmpq   $0x0,-0x18(%rbp)
jne    1190 <ic_scope_get_from_symbol+0x60>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <ic_scope_get_from_symbol+0xa2>
mov    -0x18(%rbp),%rdi
call   1040 <ic_symbol_contents@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c1 <ic_scope_get_from_symbol+0x91>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <ic_scope_get_from_symbol+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ic_scope_get@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_scope_get_from_symbol>:
push   %rbx
test   %rdi,%rdi
je     1157 <ic_scope_get_from_symbol+0x27>
test   %rsi,%rsi
je     1160 <ic_scope_get_from_symbol+0x30>
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <ic_symbol_contents@plt>
test   %rax,%rax
je     1169 <ic_scope_get_from_symbol+0x39>
mov    %rbx,%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1050 <ic_scope_get@plt>
lea    0xea2(%rip),%rdi
jmp    1170 <ic_scope_get_from_symbol+0x40>
lea    0xec2(%rip),%rdi
jmp    1170 <ic_scope_get_from_symbol+0x40>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.ic_scope = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [41 x i8] c"ic_scope_get_from_symbol: scope was null\00"
@.str.1 = [39 x i8] c"ic_scope_get_from_symbol: key was null\00"
@.str.2 = [60 x i8] c"ic_scope_get_from_symbol: call to ic_symbol_contents failed\00"
define i8* @ic_scope_get_from_symbol(%struct.ic_scope* %0, %struct.ic_symbol* %1) {
%3 = alloca i8*
%4 = alloca %struct.ic_scope*
%5 = alloca %struct.ic_symbol*
%6 = alloca i8*
store %struct.ic_scope* %0, %struct.ic_scope** %4
store %struct.ic_symbol* %1, %struct.ic_symbol** %5
store i8* null, i8** %6
%7 = load %struct.ic_scope*, %struct.ic_scope** %4
%8 = icmp ne %struct.ic_scope* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %27
11: ; preds = %2
%12 = load %struct.ic_symbol*, %struct.ic_symbol** %5
%13 = icmp ne %struct.ic_symbol* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %3
br label %27
16: ; preds = %11
%17 = load %struct.ic_symbol*, %struct.ic_symbol** %5
%18 = call i8* @ic_symbol_contents(%struct.ic_symbol* %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %27
23: ; preds = %16
%24 = load %struct.ic_scope*, %struct.ic_scope** %4
%25 = load i8*, i8** %6
%26 = call i8* @ic_scope_get(%struct.ic_scope* %24, i8* %25)
store i8* %26, i8** %3
br label %27
27: ; preds = %23, %21, %14, %9
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
%struct.ic_scope = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [41 x i8] c"ic_scope_get_from_symbol: scope was null\00"
@.str.1 = [39 x i8] c"ic_scope_get_from_symbol: key was null\00"
@.str.2 = [60 x i8] c"ic_scope_get_from_symbol: call to ic_symbol_contents failed\00"
define i8* @ic_scope_get_from_symbol(%struct.ic_scope* %0, %struct.ic_symbol* %1) {
%3 = icmp eq %struct.ic_scope* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %17
6: ; preds = %2
%7 = icmp eq %struct.ic_symbol* %1, null
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %17
10: ; preds = %6
%11 = tail call i8* @ic_symbol_contents(%struct.ic_symbol* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = tail call i8* @ic_scope_get(%struct.ic_scope* %0, i8* %11)
br label %17
17: ; preds = %15, %13, %8, %4
%18 = phi i8* [ %16, %15 ], [ null, %13 ], [ null, %8 ], [ null, %4 ]
ret i8* %18
}