#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ identify_stars(double **, int *, int /*<<< orphan*/ *, int **);
int identify_image(double image_stars[12][3], FILE *pattern_catalog,
                   int num_image_stars, int matches[4][2],
                   int num_stars_selected) {
  static int image_star_ids[4];
  if (num_stars_selected < 4) {
    for (image_star_ids[num_stars_selected] = 4 - num_stars_selected - 1;
         image_star_ids[num_stars_selected] < num_image_stars;
         image_star_ids[num_stars_selected]++) {
      if (identify_image(image_stars, pattern_catalog,
                         image_star_ids[num_stars_selected], matches,
                         num_stars_selected + 1)) {
        return 1;
      }
    }
  } else {
    if (identify_stars(image_stars, image_star_ids, pattern_catalog, matches)) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<identify_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    11db <identify_image+0xbb>
mov    $0x4,%edx
sub    -0x2c(%rbp),%edx
sub    $0x1,%edx
movslq -0x2c(%rbp),%rcx
lea    0x2ee5(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x2c(%rbp),%rcx
lea    0x2ed7(%rip),%rax
mov    (%rax,%rcx,4),%eax
cmp    -0x1c(%rbp),%eax
jge    11d6 <identify_image+0xb6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rcx
lea    0x2eb8(%rip),%rax
mov    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
add    $0x1,%r8d
call   1040 <identify_image@plt>
cmp    $0x0,%eax
je     11b1 <identify_image+0x91>
movl   $0x1,-0x4(%rbp)
jmp    1215 <identify_image+0xf5>
jmp    11b6 <identify_image+0x96>
movslq -0x2c(%rbp),%rcx
lea    0x2e7f(%rip),%rax
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
lea    0x2e72(%rip),%rax
mov    %edx,(%rax,%rcx,4)
jmp    115e <identify_image+0x3e>
jmp    120e <identify_image+0xee>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0x2e52(%rip),%rsi
call   1030 <identify_stars@plt>
cmp    $0x0,%rax
je     1209 <identify_image+0xe9>
movl   $0x1,-0x4(%rbp)
jmp    1215 <identify_image+0xf5>
jmp    120e <identify_image+0xee>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<identify_image>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r13
cmp    $0x3,%r8d
jg     1195 <identify_image+0x75>
mov    %r8d,%ebp
mov    %edx,%r12d
mov    $0x3,%edx
sub    %r8d,%edx
movslq %r8d,%rbx
lea    0x2ef1(%rip),%rsi
mov    %edx,(%rsi,%rbx,4)
cmp    %r12d,%edx
jge    11b4 <identify_image+0x94>
add    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rax,%r14
mov    %rax,%rsi
mov    %rcx,%r15
mov    %ebp,%r8d
call   1040 <identify_image@plt>
test   %eax,%eax
jne    11c5 <identify_image+0xa5>
lea    0x2ec1(%rip),%rax
mov    (%rax,%rbx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rbx,4)
cmp    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%rax
jl     1160 <identify_image+0x40>
jmp    11b4 <identify_image+0x94>
lea    0x2ea4(%rip),%rsi
mov    %r13,%rdi
mov    %rax,%rdx
call   1030 <identify_stars@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11b6 <identify_image+0x96>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    11b6 <identify_image+0x96>

LLVM IR (-O0):
@identify_image.image_star_ids = internal global [4 x i32] zeroinitializer
define i32 @identify_image([3 x double]* %0, i32* %1, i32 %2, [2 x i32]* %3, i32 %4) {
%6 = alloca i32
%7 = alloca [3 x double]*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [2 x i32]*
%11 = alloca i32
store [3 x double]* %0, [3 x double]** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store [2 x i32]* %3, [2 x i32]** %10
store i32 %4, i32* %11
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %49
14: ; preds = %5
%15 = load i32, i32* %11
%16 = sub nsw i32 4, %15
%17 = sub nsw i32 %16, 1
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 %19
store i32 %17, i32* %20
br label %21
21: ; preds = %42, %14
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %21
%29 = load [3 x double]*, [3 x double]** %7
%30 = load i32*, i32** %8
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = load [2 x i32]*, [2 x i32]** %10
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
%38 = call i32 @identify_image([3 x double]* %29, i32* %30, i32 %34, [2 x i32]* %35, i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %28
store i32 1, i32* %6
br label %60
41: ; preds = %28
br label %42
42: ; preds = %41
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
br label %21
48: ; preds = %21
br label %59
49: ; preds = %5
%50 = load [3 x double]*, [3 x double]** %7
%51 = bitcast [3 x double]* %50 to double**
%52 = load i32*, i32** %8
%53 = load [2 x i32]*, [2 x i32]** %10
%54 = bitcast [2 x i32]* %53 to i32**
%55 = call i64 @identify_stars(double** %51, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 0), i32* %52, i32** %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %49
store i32 1, i32* %6
br label %60
58: ; preds = %49
br label %59
59: ; preds = %58, %48
store i32 0, i32* %6
br label %60
60: ; preds = %59, %57, %40
%61 = load i32, i32* %6
ret i32 %61
}

LLVM IR (-O2):
@identify_image.image_star_ids = internal global [4 x i32] zeroinitializer
define i32 @identify_image([3 x double]* %0, i32* %1, i32 %2, [2 x i32]* %3, i32 %4) {
%6 = icmp slt i32 %4, 4
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = sub i32 3, %4
%9 = sext i32 %4 to i64
%10 = getelementptr inbounds [4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 %9
store i32 %8, i32* %10
%11 = icmp slt i32 %8, %2
br i1 %11, label %12, label %27
12: ; preds = %7
%13 = add nsw i32 %4, 1
br label %14
14: ; preds = %12, %18
%15 = phi i32 [ %8, %12 ], [ %20, %18 ]
%16 = tail call i32 @identify_image([3 x double]* %0, i32* %1, i32 %15, [2 x i32]* %3, i32 %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* %10
%20 = add nsw i32 %19, 1
store i32 %20, i32* %10
%21 = icmp slt i32 %20, %2
br i1 %21, label %14, label %27
22: ; preds = %5
%23 = bitcast [3 x double]* %0 to double**
%24 = bitcast [2 x i32]* %3 to i32**
%25 = tail call i64 @identify_stars(double** %23, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @identify_image.image_star_ids, i64 0, i64 0), i32* %1, i32** %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %18, %7, %22
br label %28
28: ; preds = %14, %22, %27
%29 = phi i32 [ 0, %27 ], [ 1, %22 ], [ 1, %14 ]
ret i32 %29
}