#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, y, x, z;
  int a[10];
  i = 0;
  a[i++] = 0;
  printf("%d\n", a[0]);
  a[++i] = 0;
  printf("%d\n", a[2]);
  x = 2;
  y = (x += 2);
  printf("%d\n", x);
  z = (x %= 3) + (x %= 4);
  printf("%d\n", z);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cltq
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x40(%rbp),%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cltq
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x38(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x44(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x44(%rbp),%edx
mov    %eax,-0x10(%rbp)
add    %eax,%edx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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