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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char);
void main(void) {
  static signed char i[3] = {-1, -1, -1};
  static signed char j = 0;
  static signed char *k = i;
loop:
  do {
    for (; ((*k)++) < 3;) {
      printf("j:%d, i:%d\n", k - i, *k);
      if (k < &i[sizeof(i) - 1]) {
        ++k;
        goto loop;
      }
    }
    *k = -1;
    --k;
  } while (k >= i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
jmp    1119 <main+0x9>
jmp    111e <main+0xe>
jmp    1123 <main+0x13>
mov    0x2f06(%rip),%rcx
mov    (%rcx),%al
mov    %al,%dl
add    $0x1,%dl
mov    %dl,(%rcx)
movsbl %al,%eax
cmp    $0x3,%eax
jge    119c <main+0x8c>
mov    0x2eea(%rip),%rax
lea    0x2edb(%rip),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    0x2ed7(%rip),%rax
lea    0xea0(%rip),%rdi
movsbl (%rax),%edx
call   1030 <printf@plt>
lea    0x2eb9(%rip),%rax
add    $0x2,%rax
cmp    %rax,0x2eb6(%rip)
jae    1197 <main+0x87>
mov    0x2ea9(%rip),%rax
add    $0x1,%rax
mov    %rax,0x2e9e(%rip)
jmp    1119 <main+0x9>
jmp    1123 <main+0x13>
mov    0x2e8d(%rip),%rax
movb   $0xff,(%rax)
mov    0x2e83(%rip),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x2e78(%rip)
lea    0x2e69(%rip),%rax
cmp    %rax,0x2e6a(%rip)
jae    111e <main+0xe>
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2f14(%rip),%rsi
lea    0x2f05(%rip),%rbx
lea    0xed6(%rip),%r14
lea    0x2ef9(%rip),%r15
jmp    1153 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0xff,(%rsi)
add    $0xffffffffffffffff,%rsi
mov    %rsi,0x2ee2(%rip)
cmp    %rbx,%rsi
jb     1186 <main+0x76>
movzbl (%rsi),%ecx
lea    0x1(%rcx),%eax
mov    %al,(%rsi)
cmp    $0x2,%cl
jg     1140 <main+0x30>
sub    %ebx,%esi
movsbl %al,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x2ebc(%rip),%rsi
cmp    %r15,%rsi
jae    1153 <main+0x43>
add    $0x1,%rsi
mov    %rsi,0x2eac(%rip)
jmp    1153 <main+0x43>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.i = internal global [3 x i8] c"\FF\FF\FF"
@main.j = internal global i8 0
@main.k = internal global i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i32 0, i32 0)
@.str = [12 x i8] c"j:%d, i:%d\0A\00"
define void @main() {
br label %1
1: ; preds = %19, %0
br label %2
2: ; preds = %27, %1
br label %3
3: ; preds = %22, %2
%4 = load i8*, i8** @main.k
%5 = load i8, i8* %4
%6 = add i8 %5, 1
store i8 %6, i8* %4
%7 = sext i8 %5 to i32
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %23
9: ; preds = %3
%10 = load i8*, i8** @main.k
%11 = ptrtoint i8* %10 to i64
%12 = sub i64 %11, ptrtoint ([3 x i8]* @main.i to i64)
%13 = trunc i64 %12 to i32
%14 = load i8*, i8** @main.k
%15 = load i8, i8* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i8 signext %15)
%17 = load i8*, i8** @main.k
%18 = icmp ult i8* %17, getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i64 0, i64 2)
br i1 %18, label %19, label %22
19: ; preds = %9
%20 = load i8*, i8** @main.k
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** @main.k
br label %1
22: ; preds = %9
br label %3
23: ; preds = %3
%24 = load i8*, i8** @main.k
store i8 -1, i8* %24
%25 = load i8*, i8** @main.k
%26 = getelementptr inbounds i8, i8* %25, i32 -1
store i8* %26, i8** @main.k
br label %27
27: ; preds = %23
%28 = load i8*, i8** @main.k
%29 = icmp uge i8* %28, getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i64 0, i64 0)
br i1 %29, label %2, label %30
30: ; preds = %27
ret void
}

LLVM IR (-O2):
@main.i = internal global [3 x i8] c"\FF\FF\FF"
@main.k = internal unnamed_addr global i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i64 0, i64 0)
@.str = [12 x i8] c"j:%d, i:%d\0A\00"
define void @main() {
%1 = load i8*, i8** @main.k
br label %2
2: ; preds = %14, %0
%3 = phi i8* [ %1, %0 ], [ %15, %14 ]
%4 = load i8, i8* %3
%5 = add i8 %4, 1
store i8 %5, i8* %3
%6 = icmp slt i8 %4, 3
br i1 %6, label %7, label %18
7: ; preds = %2
%8 = ptrtoint i8* %3 to i64
%9 = trunc i64 %8 to i32
%10 = sub i32 %9, ptrtoint ([3 x i8]* @main.i to i32)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10, i8 signext %5)
%12 = load i8*, i8** @main.k
%13 = icmp ult i8* %12, getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i64 0, i64 2)
br i1 %13, label %16, label %14
14: ; preds = %7, %16, %18
%15 = phi i8* [ %12, %7 ], [ %19, %18 ], [ %17, %16 ]
br label %2
16: ; preds = %7
%17 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %17, i8** @main.k
br label %14
18: ; preds = %2
store i8 -1, i8* %3
%19 = getelementptr inbounds i8, i8* %3, i64 -1
store i8* %19, i8** @main.k
%20 = icmp ult i8* %19, getelementptr inbounds ([3 x i8], [3 x i8]* @main.i, i64 0, i64 0)
br i1 %20, label %21, label %14
21: ; preds = %18
ret void
}