#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);
int main() {
  struct {
    char a;
    int b;
    double c;
  } pad;
  char *ptr1;
  int *ptr2;
  pad.b = 123456;
  ptr1 = &(pad.a);
  ptr1++;
  ptr2 = (int *)ptr1;
  printf("pad.b"
         " ==> %d\n",
         pad.b);
  printf("*ptr2"
         " ==> %d\n",
         *ptr2);
  ptr1 += 3;
  ptr2 = (int *)ptr1;
  printf("*ptr2"
         " ==> %d\n",
         *ptr2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e240,-0x14(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1e240,0xb(%rsp)
lea    0xedc(%rip),%rdi
mov    $0x1e240,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xed5(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1e240,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"pad.b ==> %d\0A\00"
@.str.1 = [14 x i8] c"*ptr2 ==> %d\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 3
%4 = bitcast i8* %3 to i32*
store i32 123456, i32* %4
%5 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 123456)
%6 = bitcast [7 x i8]* %1 to i32*
%7 = load i32, i32* %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 123456)
ret i32 0
}