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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
struct ic_symbol *ic_decl_type_union_mangled_name(struct ic_decl_type_union *);
char *ic_symbol_contents(struct ic_symbol *);
int /*<<< orphan*/ puts(char *);
unsigned int ic_b2c_compile_type_union_header(
    struct ic_kludge *kludge, struct ic_decl_type_union *tdecl_union, FILE *f) {
  struct ic_symbol *mangled_type_name = 0;
  char *mangled_type_name_ch = 0;
  if (!kludge) {
    puts("ic_b2c_compile_type_union_header: kludge was null");
    return 0;
  }
  if (!tdecl_union) {
    puts("ic_b2c_compile_type_union_header: tdecl_union was null");
    return 0;
  }
  if (!f) {
    puts("ic_b2c_compile_type_union_header: f was null");
    return 0;
  }
  mangled_type_name = ic_decl_type_union_mangled_name(tdecl_union);
  if (!mangled_type_name) {
    puts("ic_b2c_compile_type_union_header: call to "
         "ic_decl_type_union_mangled_name failed");
    return 0;
  }
  mangled_type_name_ch = ic_symbol_contents(mangled_type_name);
  if (!mangled_type_name_ch) {
    puts("ic_b2c_compile_type_union_header: call to ic_symbol_contents failed");
    return 0;
  }
  fprintf(f, "enum %s_tag;\n", mangled_type_name_ch);
  fprintf(f, "typedef struct %s * %s;\n", mangled_type_name_ch,
          mangled_type_name_ch);
  return 1;
}


