#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 */
typedef int /*<<< orphan*/ u;

/* Variables and functions */
int /*<<< orphan*/ memset(struct uni *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int, int);
void test_9(void) {
  union uni {
    struct {
      int n3;
    } s1;
    struct {
      int n4;
      int n5;
    } s2;
  };
  union uni u;
  int *p = &u.s2.n4;
  memset(&u, 0, sizeof(u));
  u.s1.n3 = 1;
  u.s2.n4 = 2;
  u.s2.n5 = 3;
  *p = 4;
  printf("%d %d %d\n", u.s1.n3, u.s2.n4, u.s2.n5);
}


x86 assembly (clang, -O0):
<test_9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x3,-0x4(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_9>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movabs $0x300000004,%rax
mov    %rax,(%rsp)
lea    0xebb(%rip),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
mov    $0x3,%ecx
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
%union.uni = type { %struct.anon.0 }
%struct.anon.0 = type { i32, i32 }
%struct.uni = type opaque
%struct.anon = type { i32 }
@.str = [10 x i8] c"%d %d %d\0A\00"
define void @test_9() {
%1 = alloca %union.uni
%2 = alloca i32*
%3 = bitcast %union.uni* %1 to %struct.anon.0*
%4 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %3, i32 0, i32 0
store i32* %4, i32** %2
%5 = bitcast %union.uni* %1 to %struct.uni*
%6 = call i32 @memset(%struct.uni* %5, i32 0, i32 8)
%7 = bitcast %union.uni* %1 to %struct.anon*
%8 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 0
store i32 1, i32* %8
%9 = bitcast %union.uni* %1 to %struct.anon.0*
%10 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %9, i32 0, i32 0
store i32 2, i32* %10
%11 = bitcast %union.uni* %1 to %struct.anon.0*
%12 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %11, i32 0, i32 1
store i32 3, i32* %12
%13 = load i32*, i32** %2
store i32 4, i32* %13
%14 = bitcast %union.uni* %1 to %struct.anon*
%15 = getelementptr inbounds %struct.anon, %struct.anon* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = bitcast %union.uni* %1 to %struct.anon.0*
%18 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = bitcast %union.uni* %1 to %struct.anon.0*
%21 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19, i32 %22)
ret void
}

LLVM IR (-O2):
%union.uni = type { %struct.anon.0 }
%struct.anon.0 = type { i32, i32 }
%struct.uni = type opaque
@.str = [10 x i8] c"%d %d %d\0A\00"
define void @test_9() {
%1 = alloca %union.uni
%2 = bitcast %union.uni* %1 to i8*
%3 = getelementptr inbounds %union.uni, %union.uni* %1, i64 0, i32 0, i32 0
%4 = bitcast %union.uni* %1 to %struct.uni*
%5 = call i32 @memset(%struct.uni* %4, i32 0, i32 8)
%6 = getelementptr inbounds %union.uni, %union.uni* %1, i64 0, i32 0, i32 1
store i32 3, i32* %6
store i32 4, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 4, i32 4, i32 3)
ret void
}