#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 */
scalar_t__ make_prime_check(unsigned int);
unsigned make_prime(unsigned nr) {
  if (0 == (nr & 1))
    nr--;
  while (nr > 1) {
    if (make_prime_check(nr))
      return nr;
    nr -= 2;
  }
  return 2;
}


x86 assembly (clang, -O0):
<make_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
and    $0x1,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1134 <make_prime+0x24>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <make_prime+0x29>
cmpl   $0x1,-0x8(%rbp)
jbe    116e <make_prime+0x5e>
mov    -0x8(%rbp),%edi
call   1030 <make_prime_check@plt>
cmp    $0x0,%rax
je     1160 <make_prime+0x50>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1175 <make_prime+0x65>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <make_prime+0x29>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_prime>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%eax
and    $0x1,%eax
lea    (%rdi,%rax,1),%ebp
add    $0xffffffff,%ebp
mov    $0x2,%ebx
cmp    $0x2,%ebp
jb     1148 <make_prime+0x38>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <make_prime_check@plt>
test   %rax,%rax
jne    1146 <make_prime+0x36>
add    $0xfffffffe,%ebp
cmp    $0x1,%ebp
ja     1130 <make_prime+0x20>
jmp    1148 <make_prime+0x38>
mov    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @make_prime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 1
%6 = icmp eq i32 0, %5
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = add i32 %8, -1
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
br label %11
11: ; preds = %20, %10
%12 = load i32, i32* %3
%13 = icmp ugt i32 %12, 1
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %3
%16 = call i64 @make_prime_check(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* %3
store i32 %19, i32* %2
br label %24
20: ; preds = %14
%21 = load i32, i32* %3
%22 = sub i32 %21, 2
store i32 %22, i32* %3
br label %11
23: ; preds = %11
store i32 2, i32* %2
br label %24
24: ; preds = %23, %18
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @make_prime(i32 %0) {
%2 = and i32 %0, 1
%3 = add i32 %0, -1
%4 = add i32 %3, %2
%5 = icmp ugt i32 %4, 1
br i1 %5, label %6, label %13
6: ; preds = %1, %10
%7 = phi i32 [ %11, %10 ], [ %4, %1 ]
%8 = tail call i64 @make_prime_check(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = add i32 %7, -2
%12 = icmp ugt i32 %11, 1
br i1 %12, label %6, label %13
13: ; preds = %6, %10, %1
%14 = phi i32 [ 2, %1 ], [ 2, %10 ], [ %7, %6 ]
ret i32 %14
}