#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 */
typedef int atomic_int;

/* Variables and functions */
int ATOMIC_VAR_INIT(int);
int /*<<< orphan*/ abort();
void test_inc_dec(void) {
  atomic_int i = ATOMIC_VAR_INIT(1);
  i++;
  if (i != 2)
    abort();
  i--;
  if (i != 1)
    abort();
  ++i;
  if (i != 2)
    abort();
  --i;
  if (i != 1)
    abort();
  if (++i != 2)
    abort();
  if (i++ != 2)
    abort();
  if (i != 3)
    abort();
  if (i-- != 3)
    abort();
  if (i != 2)
    abort();
}


x86 assembly (clang, -O0):
<test_inc_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1040 <ATOMIC_VAR_INIT@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     114f <test_inc_dec+0x2f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1169 <test_inc_dec+0x49>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     1183 <test_inc_dec+0x63>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     119d <test_inc_dec+0x7d>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x2,%eax
je     11b6 <test_inc_dec+0x96>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x2,%eax
je     11d1 <test_inc_dec+0xb1>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x3,-0x4(%rbp)
je     11e2 <test_inc_dec+0xc2>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x3,%eax
je     11fd <test_inc_dec+0xdd>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x2,-0x4(%rbp)
je     120e <test_inc_dec+0xee>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_inc_dec>:
push   %rax
mov    $0x1,%edi
call   1040 <ATOMIC_VAR_INIT@plt>
cmp    $0x1,%eax
jne    1132 <test_inc_dec+0x12>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @test_inc_dec() {
%1 = alloca i32
%2 = call i32 @ATOMIC_VAR_INIT(i32 1)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = add nsw i32 %3, 1
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 2
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (...) @abort()
unreachable
9: ; preds = %0
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %9
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %16
%24 = load i32, i32* %1
%25 = add nsw i32 %24, -1
store i32 %25, i32* %1
%26 = load i32, i32* %1
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %23
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
%33 = icmp ne i32 %32, 2
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %30
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
%39 = icmp ne i32 %37, 2
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (...) @abort()
unreachable
42: ; preds = %36
%43 = load i32, i32* %1
%44 = icmp ne i32 %43, 3
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %42
%48 = load i32, i32* %1
%49 = add nsw i32 %48, -1
store i32 %49, i32* %1
%50 = icmp ne i32 %48, 3
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (...) @abort()
unreachable
53: ; preds = %47
%54 = load i32, i32* %1
%55 = icmp ne i32 %54, 2
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (...) @abort()
unreachable
58: ; preds = %53
ret void
}

LLVM IR (-O2):
define void @test_inc_dec() {
%1 = tail call i32 @ATOMIC_VAR_INIT(i32 1)
%2 = icmp eq i32 %1, 1
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %0
ret void
}