#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  int c2 = 2;
  int c1 = 2;
  int c0 = 2;
  int b;
  for (b = 3;; b++) {
    printf("%d %d %d [%d]\n", c2, c1, c0, b);
    if (0 < c0)
      c0--;
    else if (0 < c1) {
      c1--;
      c0 = b;
    } else if (0 < c2) {
      c2--;
      c0 = c1 = b;
    } else
      break;
  }
  printf("I am finished with b=%d\n", b);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%eax
jge    116f <main+0x5f>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11bf <main+0xaf>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jge    118e <main+0x7e>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ba <main+0xaa>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jge    11b0 <main+0xa0>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    %eax,-0x10(%rbp)
jmp    11b5 <main+0xa5>
jmp    11d2 <main+0xc2>
jmp    11ba <main+0xaa>
jmp    11bf <main+0xaf>
jmp    11c4 <main+0xb4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x3,%ebx
mov    $0x2,%r15d
lea    0xed6(%rip),%r14
mov    $0x2,%r12d
mov    $0x2,%ebp
jmp    1146 <main+0x36>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
add    $0x1,%ebx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jg     1140 <main+0x30>
test   %r12d,%r12d
jle    116a <main+0x5a>
add    $0xffffffff,%r12d
jmp    1176 <main+0x66>
test   %r15d,%r15d
jle    117f <main+0x6f>
add    $0xffffffff,%r15d
mov    %ebx,%r12d
mov    %ebx,%ebp
lea    0x1(%rbx),%eax
mov    %eax,%ebx
jmp    1146 <main+0x36>
lea    0xe89(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%d %d %d [%d]\0A\00"
@.str.1 = [25 x i8] c"I am finished with b=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 2, i32* %3
store i32 2, i32* %4
store i32 3, i32* %5
br label %6
6: ; preds = %35, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9, i32 %10)
%12 = load i32, i32* %4
%13 = icmp slt i32 0, %12
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* %4
%16 = add nsw i32 %15, -1
store i32 %16, i32* %4
br label %34
17: ; preds = %6
%18 = load i32, i32* %3
%19 = icmp slt i32 0, %18
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
%23 = load i32, i32* %5
store i32 %23, i32* %4
br label %33
24: ; preds = %17
%25 = load i32, i32* %2
%26 = icmp slt i32 0, %25
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %2
%29 = add nsw i32 %28, -1
store i32 %29, i32* %2
%30 = load i32, i32* %5
store i32 %30, i32* %3
store i32 %30, i32* %4
br label %32
31: ; preds = %24
br label %38
32: ; preds = %27
br label %33
33: ; preds = %32, %20
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %6
38: ; preds = %31
%39 = load i32, i32* %5
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @EXIT_SUCCESS
ret i32 %41
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d %d %d [%d]\0A\00"
@.str.1 = [25 x i8] c"I am finished with b=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
br label %1
1: ; preds = %18, %0
%2 = phi i32 [ 2, %0 ], [ %19, %18 ]
%3 = phi i32 [ 2, %0 ], [ %20, %18 ]
%4 = phi i32 [ 2, %0 ], [ %21, %18 ]
%5 = phi i32 [ 3, %0 ], [ %22, %18 ]
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 %4, i32 %5)
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = add nsw i32 %4, -1
br label %18
10: ; preds = %1
%11 = icmp sgt i32 %3, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = add nsw i32 %3, -1
br label %18
14: ; preds = %10
%15 = icmp sgt i32 %2, 0
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = add nsw i32 %2, -1
br label %18
18: ; preds = %8, %16, %12
%19 = phi i32 [ %2, %8 ], [ %2, %12 ], [ %17, %16 ]
%20 = phi i32 [ %3, %8 ], [ %13, %12 ], [ %5, %16 ]
%21 = phi i32 [ %9, %8 ], [ %5, %12 ], [ %5, %16 ]
%22 = add nuw nsw i32 %5, 1
br label %1
23: ; preds = %14
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}