#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int xeuclid(int, int, int *, int *);
int main(void) {
  int a, b, x, y, gcd;
  printf("Enter the number whose coprime you would like to find: ");
  scanf("%d", &a);
  for (b = 100; b < 200; b++) {
    gcd = xeuclid(a, b, &x, &y);
    if (gcd == 1) {
      break;
    }
  }
  printf("\t (1) %d is a number in the range [100, 200] that is relatively "
         "prime to %d\n",
         b, a);
  printf("\t (2) The coeffiecients x and y in gcd(%d, %d) = 1 = (%d * x) + (%d "
         "* y) are: \n",
         a, b, a, b);
  printf("\t\tx = %d\n\t\ty = %d\n", x, y);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x64,-0xc(%rbp)
cmpl   $0xc8,-0xc(%rbp)
jge    11b9 <main+0x79>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1030 <xeuclid@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11a6 <main+0x66>
jmp    11b9 <main+0x79>
jmp    11ab <main+0x6b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x34>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x64,%ebx
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <xeuclid@plt>
cmp    $0x1,%eax
je     11a6 <main+0x66>
add    $0x1,%ebx
cmp    $0xc8,%ebx
jne    1180 <main+0x40>
mov    $0xc8,%ebx
mov    0x4(%rsp),%edx
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ecx
lea    0xec3(%rip),%rdi
mov    %ecx,%esi
mov    %ebx,%edx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xef6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"Enter the number whose coprime you would like to find: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [77 x i8] c"\09 (1) %d is a number in the range [100, 200] that is relatively prime to %d\0A\00"
@.str.3 = [80 x i8] c"\09 (2) The coeffiecients x and y in gcd(%d, %d) = 1 = (%d * x) + (%d * y) are: \0A\00"
@.str.4 = [19 x i8] c"\09\09x = %d\0A\09\09y = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 100, i32* %3
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 200
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @xeuclid(i32 %13, i32 %14, i32* %4, i32* %5)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %12
br label %23
19: ; preds = %12
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %9
23: ; preds = %18, %9
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33)
%35 = load i32, i32* @EXIT_SUCCESS
%36 = call i32 @exit(i32 %35)
unreachable
}

LLVM IR (-O2):
@.str = [56 x i8] c"Enter the number whose coprime you would like to find: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [77 x i8] c"\09 (1) %d is a number in the range [100, 200] that is relatively prime to %d\0A\00"
@.str.3 = [80 x i8] c"\09 (2) The coeffiecients x and y in gcd(%d, %d) = 1 = (%d * x) + (%d * y) are: \0A\00"
@.str.4 = [19 x i8] c"\09\09x = %d\0A\09\09y = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %0, %14
%10 = phi i32 [ 100, %0 ], [ %15, %14 ]
%11 = load i32, i32* %1
%12 = call i32 @xeuclid(i32 %11, i32 %10, i32* %2, i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = add nuw nsw i32 %10, 1
%16 = icmp eq i32 %15, 200
br i1 %16, label %17, label %9
17: ; preds = %9, %14
%18 = phi i32 [ %10, %9 ], [ 200, %14 ]
%19 = load i32, i32* %1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %18, i32 %21, i32 %18)
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}