#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 euclidesExt(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int i, a, b, d, n, x, y;
  printf("Digite o valor de A: ");
  scanf("%i", &a);
  printf("Digite o valor de B: ");
  scanf("%i", &b);
  printf("Digite o valor de n: ");
  scanf("%i", &n);
  d = euclidesExt(a, n, &x, &y);
  if (b % d == 0) {
    x = x * (b / d) % n;
    for (i = 0; i < d; i++) {
      printf("X= %i\n", (x + (i + 1) * (n / d)) % n);
    }
  } else {
    printf("Sem solucao\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <euclidesExt@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    122b <main+0xfb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1226 <main+0xf6>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
mov    -0x14(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%edx
mov    -0x24(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11db <main+0xab>
jmp    1239 <main+0x109>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
lea    0x4(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1040 <euclidesExt@plt>
mov    %eax,%r15d
mov    0xc(%rsp),%eax
cltd
idiv   %r15d
test   %edx,%edx
je     11df <main+0x9f>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
imul   0x4(%rsp),%eax
mov    0x8(%rsp),%ecx
cltd
idiv   %ecx
mov    %edx,0x4(%rsp)
test   %r15d,%r15d
jle    11d4 <main+0x94>
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %r15d
add    %esi,%eax
cltd
idiv   %ecx
lea    0xe3d(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%r15d
je     11d4 <main+0x94>
mov    %r15d,%ebx
neg    %ebx
mov    $0x2,%ebp
lea    0xe1d(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %r15d
imul   %ebp,%eax
add    0x4(%rsp),%eax
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1230 <main+0xf0>
jmp    11d4 <main+0x94>

LLVM IR (-O0):
@.str = [22 x i8] c"Digite o valor de A: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [22 x i8] c"Digite o valor de B: \00"
@.str.3 = [22 x i8] c"Digite o valor de n: \00"
@.str.4 = [7 x i8] c"X= %i\0A\00"
@.str.5 = [13 x i8] c"Sem solucao\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %2
%15 = load i32, i32* %5
%16 = call i32 @euclidesExt(i32 %14, i32 %15, i32* %6, i32* %7)
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %0
%22 = load i32, i32* %6
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sdiv i32 %23, %24
%26 = mul nsw i32 %22, %25
%27 = load i32, i32* %5
%28 = srem i32 %26, %27
store i32 %28, i32* %6
store i32 0, i32* %1
br label %29
29: ; preds = %45, %21
%30 = load i32, i32* %1
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %48
33: ; preds = %29
%34 = load i32, i32* %6
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = sdiv i32 %37, %38
%40 = mul nsw i32 %36, %39
%41 = add nsw i32 %34, %40
%42 = load i32, i32* %5
%43 = srem i32 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %33
%46 = load i32, i32* %1
%47 = add nsw i32 %46, 1
store i32 %47, i32* %1
br label %29
48: ; preds = %29
br label %51
49: ; preds = %0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %51
51: ; preds = %49, %48
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Digite o valor de A: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [22 x i8] c"Digite o valor de B: \00"
@.str.3 = [22 x i8] c"Digite o valor de n: \00"
@.str.4 = [7 x i8] c"X= %i\0A\00"
@str = [12 x i8] c"Sem solucao\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %1
%18 = load i32, i32* %3
%19 = call i32 @euclidesExt(i32 %17, i32 %18, i32* %4, i32* %5)
%20 = load i32, i32* %2
%21 = srem i32 %20, %19
%22 = sdiv i32 %20, %19
%23 = icmp eq i32 %21, 0
br i1 %23, label %24, label %47
24: ; preds = %0
%25 = load i32, i32* %4
%26 = mul nsw i32 %22, %25
%27 = load i32, i32* %3
%28 = srem i32 %26, %27
store i32 %28, i32* %4
%29 = icmp sgt i32 %19, 0
br i1 %29, label %30, label %49
30: ; preds = %24
%31 = sdiv i32 %27, %19
%32 = add nsw i32 %31, %28
%33 = srem i32 %32, %27
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = icmp eq i32 %19, 1
br i1 %35, label %49, label %36
36: ; preds = %30, %36
%37 = phi i32 [ %40, %36 ], [ 1, %30 ]
%38 = load i32, i32* %4
%39 = load i32, i32* %3
%40 = add nuw nsw i32 %37, 1
%41 = sdiv i32 %39, %19
%42 = mul nsw i32 %41, %40
%43 = add nsw i32 %42, %38
%44 = srem i32 %43, %39
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = icmp eq i32 %40, %19
br i1 %46, label %49, label %36
47: ; preds = %0
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %36, %30, %24, %47
ret void
}