#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 numberOf(int);
int haveTwoTheSame() {
  int i;
  for (i = 1; i <= 6; i++) {
    if (numberOf(i) == 2) {
      return i;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<haveTwoTheSame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jg     1158 <haveTwoTheSame+0x48>
mov    -0x8(%rbp),%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
jne    1145 <haveTwoTheSame+0x35>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115f <haveTwoTheSame+0x4f>
jmp    114a <haveTwoTheSame+0x3a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    111f <haveTwoTheSame+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<haveTwoTheSame>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    $0x1,%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
je     118e <haveTwoTheSame+0x7e>
mov    $0x2,%ebx
mov    $0x2,%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
je     118e <haveTwoTheSame+0x7e>
mov    $0x3,%ebx
mov    $0x3,%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
je     118e <haveTwoTheSame+0x7e>
mov    $0x4,%ebx
mov    $0x4,%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
je     118e <haveTwoTheSame+0x7e>
mov    $0x5,%ebx
mov    $0x5,%edi
call   1030 <numberOf@plt>
cmp    $0x2,%eax
je     118e <haveTwoTheSame+0x7e>
mov    $0x6,%ebp
mov    $0x6,%edi
call   1030 <numberOf@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
cmove  %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @haveTwoTheSame() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = icmp sle i32 %4, 6
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i32 @numberOf(i32 %7)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = load i32, i32* %2
store i32 %11, i32* %1
br label %17
12: ; preds = %6
br label %13
13: ; preds = %12
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %3
16: ; preds = %3
store i32 0, i32* %1
br label %17
17: ; preds = %16, %10
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
define i32 @haveTwoTheSame() {
%1 = tail call i32 @numberOf(i32 1)
%2 = icmp eq i32 %1, 2
br i1 %2, label %19, label %3
3: ; preds = %0
%4 = tail call i32 @numberOf(i32 2)
%5 = icmp eq i32 %4, 2
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i32 @numberOf(i32 3)
%8 = icmp eq i32 %7, 2
br i1 %8, label %19, label %9
9: ; preds = %6
%10 = tail call i32 @numberOf(i32 4)
%11 = icmp eq i32 %10, 2
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i32 @numberOf(i32 5)
%14 = icmp eq i32 %13, 2
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call i32 @numberOf(i32 6)
%17 = icmp eq i32 %16, 2
%18 = select i1 %17, i32 6, i32 0
br label %19
19: ; preds = %15, %12, %9, %6, %3, %0
%20 = phi i32 [ 1, %0 ], [ 2, %3 ], [ 3, %6 ], [ 4, %9 ], [ 5, %12 ], [ %18, %15 ]
ret i32 %20
}