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

/* Variables and functions */
scalar_t__ ic_kludge_get_decl_type_from_symbol(struct ic_kludge *,
                                               struct ic_symbol *);
scalar_t__ ic_kludge_get_fdecl_from_symbol(struct ic_kludge *,
                                           struct ic_symbol *);
scalar_t__ ic_scope_get_from_symbol(struct ic_scope *, struct ic_symbol *);
int /*<<< orphan*/ puts(char *);
int ic_kludge_identifier_exists_symbol(struct ic_kludge *kludge,
                                       struct ic_scope *scope,
                                       struct ic_symbol *identifier) {
  if (!kludge) {
    puts("ic_kludge_identifier_exists_symbol: kludge was null");
    return -1;
  }
  if (!identifier) {
    puts("ic_kludge_identifier_exists_symbol: identifier was null");
    return -1;
  }
  if (scope) {
    if (ic_scope_get_from_symbol(scope, identifier)) {
      return 1;
    }
  }
  if (ic_kludge_get_decl_type_from_symbol(kludge, identifier)) {
    return 1;
  }
  if (ic_kludge_get_fdecl_from_symbol(kludge, identifier)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ic_kludge_identifier_exists_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <ic_kludge_identifier_exists_symbol+0x37>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121a <ic_kludge_identifier_exists_symbol+0xda>
cmpq   $0x0,-0x20(%rbp)
jne    119a <ic_kludge_identifier_exists_symbol+0x5a>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121a <ic_kludge_identifier_exists_symbol+0xda>
cmpq   $0x0,-0x18(%rbp)
je     11cd <ic_kludge_identifier_exists_symbol+0x8d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ic_scope_get_from_symbol@plt>
cmp    $0x0,%rax
je     11c8 <ic_kludge_identifier_exists_symbol+0x88>
movl   $0x1,-0x4(%rbp)
jmp    121a <ic_kludge_identifier_exists_symbol+0xda>
jmp    11cd <ic_kludge_identifier_exists_symbol+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <ic_kludge_get_decl_type_from_symbol@plt>
cmp    $0x0,%rax
je     11f0 <ic_kludge_identifier_exists_symbol+0xb0>
movl   $0x1,-0x4(%rbp)
jmp    121a <ic_kludge_identifier_exists_symbol+0xda>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <ic_kludge_get_fdecl_from_symbol@plt>
cmp    $0x0,%rax
je     1213 <ic_kludge_identifier_exists_symbol+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    121a <ic_kludge_identifier_exists_symbol+0xda>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_kludge_identifier_exists_symbol>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11a1 <ic_kludge_identifier_exists_symbol+0x61>
mov    %rdx,%r14
test   %rdx,%rdx
je     11aa <ic_kludge_identifier_exists_symbol+0x6a>
mov    %rdi,%rbx
test   %rsi,%rsi
je     1171 <ic_kludge_identifier_exists_symbol+0x31>
mov    %rsi,%rdi
mov    %r14,%rsi
call   1050 <ic_scope_get_from_symbol@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11bb <ic_kludge_identifier_exists_symbol+0x7b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <ic_kludge_get_decl_type_from_symbol@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11bb <ic_kludge_identifier_exists_symbol+0x7b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <ic_kludge_get_fdecl_from_symbol@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    11bb <ic_kludge_identifier_exists_symbol+0x7b>
lea    0xe58(%rip),%rdi
jmp    11b1 <ic_kludge_identifier_exists_symbol+0x71>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ic_kludge = type { i32 }
%struct.ic_scope = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [52 x i8] c"ic_kludge_identifier_exists_symbol: kludge was null\00"
@.str.1 = [56 x i8] c"ic_kludge_identifier_exists_symbol: identifier was null\00"
define i32 @ic_kludge_identifier_exists_symbol(%struct.ic_kludge* %0, %struct.ic_scope* %1, %struct.ic_symbol* %2) {
%4 = alloca i32
%5 = alloca %struct.ic_kludge*
%6 = alloca %struct.ic_scope*
%7 = alloca %struct.ic_symbol*
store %struct.ic_kludge* %0, %struct.ic_kludge** %5
store %struct.ic_scope* %1, %struct.ic_scope** %6
store %struct.ic_symbol* %2, %struct.ic_symbol** %7
%8 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%9 = icmp ne %struct.ic_kludge* %8, null
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %40
12: ; preds = %3
%13 = load %struct.ic_symbol*, %struct.ic_symbol** %7
%14 = icmp ne %struct.ic_symbol* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %40
17: ; preds = %12
%18 = load %struct.ic_scope*, %struct.ic_scope** %6
%19 = icmp ne %struct.ic_scope* %18, null
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load %struct.ic_scope*, %struct.ic_scope** %6
%22 = load %struct.ic_symbol*, %struct.ic_symbol** %7
%23 = call i64 @ic_scope_get_from_symbol(%struct.ic_scope* %21, %struct.ic_symbol* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %4
br label %40
26: ; preds = %20
br label %27
27: ; preds = %26, %17
%28 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%29 = load %struct.ic_symbol*, %struct.ic_symbol** %7
%30 = call i64 @ic_kludge_get_decl_type_from_symbol(%struct.ic_kludge* %28, %struct.ic_symbol* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 1, i32* %4
br label %40
33: ; preds = %27
%34 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%35 = load %struct.ic_symbol*, %struct.ic_symbol** %7
%36 = call i64 @ic_kludge_get_fdecl_from_symbol(%struct.ic_kludge* %34, %struct.ic_symbol* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 1, i32* %4
br label %40
39: ; preds = %33
store i32 0, i32* %4
br label %40
40: ; preds = %39, %38, %32, %25, %15, %10
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
%struct.ic_kludge = type { i32 }
%struct.ic_scope = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [52 x i8] c"ic_kludge_identifier_exists_symbol: kludge was null\00"
@.str.1 = [56 x i8] c"ic_kludge_identifier_exists_symbol: identifier was null\00"
define i32 @ic_kludge_identifier_exists_symbol(%struct.ic_kludge* %0, %struct.ic_scope* %1, %struct.ic_symbol* %2) {
%4 = icmp eq %struct.ic_kludge* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %3
%8 = icmp eq %struct.ic_symbol* %2, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
br label %23
11: ; preds = %7
%12 = icmp eq %struct.ic_scope* %1, null
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = tail call i64 @ic_scope_get_from_symbol(%struct.ic_scope* %1, %struct.ic_symbol* %2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13, %11
%17 = tail call i64 @ic_kludge_get_decl_type_from_symbol(%struct.ic_kludge* %0, %struct.ic_symbol* %2)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = tail call i64 @ic_kludge_get_fdecl_from_symbol(%struct.ic_kludge* %0, %struct.ic_symbol* %2)
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %19, %16, %13, %9, %5
%24 = phi i32 [ -1, %9 ], [ -1, %5 ], [ 1, %13 ], [ 1, %16 ], [ %22, %19 ]
ret i32 %24
}