#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*/ fftw_die(char *);
int period(int, int);
int find_generator(int p) {
  int g;
  for (g = 1; g < p; ++g)
    if (period(g, p) == p - 1)
      break;
  if (g == p)
    fftw_die("couldn't find generator for Rader\n");
  return g;
}


x86 assembly (clang, -O0):
<find_generator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116f <find_generator+0x4f>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <period@plt>
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    115c <find_generator+0x3c>
jmp    116f <find_generator+0x4f>
jmp    1161 <find_generator+0x41>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <find_generator+0x12>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1187 <find_generator+0x67>
lea    0xe7e(%rip),%rdi
call   1040 <fftw_die@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_generator>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     115b <find_generator+0x3b>
lea    -0x1(%r14),%ebp
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <period@plt>
cmp    %ebp,%eax
je     115b <find_generator+0x3b>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1140 <find_generator+0x20>
mov    %r14d,%ebx
jmp    1160 <find_generator+0x40>
cmp    %r14d,%ebx
jne    116c <find_generator+0x4c>
lea    0xe99(%rip),%rdi
call   1040 <fftw_die@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"couldn't find generator for Rader\0A\00"
define i32 @find_generator(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %17, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = call i32 @period(i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, 1
%14 = icmp eq i32 %11, %13
br i1 %14, label %15, label %16
15: ; preds = %8
br label %20
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %4
20: ; preds = %15, %4
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @fftw_die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [35 x i8] c"couldn't find generator for Rader\0A\00"
define i32 @find_generator(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %12
3: ; preds = %1
%4 = add nsw i32 %0, -1
br label %5
5: ; preds = %3, %9
%6 = phi i32 [ 1, %3 ], [ %10, %9 ]
%7 = tail call i32 @period(i32 %6, i32 %0)
%8 = icmp eq i32 %7, %4
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = add nuw nsw i32 %6, 1
%11 = icmp eq i32 %10, %0
br i1 %11, label %15, label %5
12: ; preds = %5, %1
%13 = phi i32 [ 1, %1 ], [ %6, %5 ]
%14 = icmp eq i32 %13, %0
br i1 %14, label %15, label %18
15: ; preds = %9, %12
%16 = phi i32 [ %13, %12 ], [ %0, %9 ]
%17 = tail call i32 @fftw_die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ %16, %15 ], [ %13, %12 ]
ret i32 %19
}