#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 certain_qnames_iterator(char **label) {
  static int next_iter = 0;
  if (NULL == label) {
    next_iter = 0;
    return 2 + 1;
  }
  if (0 == next_iter)
    *label = "localhost";
  else if (1 == next_iter)
    *label = "X.root-servers.net";
  else if (2 == next_iter)
    *label = "else";
  else
    return -1;
  return next_iter++;
}


x86 assembly (clang, -O0):
<certain_qnames_iterator>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    112a <certain_qnames_iterator+0x2a>
movl   $0x0,0x2f06(%rip)
movl   $0x3,-0x4(%rbp)
jmp    11bd <certain_qnames_iterator+0xbd>
xor    %eax,%eax
cmp    0x2ef2(%rip),%eax
jne    114b <certain_qnames_iterator+0x4b>
mov    -0x10(%rbp),%rax
lea    0xebd(%rip),%rcx
mov    %rcx,(%rax)
jmp    11a9 <certain_qnames_iterator+0xa9>
mov    $0x1,%eax
cmp    0x2ece(%rip),%eax
jne    116f <certain_qnames_iterator+0x6f>
mov    -0x10(%rbp),%rax
lea    0xea3(%rip),%rcx
mov    %rcx,(%rax)
jmp    11a4 <certain_qnames_iterator+0xa4>
mov    $0x2,%eax
cmp    0x2eaa(%rip),%eax
jne    1193 <certain_qnames_iterator+0x93>
mov    -0x10(%rbp),%rax
lea    0xe92(%rip),%rcx
mov    %rcx,(%rax)
jmp    119f <certain_qnames_iterator+0x9f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <certain_qnames_iterator+0xbd>
jmp    11a4 <certain_qnames_iterator+0xa4>
jmp    11a9 <certain_qnames_iterator+0xa9>
mov    0x2e75(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2e6a(%rip)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<certain_qnames_iterator>:
test   %rdi,%rdi
je     112f <certain_qnames_iterator+0x2f>
movslq 0x2f18(%rip),%rcx
mov    $0xffffffff,%eax
cmp    $0x2,%rcx
ja     113c <certain_qnames_iterator+0x3c>
lea    0xf06(%rip),%rax
movslq (%rax,%rcx,4),%rdx
add    %rax,%rdx
mov    %rdx,(%rdi)
lea    0x1(%rcx),%edx
mov    %ecx,%eax
jmp    1136 <certain_qnames_iterator+0x36>
mov    $0x3,%eax
xor    %edx,%edx
mov    %edx,0x2ee8(%rip)
ret

LLVM IR (-O0):
@certain_qnames_iterator.next_iter = internal global i32 0
@.str = [10 x i8] c"localhost\00"
@.str.1 = [19 x i8] c"X.root-servers.net\00"
@.str.2 = [5 x i8] c"else\00"
define i32 @certain_qnames_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* @certain_qnames_iterator.next_iter
store i32 3, i32* %2
br label %28
7: ; preds = %1
%8 = load i32, i32* @certain_qnames_iterator.next_iter
%9 = icmp eq i32 0, %8
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i8**, i8*** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %11
br label %25
12: ; preds = %7
%13 = load i32, i32* @certain_qnames_iterator.next_iter
%14 = icmp eq i32 1, %13
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i8**, i8*** %3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %16
br label %24
17: ; preds = %12
%18 = load i32, i32* @certain_qnames_iterator.next_iter
%19 = icmp eq i32 2, %18
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i8**, i8*** %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %21
br label %23
22: ; preds = %17
store i32 -1, i32* %2
br label %28
23: ; preds = %20
br label %24
24: ; preds = %23, %15
br label %25
25: ; preds = %24, %10
%26 = load i32, i32* @certain_qnames_iterator.next_iter
%27 = add nsw i32 %26, 1
store i32 %27, i32* @certain_qnames_iterator.next_iter
store i32 %26, i32* %2
br label %28
28: ; preds = %25, %22, %6
%29 = load i32, i32* %2
ret i32 %29
}

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