#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*/ display(int *, int, char *);
int *malloc(int);
int main() {
  int *int_ptr = malloc(sizeof(int));
  int *origin = int_ptr;
  *int_ptr = 0;
  display(origin, 1, "original");
  int_ptr++;
  display(origin, 2, "pointer++");
  *int_ptr++;
  display(origin, 3, "*pointer++");
  (*int_ptr)++;
  display(origin, 3, "(*pointer)++");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
lea    0xea1(%rip),%rdx
call   1030 <display@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
lea    0xe8a(%rip),%rdx
call   1030 <display@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
lea    0xe68(%rip),%rdx
call   1030 <display@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
lea    0xe53(%rip),%rdx
call   1030 <display@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movl   $0x0,(%rax)
lea    0xec5(%rip),%rdx
mov    %rax,%rdi
mov    $0x1,%esi
call   1030 <display@plt>
lea    0xebb(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <display@plt>
lea    0xea6(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <display@plt>
addl   $0x1,0x8(%rbx)
lea    0xe99(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <display@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"original\00"
@.str.1 = [10 x i8] c"pointer++\00"
@.str.2 = [11 x i8] c"*pointer++\00"
@.str.3 = [13 x i8] c"(*pointer)++\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @malloc(i32 4)
store i32* %4, i32** %2
%5 = load i32*, i32** %2
store i32* %5, i32** %3
%6 = load i32*, i32** %2
store i32 0, i32* %6
%7 = load i32*, i32** %3
%8 = call i32 @display(i32* %7, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i32 1
store i32* %10, i32** %2
%11 = load i32*, i32** %3
%12 = call i32 @display(i32* %11, i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %2
%15 = load i32, i32* %13
%16 = load i32*, i32** %3
%17 = call i32 @display(i32* %16, i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32*, i32** %2
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = load i32*, i32** %3
%22 = call i32 @display(i32* %21, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"original\00"
@.str.1 = [10 x i8] c"pointer++\00"
@.str.2 = [11 x i8] c"*pointer++\00"
@.str.3 = [13 x i8] c"(*pointer)++\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 4)
store i32 0, i32* %1
%2 = tail call i32 @display(i32* %1, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @display(i32* %1, i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds i32, i32* %1, i64 2
%5 = tail call i32 @display(i32* %1, i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = tail call i32 @display(i32* %1, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}