#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 *, ...);
void INCREMENT(int A[]) {
  int i = 0, j;
  while (i < 8 && A[i] == 1) {
    A[i] = 0;
    i = i + 1;
  }
  if (i < 8) {
    A[i] = 1;
  }
  for (j = 8 - 1; j > -1; j--) {
    printf("%d\t", A[j]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<INCREMENT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jge    1144 <INCREMENT+0x34>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1154 <INCREMENT+0x44>
jmp    1171 <INCREMENT+0x61>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <INCREMENT+0x13>
cmpl   $0x8,-0xc(%rbp)
jge    118a <INCREMENT+0x7a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movl   $0x7,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jle    11c2 <INCREMENT+0xb2>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <INCREMENT+0x81>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<INCREMENT>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpl   $0x1,(%rdi)
mov    %rdi,%rax
jne    11bd <INCREMENT+0x9d>
movl   $0x0,(%rbx)
cmpl   $0x1,0x4(%rbx)
jne    119b <INCREMENT+0x7b>
movl   $0x0,0x4(%rbx)
cmpl   $0x1,0x8(%rbx)
jne    11a1 <INCREMENT+0x81>
movl   $0x0,0x8(%rbx)
cmpl   $0x1,0xc(%rbx)
jne    11a7 <INCREMENT+0x87>
movl   $0x0,0xc(%rbx)
cmpl   $0x1,0x10(%rbx)
jne    11ad <INCREMENT+0x8d>
movl   $0x0,0x10(%rbx)
cmpl   $0x1,0x14(%rbx)
jne    11b3 <INCREMENT+0x93>
movl   $0x0,0x14(%rbx)
cmpl   $0x1,0x18(%rbx)
jne    11b9 <INCREMENT+0x99>
movl   $0x0,0x18(%rbx)
lea    0x1c(%rbx),%rax
cmpl   $0x1,0x1c(%rbx)
jne    11bd <INCREMENT+0x9d>
movl   $0x0,(%rax)
xor    %esi,%esi
jmp    11c6 <INCREMENT+0xa6>
lea    0x4(%rbx),%rax
jmp    11bd <INCREMENT+0x9d>
lea    0x8(%rbx),%rax
jmp    11bd <INCREMENT+0x9d>
lea    0xc(%rbx),%rax
jmp    11bd <INCREMENT+0x9d>
lea    0x10(%rbx),%rax
jmp    11bd <INCREMENT+0x9d>
lea    0x14(%rbx),%rax
jmp    11bd <INCREMENT+0x9d>
lea    0x18(%rbx),%rax
movl   $0x1,(%rax)
mov    0x1c(%rbx),%esi
lea    0xe33(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @INCREMENT(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 1
br label %15
15: ; preds = %8, %5
%16 = phi i1 [ false, %5 ], [ %14, %8 ]
br i1 %16, label %17, label %24
17: ; preds = %15
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 0, i32* %21
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %5
24: ; preds = %15
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 8
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32*, i32** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
store i32 1, i32* %31
br label %32
32: ; preds = %27, %24
store i32 7, i32* %4
br label %33
33: ; preds = %43, %32
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, -1
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i32*, i32** %2
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %36
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
br label %33
46: ; preds = %33
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @INCREMENT(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %33
4: ; preds = %1
store i32 0, i32* %0
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %33
8: ; preds = %4
store i32 0, i32* %5
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %33
12: ; preds = %8
store i32 0, i32* %9
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %33
16: ; preds = %12
store i32 0, i32* %13
%17 = getelementptr inbounds i32, i32* %0, i64 4
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %33
20: ; preds = %16
store i32 0, i32* %17
%21 = getelementptr inbounds i32, i32* %0, i64 5
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %33
24: ; preds = %20
store i32 0, i32* %21
%25 = getelementptr inbounds i32, i32* %0, i64 6
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %33
28: ; preds = %24
store i32 0, i32* %25
%29 = getelementptr inbounds i32, i32* %0, i64 7
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 0, i32* %29
br label %37
33: ; preds = %28, %24, %20, %16, %12, %8, %4, %1
%34 = phi i32* [ %0, %1 ], [ %5, %4 ], [ %9, %8 ], [ %13, %12 ], [ %17, %16 ], [ %21, %20 ], [ %25, %24 ], [ %29, %28 ]
store i32 1, i32* %34
%35 = getelementptr inbounds i32, i32* %0, i64 7
%36 = load i32, i32* %35
br label %37
37: ; preds = %32, %33
%38 = phi i32 [ 0, %32 ], [ %36, %33 ]
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds i32, i32* %0, i64 6
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds i32, i32* %0, i64 5
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds i32, i32* %0, i64 4
%47 = load i32, i32* %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds i32, i32* %0, i64 3
%50 = load i32, i32* %49
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds i32, i32* %0, i64 2
%53 = load i32, i32* %52
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds i32, i32* %0, i64 1
%56 = load i32, i32* %55
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %0
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = tail call i32 @putchar(i32 10)
ret void
}