#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 /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main() {
  int a[] = {-1, -2, -3, -4, 1, 2, 3, 4};
  int j = 0;
  int size = sizeof(a) / sizeof(a[0]);
  int first, second, third;
  while (j + 2 < size) {
    first = second = third = 1;
    if (a[j] < 0)
      first = -1;
    if (a[j + 1] < 0)
      second = -1;
    if (a[j + 2] < 0)
      third = -1;
    if (first == second && second != third) {
      int tmp;
      tmp = a[j + 1];
      a[j + 1] = a[j + 2];
      a[j + 2] = tmp;
    }
    j++;
  }
  for (int i = 0; i < size; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x8,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
cmp    -0x38(%rbp),%eax
jge    1223 <main+0x113>
movl   $0x1,-0x44(%rbp)
movl   $0x1,-0x40(%rbp)
movl   $0x1,-0x3c(%rbp)
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jge    1193 <main+0x83>
movl   $0xffffffff,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
cmpl   $0x0,-0x30(%rbp,%rax,4)
jge    11ad <main+0x9d>
movl   $0xffffffff,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
cltq
cmpl   $0x0,-0x30(%rbp,%rax,4)
jge    11c7 <main+0xb7>
movl   $0xffffffff,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    1215 <main+0x105>
mov    -0x40(%rbp),%eax
cmp    -0x44(%rbp),%eax
je     1215 <main+0x105>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x48(%rbp),%ecx
mov    -0x34(%rbp),%eax
add    $0x2,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1159 <main+0x49>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1258 <main+0x148>
movslq -0x4c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    122a <main+0x11a>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.a = [8 x i32] [i32 -1, i32 -2, i32 -3, i32 -4, i32 1, i32 2, i32 3, i32 4]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [8 x i32]* %2 to i8*
store i32 0, i32* %3
store i32 8, i32* %4
br label %11
11: ; preds = %67, %0
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 2
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %70
16: ; preds = %11
store i32 1, i32* %7
store i32 1, i32* %6
store i32 1, i32* %5
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 -1, i32* %5
br label %23
23: ; preds = %22, %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 -1, i32* %6
br label %31
31: ; preds = %30, %23
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %31
store i32 -1, i32* %7
br label %39
39: ; preds = %38, %31
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %67
43: ; preds = %39
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %67
47: ; preds = %43
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %50
%52 = load i32, i32* %51
store i32 %52, i32* %8
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %60
store i32 %57, i32* %61
%62 = load i32, i32* %8
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 2
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %65
store i32 %62, i32* %66
br label %67
67: ; preds = %47, %43, %39
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %11
70: ; preds = %11
store i32 0, i32* %9
br label %71
71: ; preds = %81, %70
%72 = load i32, i32* %9
%73 = load i32, i32* %4
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
store i32 %83, i32* %9
br label %71
84: ; preds = %71
ret i32 0
}

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