#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
main() {
  struct a {
    int type;
  };
  struct b {
    int type;
    int e;
  };
  struct c {
    int type;
    float f;
  };
  union {
    struct a n;
    struct b ni;
    struct c nf;
  } all;
  all.ni.type = 1;
  all.nf.f = 10;
  all.ni.e = 1;
  if (all.nf.type == 1)
    printf("float value =%2.1f", all.nf.f);
  if (all.ni.type == 1)
    printf("\ninteger value=%d", all.ni.e);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movss  0xed2(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1155 <main+0x45>
cvttss2si -0xc(%rbp),%esi
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x10(%rbp)
jne    116e <main+0x5e>
mov    -0xc(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.anon = type { %struct.b }
%struct.b = type { i32, i32 }
%struct.c = type { i32, float }
@.str = [19 x i8] c"float value =%2.1f\00"
@.str.1 = [18 x i8] c"\0Ainteger value=%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %union.anon
store i32 0, i32* %1
%3 = bitcast %union.anon* %2 to %struct.b*
%4 = getelementptr inbounds %struct.b, %struct.b* %3, i32 0, i32 0
store i32 1, i32* %4
%5 = bitcast %union.anon* %2 to %struct.c*
%6 = getelementptr inbounds %struct.c, %struct.c* %5, i32 0, i32 1
store float 1.000000e+01, float* %6
%7 = bitcast %union.anon* %2 to %struct.b*
%8 = getelementptr inbounds %struct.b, %struct.b* %7, i32 0, i32 1
store i32 1, i32* %8
%9 = bitcast %union.anon* %2 to %struct.c*
%10 = getelementptr inbounds %struct.c, %struct.c* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = bitcast %union.anon* %2 to %struct.c*
%15 = getelementptr inbounds %struct.c, %struct.c* %14, i32 0, i32 1
%16 = load float, float* %15
%17 = fptosi float %16 to i32
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13, %0
%20 = bitcast %union.anon* %2 to %struct.b*
%21 = getelementptr inbounds %struct.b, %struct.b* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = bitcast %union.anon* %2 to %struct.b*
%26 = getelementptr inbounds %struct.b, %struct.b* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24, %19
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [19 x i8] c"float value =%2.1f\00"
@.str.1 = [18 x i8] c"\0Ainteger value=%d\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret i32 0
}