#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int input_prime_number(int *prime_number, int range) {
  int value;
  do {
    printf("input prime number: ");
    scanf("%d", prime_number);
    value = (*prime_number);
    while ((*prime_number) != range && (*prime_number) != 0) {
      if ((*prime_number) > range) {
        (*prime_number) -= range;
      } else {
        range -= (*prime_number);
      }
    }
  } while ((*prime_number) != 1);
  return value;
}


x86 assembly (clang, -O0):
<input_prime_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xecf(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x11(%rbp)
je     1175 <input_prime_number+0x55>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1185 <input_prime_number+0x65>
jmp    11b9 <input_prime_number+0x99>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jle    11a6 <input_prime_number+0x86>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    11b4 <input_prime_number+0x94>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <input_prime_number+0x34>
jmp    11be <input_prime_number+0x9e>
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jne    112f <input_prime_number+0xf>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_prime_number>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xecc(%rip),%r15
lea    0xeda(%rip),%r12
jmp    1145 <input_prime_number+0x25>
nopl   (%rax)
cmp    $0x1,%ecx
je     119c <input_prime_number+0x7c>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    (%r14),%eax
mov    %eax,%ecx
test   %eax,%eax
je     1140 <input_prime_number+0x20>
cmp    %ebx,%eax
je     1140 <input_prime_number+0x20>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%edx
sub    %ebx,%edx
jle    1190 <input_prime_number+0x70>
mov    %edx,(%r14)
mov    %edx,%ecx
test   %ecx,%ecx
jne    1196 <input_prime_number+0x76>
jmp    1140 <input_prime_number+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
sub    %ecx,%ebx
test   %ecx,%ecx
je     1140 <input_prime_number+0x20>
cmp    %ebx,%ecx
jne    1170 <input_prime_number+0x50>
jmp    1140 <input_prime_number+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"input prime number: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @input_prime_number(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %40, %2
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = load i32*, i32** %3
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
store i32 %11, i32* %5
br label %12
12: ; preds = %38, %6
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = load i32, i32* %4
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %17, %12
%22 = phi i1 [ false, %12 ], [ %20, %17 ]
br i1 %22, label %23, label %39
23: ; preds = %21
%24 = load i32*, i32** %3
%25 = load i32, i32* %24
%26 = load i32, i32* %4
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i32, i32* %4
%30 = load i32*, i32** %3
%31 = load i32, i32* %30
%32 = sub nsw i32 %31, %29
store i32 %32, i32* %30
br label %38
33: ; preds = %23
%34 = load i32*, i32** %3
%35 = load i32, i32* %34
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, %35
store i32 %37, i32* %4
br label %38
38: ; preds = %33, %28
br label %12
39: ; preds = %21
br label %40
40: ; preds = %39
%41 = load i32*, i32** %3
%42 = load i32, i32* %41
%43 = icmp ne i32 %42, 1
br i1 %43, label %6, label %44
44: ; preds = %40
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [21 x i8] c"input prime number: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @input_prime_number(i32* %0, i32 %1) {
br label %3
3: ; preds = %25, %2
%4 = phi i32 [ %1, %2 ], [ %27, %25 ]
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %0)
%7 = load i32, i32* %0
%8 = icmp eq i32 %7, %4
%9 = icmp eq i32 %7, 0
%10 = or i1 %9, %8
br i1 %10, label %25, label %11
11: ; preds = %3, %19
%12 = phi i32 [ %20, %19 ], [ %7, %3 ]
%13 = phi i32 [ %21, %19 ], [ %4, %3 ]
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = sub nsw i32 %12, %13
store i32 %16, i32* %0
br label %19
17: ; preds = %11
%18 = sub nsw i32 %13, %12
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ %12, %17 ]
%21 = phi i32 [ %13, %15 ], [ %18, %17 ]
%22 = icmp eq i32 %20, %21
%23 = icmp eq i32 %20, 0
%24 = or i1 %23, %22
br i1 %24, label %25, label %11
25: ; preds = %19, %3
%26 = phi i32 [ %7, %3 ], [ %20, %19 ]
%27 = phi i32 [ %4, %3 ], [ %21, %19 ]
%28 = icmp eq i32 %26, 1
br i1 %28, label %29, label %3
29: ; preds = %25
ret i32 %7
}