x86 assembly (clang, -O0):
<ic_b2c_compile_type_union_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1187 <ic_b2c_compile_type_union_header+0x47>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ic_b2c_compile_type_union_header+0x124>
cmpq   $0x0,-0x18(%rbp)
jne    11aa <ic_b2c_compile_type_union_header+0x6a>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ic_b2c_compile_type_union_header+0x124>
cmpq   $0x0,-0x20(%rbp)
jne    11cd <ic_b2c_compile_type_union_header+0x8d>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ic_b2c_compile_type_union_header+0x124>
mov    -0x18(%rbp),%rdi
call   1060 <ic_decl_type_union_mangled_name@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11fd <ic_b2c_compile_type_union_header+0xbd>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ic_b2c_compile_type_union_header+0x124>
mov    -0x28(%rbp),%rdi
call   1040 <ic_symbol_contents@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    122d <ic_b2c_compile_type_union_header+0xed>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ic_b2c_compile_type_union_header+0x124>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xeef(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xee3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ic_b2c_compile_type_union_header>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11a5 <ic_b2c_compile_type_union_header+0x65>
test   %rsi,%rsi
je     11ae <ic_b2c_compile_type_union_header+0x6e>
mov    %rdx,%rbx
test   %rdx,%rdx
je     11b7 <ic_b2c_compile_type_union_header+0x77>
mov    %rsi,%rdi
call   1060 <ic_decl_type_union_mangled_name@plt>
test   %rax,%rax
je     11c0 <ic_b2c_compile_type_union_header+0x80>
mov    %rax,%rdi
call   1040 <ic_symbol_contents@plt>
test   %rax,%rax
je     11c9 <ic_b2c_compile_type_union_header+0x89>
mov    %rax,%r14
lea    0xfb1(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xfab(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11d7 <ic_b2c_compile_type_union_header+0x97>
lea    0xe54(%rip),%rdi
jmp    11d0 <ic_b2c_compile_type_union_header+0x90>
lea    0xe7d(%rip),%rdi
jmp    11d0 <ic_b2c_compile_type_union_header+0x90>
lea    0xeab(%rip),%rdi
jmp    11d0 <ic_b2c_compile_type_union_header+0x90>
lea    0xecf(%rip),%rdi
jmp    11d0 <ic_b2c_compile_type_union_header+0x90>
lea    0xf17(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ic_kludge = type { i32 }
%struct.ic_decl_type_union = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [50 x i8] c"ic_b2c_compile_type_union_header: kludge was null\00"
@.str.1 = [55 x i8] c"ic_b2c_compile_type_union_header: tdecl_union was null\00"
@.str.2 = [45 x i8] c"ic_b2c_compile_type_union_header: f was null\00"
@.str.3 = [81 x i8] c"ic_b2c_compile_type_union_header: call to ic_decl_type_union_mangled_name failed\00"
@.str.4 = [68 x i8] c"ic_b2c_compile_type_union_header: call to ic_symbol_contents failed\00"
@.str.5 = [14 x i8] c"enum %s_tag;\0A\00"
@.str.6 = [25 x i8] c"typedef struct %s * %s;\0A\00"
define i32 @ic_b2c_compile_type_union_header(%struct.ic_kludge* %0, %struct.ic_decl_type_union* %1, i32* %2) {
%4 = alloca i32
%5 = alloca %struct.ic_kludge*
%6 = alloca %struct.ic_decl_type_union*
%7 = alloca i32*
%8 = alloca %struct.ic_symbol*
%9 = alloca i8*
store %struct.ic_kludge* %0, %struct.ic_kludge** %5
store %struct.ic_decl_type_union* %1, %struct.ic_decl_type_union** %6
store i32* %2, i32** %7
store %struct.ic_symbol* null, %struct.ic_symbol** %8
store i8* null, i8** %9
%10 = load %struct.ic_kludge*, %struct.ic_kludge** %5
%11 = icmp ne %struct.ic_kludge* %10, null
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %46
14: ; preds = %3
%15 = load %struct.ic_decl_type_union*, %struct.ic_decl_type_union** %6
%16 = icmp ne %struct.ic_decl_type_union* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 @puts(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %46
19: ; preds = %14
%20 = load i32*, i32** %7
%21 = icmp ne i32* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %46
24: ; preds = %19
%25 = load %struct.ic_decl_type_union*, %struct.ic_decl_type_union** %6
%26 = call %struct.ic_symbol* @ic_decl_type_union_mangled_name(%struct.ic_decl_type_union* %25)
store %struct.ic_symbol* %26, %struct.ic_symbol** %8
%27 = load %struct.ic_symbol*, %struct.ic_symbol** %8
%28 = icmp ne %struct.ic_symbol* %27, null
br i1 %28, label %31, label %29
29: ; preds = %24
%30 = call i32 @puts(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %46
31: ; preds = %24
%32 = load %struct.ic_symbol*, %struct.ic_symbol** %8
%33 = call i8* @ic_symbol_contents(%struct.ic_symbol* %32)
store i8* %33, i8** %9
%34 = load i8*, i8** %9
%35 = icmp ne i8* %34, null
br i1 %35, label %38, label %36
36: ; preds = %31
%37 = call i32 @puts(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %46
38: ; preds = %31
%39 = load i32*, i32** %7
%40 = load i8*, i8** %9
%41 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i32*, i32** %7
%43 = load i8*, i8** %9
%44 = load i8*, i8** %9
%45 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %43, i8* %44)
store i32 1, i32* %4
br label %46
46: ; preds = %38, %36, %29, %22, %17, %12
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
%struct.ic_kludge = type { i32 }
%struct.ic_decl_type_union = type { i32 }
%struct.ic_symbol = type { i32 }
@.str = [50 x i8] c"ic_b2c_compile_type_union_header: kludge was null\00"
@.str.1 = [55 x i8] c"ic_b2c_compile_type_union_header: tdecl_union was null\00"
@.str.2 = [45 x i8] c"ic_b2c_compile_type_union_header: f was null\00"
@.str.3 = [81 x i8] c"ic_b2c_compile_type_union_header: call to ic_decl_type_union_mangled_name failed\00"
@.str.4 = [68 x i8] c"ic_b2c_compile_type_union_header: call to ic_symbol_contents failed\00"
@.str.5 = [14 x i8] c"enum %s_tag;\0A\00"
@.str.6 = [25 x i8] c"typedef struct %s * %s;\0A\00"
define i32 @ic_b2c_compile_type_union_header(%struct.ic_kludge* readnone %0, %struct.ic_decl_type_union* %1, i32* %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 ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %28
7: ; preds = %3
%8 = icmp eq %struct.ic_decl_type_union* %1, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
br label %28
11: ; preds = %7
%12 = icmp eq i32* %2, null
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %28
15: ; preds = %11
%16 = tail call %struct.ic_symbol* @ic_decl_type_union_mangled_name(%struct.ic_decl_type_union* %1)
%17 = icmp eq %struct.ic_symbol* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.3, i64 0, i64 0))
br label %28
20: ; preds = %15
%21 = tail call i8* @ic_symbol_contents(%struct.ic_symbol* %16)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0))
br label %28
25: ; preds = %20
%26 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%27 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %21, i8* %21)
br label %28
28: ; preds = %25, %23, %18, %13, %9, %5
%29 = phi i32 [ 1, %25 ], [ 0, %23 ], [ 0, %18 ], [ 0, %13 ], [ 0, %9 ], [ 0, %5 ]
ret i32 %29
}