#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() {
  int var1 = 5;
  char var2 = 'a';
  int *ptr1 = &var1;
  char *ptr2 = &var2;
  *ptr2 = 'b';
  printf("var1 tem o endereco %p e o valor %d\n", ptr1, *ptr1);
  printf("var2 tem o endereco %p e o valor %d\n", ptr2, *ptr2);
  printf("Sizeof:\n\tchar: %zu\n\tchar *: %zu\n\tint: %zu\n\tint *: %zu\n",
         sizeof(char), sizeof(char *), sizeof(int), sizeof(int *));
  printf("ptr1 e ptr1+1: %p %p\nptr2 e ptr2+1: %p %p\n", ptr1, ptr1 + 1, ptr2,
         ptr2 + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movb   $0x61,-0x9(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x62,(%rax)
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsbl (%rax),%edx
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    $0x1,%esi
mov    $0x8,%r8d
mov    $0x4,%ecx
mov    %r8,%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x4,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
add    $0x1,%r8
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x5,0x4(%rsp)
movb   $0x62,0x3(%rsp)
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%r14
mov    %r14,%rsi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x62,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0x8,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%r8
lea    0xef6(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"var1 tem o endereco %p e o valor %d\0A\00"
@.str.1 = [37 x i8] c"var2 tem o endereco %p e o valor %d\0A\00"
@.str.2 = [55 x i8] c"Sizeof:\0A\09char: %zu\0A\09char *: %zu\0A\09int: %zu\0A\09int *: %zu\0A\00"
@.str.3 = [43 x i8] c"ptr1 e ptr1+1: %p %p\0Aptr2 e ptr2+1: %p %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i8*
store i32 0, i32* %1
store i32 5, i32* %2
store i8 97, i8* %3
store i32* %2, i32** %4
store i8* %3, i8** %5
%6 = load i8*, i8** %5
store i8 98, i8* %6
%7 = load i32*, i32** %4
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32* %7, i32 %9)
%11 = load i8*, i8** %5
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i64 1, i64 8, i64 4, i64 8)
%17 = load i32*, i32** %4
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = load i8*, i8** %5
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32* %17, i32* %19, i8* %20, i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"var1 tem o endereco %p e o valor %d\0A\00"
@.str.1 = [37 x i8] c"var2 tem o endereco %p e o valor %d\0A\00"
@.str.2 = [55 x i8] c"Sizeof:\0A\09char: %zu\0A\09char *: %zu\0A\09int: %zu\0A\09int *: %zu\0A\00"
@.str.3 = [43 x i8] c"ptr1 e ptr1+1: %p %p\0Aptr2 e ptr2+1: %p %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i32 5, i32* %1
store i8 98, i8* %2
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32* %1, i32 5)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 98)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i64 1, i64 8, i64 4, i64 8)
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = getelementptr inbounds i8, i8* %2, i64 1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %7, i8* %2, i8* %8)
ret i32 0
}