#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 qr_aa_bits_iterator(char **label) {
  static int next_iter = 0;
  if (NULL == label) {
    next_iter = 0;
    return 4;
  }
  switch (next_iter) {
  case 0:
    *label = "qr=0,aa=0";
    break;
  case 1:
    *label = "qr=1,aa=0";
    break;
  case 2:
    *label = "qr=0,aa=1";
    break;
  case 3:
    *label = "qr=1,aa=1";
    break;
  default:
    *label = "bug";
    return -1;
  }
  return next_iter++;
}


x86 assembly (clang, -O0):
<qr_aa_bits_iterator>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    112a <qr_aa_bits_iterator+0x2a>
movl   $0x0,0x2f06(%rip)
movl   $0x4,-0x4(%rbp)
jmp    11cc <qr_aa_bits_iterator+0xcc>
mov    0x2ef4(%rip),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     119e <qr_aa_bits_iterator+0x9e>
mov    -0x18(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
lea    0xeb3(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b8 <qr_aa_bits_iterator+0xb8>
mov    -0x10(%rbp),%rax
lea    0xeaa(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b8 <qr_aa_bits_iterator+0xb8>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b8 <qr_aa_bits_iterator+0xb8>
mov    -0x10(%rbp),%rax
lea    0xe98(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b8 <qr_aa_bits_iterator+0xb8>
mov    -0x10(%rbp),%rax
lea    0xe8f(%rip),%rcx
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11cc <qr_aa_bits_iterator+0xcc>
mov    0x2e66(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2e5b(%rip)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<qr_aa_bits_iterator>:
test   %rdi,%rdi
je     112d <qr_aa_bits_iterator+0x2d>
movslq 0x2f18(%rip),%rax
cmp    $0x4,%rax
jae    113d <qr_aa_bits_iterator+0x3d>
lea    0xf13(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
mov    %rdx,(%rdi)
lea    0x1(%rax),%ecx
mov    %ecx,0x2ef8(%rip)
ret
movl   $0x0,0x2eed(%rip)
mov    $0x4,%eax
ret
lea    0xee4(%rip),%rax
mov    %rax,(%rdi)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@qr_aa_bits_iterator.next_iter = internal global i32 0
@.str = [10 x i8] c"qr=0,aa=0\00"
@.str.1 = [10 x i8] c"qr=1,aa=0\00"
@.str.2 = [10 x i8] c"qr=0,aa=1\00"
@.str.3 = [10 x i8] c"qr=1,aa=1\00"
@.str.4 = [4 x i8] c"bug\00"
define i32 @qr_aa_bits_iterator(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = icmp eq i8** null, %4
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* @qr_aa_bits_iterator.next_iter
store i32 4, i32* %2
br label %22
7: ; preds = %1
%8 = load i32, i32* @qr_aa_bits_iterator.next_iter
switch i32 %8, label %17 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
9: ; preds = %7
%10 = load i8**, i8*** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %10
br label %19
11: ; preds = %7
%12 = load i8**, i8*** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %12
br label %19
13: ; preds = %7
%14 = load i8**, i8*** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %14
br label %19
15: ; preds = %7
%16 = load i8**, i8*** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %16
br label %19
17: ; preds = %7
%18 = load i8**, i8*** %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %18
store i32 -1, i32* %2
br label %22
19: ; preds = %15, %13, %11, %9
%20 = load i32, i32* @qr_aa_bits_iterator.next_iter
%21 = add nsw i32 %20, 1
store i32 %21, i32* @qr_aa_bits_iterator.next_iter
store i32 %20, i32* %2
br label %22
22: ; preds = %19, %17, %6
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@qr_aa_bits_iterator.next_iter = internal unnamed_addr global i32 0
@.str = [10 x i8] c"qr=0,aa=0\00"
@.str.1 = [10 x i8] c"qr=1,aa=0\00"
@.str.2 = [10 x i8] c"qr=0,aa=1\00"
@.str.3 = [10 x i8] c"qr=1,aa=1\00"
@.str.4 = [4 x i8] c"bug\00"
@reltable.qr_aa_bits_iterator = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.qr_aa_bits_iterator to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.qr_aa_bits_iterator to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.qr_aa_bits_iterator to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.qr_aa_bits_iterator to i64)) to i32)]
define i32 @qr_aa_bits_iterator(i8** writeonly %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %3, label %4
3: ; preds = %1
store i32 0, i32* @qr_aa_bits_iterator.next_iter
br label %13
4: ; preds = %1
%5 = load i32, i32* @qr_aa_bits_iterator.next_iter
%6 = icmp ult i32 %5, 4
br i1 %6, label %8, label %7
7: ; preds = %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %0
br label %13
8: ; preds = %4
%9 = sext i32 %5 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.qr_aa_bits_iterator to i8*), i64 %10)
store i8* %11, i8** %0
%12 = add nuw nsw i32 %5, 1
store i32 %12, i32* @qr_aa_bits_iterator.next_iter
br label %13
13: ; preds = %8, %7, %3
%14 = phi i32 [ 4, %3 ], [ -1, %7 ], [ %5, %8 ]
ret i32 %14
}