#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() {
  int i, x;
  i = 0;
  x = i++;
  printf("Post increment: i=0, x=i++ i = %i x = %i\n", i, x);
  i = 0;
  x = ++i;
  printf("Pre increment: i=0, x=++i i = %i x = %i\n", i, x);
  i = 0;
  x = i--;
  printf("Post decrement: i=0, x=i-- i = %i x = %i\n", i, x);
  i = 0;
  x = --i;
  printf("Pre decrement: i=0, x=--i i = %i x = %i\n", i, x);
  i = 5;
  i += 2;
  printf("Plus Compound: i=5, i+=2 Result:  %i\n", i);
  i = 25;
  i %= 7;
  printf("25%%7 i=%i\n", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x19,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf34(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf47(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Post increment: i=0, x=i++ i = %i x = %i\0A\00"
@.str.1 = [41 x i8] c"Pre increment: i=0, x=++i i = %i x = %i\0A\00"
@.str.2 = [42 x i8] c"Post decrement: i=0, x=i-- i = %i x = %i\0A\00"
@.str.3 = [41 x i8] c"Pre decrement: i=0, x=--i i = %i x = %i\0A\00"
@.str.4 = [38 x i8] c"Plus Compound: i=5, i+=2 Result: %i\0A\00"
@.str.5 = [12 x i8] c"25%%7 i=%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = load i32, i32* %2
%5 = add nsw i32 %4, 1
store i32 %5, i32* %2
store i32 %4, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
store i32 0, i32* %2
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
store i32 0, i32* %2
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
store i32 %14, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17)
store i32 0, i32* %2
%19 = load i32, i32* %2
%20 = add nsw i32 %19, -1
store i32 %20, i32* %2
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22)
store i32 5, i32* %2
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 2
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %26)
store i32 25, i32* %2
%28 = load i32, i32* %2
%29 = srem i32 %28, 7
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Post increment: i=0, x=i++ i = %i x = %i\0A\00"
@.str.1 = [41 x i8] c"Pre increment: i=0, x=++i i = %i x = %i\0A\00"
@.str.2 = [42 x i8] c"Post decrement: i=0, x=i-- i = %i x = %i\0A\00"
@.str.3 = [41 x i8] c"Pre decrement: i=0, x=--i i = %i x = %i\0A\00"
@.str.4 = [38 x i8] c"Plus Compound: i=5, i+=2 Result: %i\0A\00"
@.str.5 = [12 x i8] c"25%%7 i=%i\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 1, i32 0)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 -1, i32 0)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 -1, i32 -1)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 7)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 4)
ret i32 0
}