#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 a = 1, b = 2, c = 1, d = 2, e = 1, f = 2, g = 1, h = 2, ex1, ex2, ex3,
      ex4;
  ex1 = a++ + b++;
  printf("Output for ex1 is :\t %d \n", ex1);
  ex2 = ++c + ++d;
  printf("Output for ex2 is :\t %d \n", ex2);
  ex3 = e++ + ++f;
  printf("Output for ex3 is :\t %d \n", ex3);
  ex4 = ++g + h++;
  printf("Output for ex4 is :\t %d \n", ex4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Output for ex1 is :\09 %d \0A\00"
@.str.1 = [26 x i8] c"Output for ex2 is :\09 %d \0A\00"
@.str.2 = [26 x i8] c"Output for ex3 is :\09 %d \0A\00"
@.str.3 = [26 x i8] c"Output for ex4 is :\09 %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
store i32 1, i32* %4
store i32 2, i32* %5
store i32 1, i32* %6
store i32 2, i32* %7
store i32 1, i32* %8
store i32 2, i32* %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = add nsw i32 %14, %16
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = add nsw i32 %22, %24
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
%32 = add nsw i32 %28, %31
store i32 %32, i32* %12
%33 = load i32, i32* %12
%34 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
%39 = add nsw i32 %36, %37
store i32 %39, i32* %13
%40 = load i32, i32* %13
%41 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Output for ex1 is :\09 %d \0A\00"
@.str.1 = [26 x i8] c"Output for ex2 is :\09 %d \0A\00"
@.str.2 = [26 x i8] c"Output for ex3 is :\09 %d \0A\00"
@.str.3 = [26 x i8] c"Output for ex4 is :\09 %d \0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 3)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 5)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 4)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 4)
ret i32 0
}