#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 *, int);
int main() {
  int a = 1, b = 1, answer = 0;
  int cnt = 0, cnt2 = 0;
  while (a < 30) {
    while (b < a) {
      if (b > 5)
        b = b * 3;
      else
        b = b + 2;
      if (b >= 10 && b <= 12)
        a = a + 10;
      else
        a = a + 1;
      cnt++;
    }
    printf("cnt:%d\n", cnt);
    cnt = 0;
    cnt2++;
    a = a + 2;
    b = b - 10;
  }
  printf("cnt2:%d\n", cnt2);
  return answer;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1e,-0x8(%rbp)
jge    11eb <main+0xdb>
jmp    1151 <main+0x41>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b5 <main+0xa5>
cmpl   $0x5,-0xc(%rbp)
jle    1173 <main+0x63>
imul   $0x3,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x6c>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     119e <main+0x8e>
cmpl   $0xc,-0xc(%rbp)
jg     119e <main+0x8e>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    11a7 <main+0x97>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <main+0x41>
mov    -0x14(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <main+0x32>
mov    -0x18(%rbp),%esi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
xor    %r15d,%r15d
lea    0xeda(%rip),%r14
mov    $0x1,%eax
jmp    114f <main+0x3f>
nopl   (%rax)
add    $0xfffffff6,%eax
xor    %esi,%esi
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%r15d
lea    0x2(%rbx),%ecx
mov    %ebp,%eax
cmp    $0x1c,%ebx
mov    %ecx,%ebx
jge    1188 <main+0x78>
cmp    %ebx,%eax
jge    1130 <main+0x20>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x2(%rax),%ecx
cmp    $0x6,%eax
lea    (%rax,%rax,2),%eax
cmovl  %ecx,%eax
lea    -0xa(%rax),%ebp
xor    %ecx,%ecx
cmp    $0x3,%ebp
setb   %cl
lea    (%rcx,%rcx,8),%ecx
add    %ecx,%ebx
add    $0x1,%ebx
add    $0x1,%esi
cmp    %ebx,%eax
jl     1160 <main+0x50>
jmp    1137 <main+0x27>
lea    0xe79(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"cnt:%d\0A\00"
@.str.1 = [9 x i8] c"cnt2:%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %22
%2 = phi i32 [ 0, %0 ], [ %27, %22 ]
%3 = phi i32 [ 1, %0 ], [ %28, %22 ]
%4 = phi i32 [ 1, %0 ], [ %23, %22 ]
%5 = icmp slt i32 %4, %3
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = add nsw i32 %4, -10
br label %22
8: ; preds = %1, %8
%9 = phi i32 [ %20, %8 ], [ 0, %1 ]
%10 = phi i32 [ %19, %8 ], [ %3, %1 ]
%11 = phi i32 [ %15, %8 ], [ %4, %1 ]
%12 = icmp sgt i32 %11, 5
%13 = mul nsw i32 %11, 3
%14 = add nsw i32 %11, 2
%15 = select i1 %12, i32 %13, i32 %14
%16 = add i32 %15, -10
%17 = icmp ult i32 %16, 3
%18 = select i1 %17, i32 10, i32 1
%19 = add nsw i32 %18, %10
%20 = add nuw nsw i32 %9, 1
%21 = icmp slt i32 %15, %19
br i1 %21, label %8, label %22
22: ; preds = %8, %6
%23 = phi i32 [ %7, %6 ], [ %16, %8 ]
%24 = phi i32 [ %3, %6 ], [ %19, %8 ]
%25 = phi i32 [ 0, %6 ], [ %20, %8 ]
%26 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i32 %2, 1
%28 = add nsw i32 %24, 2
%29 = icmp slt i32 %24, 28
br i1 %29, label %1, label %30
30: ; preds = %22
%31 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}