#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*/ check_malloc(int *);
int /*<<< orphan*/ free_null(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, int *, int, int *, int, int *);
int main() {
  int *a = (int *)malloc(sizeof(int) * 3);
  check_malloc(a);
  int *b = a + 1;
  int *c = b + 1;
  *a = 5;
  *b = 10;
  *c = (*a) + (*b);
  printf("a: %d\na adres: %p\nb: %d\nb adres: %p\nsonuc: %d\nc adres: %p\n", *a,
         a, *b, b, *c, c);
  free_null(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <check_malloc@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%rax
mov    (%rax),%r9d
mov    -0x20(%rbp),%rax
lea    0xe36(%rip),%rdi
mov    %rax,(%rsp)
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free_null@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <check_malloc@plt>
lea    0x4(%rbx),%r8
lea    0x8(%rbx),%rax
movabs $0xa00000005,%rcx
mov    %rcx,(%rbx)
movl   $0xf,0x8(%rbx)
mov    %rax,(%rsp)
lea    0xe7f(%rip),%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
mov    $0xf,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <free_null@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [59 x i8] c"a: %d\0Aa adres: %p\0Ab: %d\0Ab adres: %p\0Asonuc: %d\0Ac adres: %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i64 @malloc(i32 12)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = call i32 @check_malloc(i32* %7)
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32* %12, i32** %4
%13 = load i32*, i32** %2
store i32 5, i32* %13
%14 = load i32*, i32** %3
store i32 10, i32* %14
%15 = load i32*, i32** %2
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
%18 = load i32, i32* %17
%19 = add nsw i32 %16, %18
%20 = load i32*, i32** %4
store i32 %19, i32* %20
%21 = load i32*, i32** %2
%22 = load i32, i32* %21
%23 = load i32*, i32** %2
%24 = load i32*, i32** %3
%25 = load i32, i32* %24
%26 = load i32*, i32** %3
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = load i32*, i32** %4
%30 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %22, i32* %23, i32 %25, i32* %26, i32 %28, i32* %29)
%31 = load i32*, i32** %2
%32 = call i32 @free_null(i32* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"a: %d\0Aa adres: %p\0Ab: %d\0Ab adres: %p\0Asonuc: %d\0Ac adres: %p\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 12)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 @check_malloc(i32* %2)
%4 = getelementptr inbounds i32, i32* %2, i64 1
%5 = getelementptr inbounds i32, i32* %2, i64 2
store i32 5, i32* %2
store i32 10, i32* %4
store i32 15, i32* %5
%6 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 5, i32* %2, i32 10, i32* %4, i32 15, i32* %5)
%7 = tail call i32 @free_null(i32* %2)
ret i32 0
}