#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 main(int argc, char **argv) {
  int a, b, x, xmax, y, ymax, z, s;
  int OK = 0;
  printf("Inserire un numero: ");
  scanf("%d", &a);
  printf("Inserire un numero: ");
  scanf("%d", &b);
  printf("Inserire il valore obiettivo: ");
  scanf("%d", &z);
  if ((a <= 0) || (b <= 0) || (a == b) || (z <= 0)) {
    printf("Valore non vaido");
  } else {
    if (a > b) {
      y = b;
      x = a;
    } else {
      y = a;
      x = b;
    }
    if ((z >= x) || ((x % 2 == 0) && (y % 2 == 0) && (z % 2 != 0))) {
      printf("Valore non vaido");
    } else {
      printf("Caso: %d %d => %d \n", x, y, z);
      s = x;
      int i = 0;
      printf("%d\n", s);
      while (OK == 0) {
        if (s < y) {
          s = x - (y - s);
        } else {
          s = s - y;
        }
        printf("%d\n", s);
        if (s < 0) {
          printf("<0, Impossibile?\n");
          OK = 1;
        }
        if (s == z) {
          printf("Possibile!\n");
          OK = 1;
        }
        if (i > 25) {
          printf("Troppi step, Impossibile?\n");
          OK = 1;
        }
        i++;
      }
    }
  }
  return OK;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11c1 <main+0xa1>
cmpl   $0x0,-0x18(%rbp)
jle    11c1 <main+0xa1>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11c1 <main+0xa1>
cmpl   $0x0,-0x2c(%rbp)
jg     11d4 <main+0xb4>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1347 <main+0x227>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11f1 <main+0xd1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11fd <main+0xdd>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1245 <main+0x125>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1258 <main+0x138>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1258 <main+0x138>
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1258 <main+0x138>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1342 <main+0x222>
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
jne    133d <main+0x21d>
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12b6 <main+0x196>
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x30(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x30(%rbp)
jmp    12bf <main+0x19f>
mov    -0x30(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jge    12ef <main+0x1cf>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1310 <main+0x1f0>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
cmpl   $0x19,-0x38(%rbp)
jle    132f <main+0x20f>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    128d <main+0x16d>
jmp    1342 <main+0x222>
jmp    1347 <main+0x227>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rbp
lea    0x14(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
test   %eax,%eax
jle    11e4 <main+0xb4>
mov    0x10(%rsp),%ebx
test   %ebx,%ebx
jle    11e4 <main+0xb4>
cmp    %ebx,%eax
je     11e4 <main+0xb4>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    11e4 <main+0xb4>
cmp    %ebx,%eax
mov    %eax,%r13d
cmova  %ebx,%r13d
cmova  %eax,%ebx
cmp    %ebx,%ecx
jae    11d8 <main+0xa8>
test   $0x1,%bl
jne    1204 <main+0xd4>
mov    %r13d,%eax
and    $0x1,%eax
jne    1204 <main+0xd4>
mov    %ecx,%eax
and    $0x1,%eax
je     1204 <main+0xd4>
lea    0xe58(%rip),%rdi
xor    %r14d,%r14d
jmp    11eb <main+0xbb>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3d(%rip),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3e(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebx,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%r15d
sub    %r13d,%r15d
mov    $0x0,%r12d
cmovl  %ebx,%r12d
lea    (%r12,%r15,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r15d,%r12d
mov    $0x0,%eax
js     1290 <main+0x160>
cmp    0xc(%rsp),%r12d
jne    1280 <main+0x150>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x1,%ebp
cmp    $0x1a,%ebp
jae    12aa <main+0x17a>
test   %eax,%eax
je     1240 <main+0x110>
jmp    12b6 <main+0x186>
xchg   %ax,%ax
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
cmp    0xc(%rsp),%r12d
je     126f <main+0x13f>
jmp    1280 <main+0x150>
lea    0xdaf(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    11f2 <main+0xc2>

LLVM IR (-O0):
@.str = [21 x i8] c"Inserire un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Inserire il valore obiettivo: \00"
@.str.3 = [17 x i8] c"Valore non vaido\00"
@.str.4 = [20 x i8] c"Caso: %d %d => %d \0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [18 x i8] c"<0, Impossibile?\0A\00"
@.str.7 = [12 x i8] c"Possibile!\0A\00"
@.str.8 = [27 x i8] c"Troppi step, Impossibile?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%22 = load i32, i32* %6
%23 = icmp sle i32 %22, 0
br i1 %23, label %34, label %24
24: ; preds = %2
%25 = load i32, i32* %7
%26 = icmp sle i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp eq i32 %28, %29
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i32, i32* %12
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31, %27, %24, %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %112
36: ; preds = %31
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %7
store i32 %41, i32* %10
%42 = load i32, i32* %6
store i32 %42, i32* %8
br label %46
43: ; preds = %36
%44 = load i32, i32* %6
store i32 %44, i32* %10
%45 = load i32, i32* %7
store i32 %45, i32* %8
br label %46
46: ; preds = %43, %40
%47 = load i32, i32* %12
%48 = load i32, i32* %8
%49 = icmp sge i32 %47, %48
br i1 %49, label %62, label %50
50: ; preds = %46
%51 = load i32, i32* %8
%52 = srem i32 %51, 2
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %64
54: ; preds = %50
%55 = load i32, i32* %10
%56 = srem i32 %55, 2
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %54
%59 = load i32, i32* %12
%60 = srem i32 %59, 2
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %58, %46
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %111
64: ; preds = %58, %54, %50
%65 = load i32, i32* %8
%66 = load i32, i32* %10
%67 = load i32, i32* %12
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %65, i32 %66, i32 %67)
%69 = load i32, i32* %8
store i32 %69, i32* %13
store i32 0, i32* %15
%70 = load i32, i32* %13
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %107, %64
%73 = load i32, i32* %14
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %110
75: ; preds = %72
%76 = load i32, i32* %13
%77 = load i32, i32* %10
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %85
79: ; preds = %75
%80 = load i32, i32* %8
%81 = load i32, i32* %10
%82 = load i32, i32* %13
%83 = sub nsw i32 %81, %82
%84 = sub nsw i32 %80, %83
store i32 %84, i32* %13
br label %89
85: ; preds = %75
%86 = load i32, i32* %13
%87 = load i32, i32* %10
%88 = sub nsw i32 %86, %87
store i32 %88, i32* %13
br label %89
89: ; preds = %85, %79
%90 = load i32, i32* %13
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %90)
%92 = load i32, i32* %13
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %89
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %14
br label %96
96: ; preds = %94, %89
%97 = load i32, i32* %13
%98 = load i32, i32* %12
%99 = icmp eq i32 %97, %98
br i1 %99, label %100, label %102
100: ; preds = %96
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %14
br label %102
102: ; preds = %100, %96
%103 = load i32, i32* %15
%104 = icmp sgt i32 %103, 25
br i1 %104, label %105, label %107
105: ; preds = %102
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %14
br label %107
107: ; preds = %105, %102
%108 = load i32, i32* %15
%109 = add nsw i32 %108, 1
store i32 %109, i32* %15
br label %72
110: ; preds = %72
br label %111
111: ; preds = %110, %62
br label %112
112: ; preds = %111, %34
%113 = load i32, i32* %14
ret i32 %113
}

LLVM IR (-O2):
@.str = [21 x i8] c"Inserire un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Inserire il valore obiettivo: \00"
@.str.3 = [17 x i8] c"Valore non vaido\00"
@.str.4 = [20 x i8] c"Caso: %d %d => %d \0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str = [26 x i8] c"Troppi step, Impossibile?\00"
@str.9 = [11 x i8] c"Possibile!\00"
@str.10 = [17 x i8] c"<0, Impossibile?\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 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* %5)
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 1
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 1
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %25, label %20
20: ; preds = %2
%21 = icmp eq i32 %15, %17
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 1
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %27
25: ; preds = %20, %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %71
27: ; preds = %20
%28 = icmp ugt i32 %15, %17
%29 = select i1 %28, i32 %17, i32 %15
%30 = select i1 %28, i32 %15, i32 %17
%31 = icmp ult i32 %22, %30
br i1 %31, label %32, label %41
32: ; preds = %27
%33 = and i32 %30, 1
%34 = icmp ne i32 %33, 0
%35 = and i32 %29, 1
%36 = icmp ne i32 %35, 0
%37 = select i1 %34, i1 true, i1 %36
%38 = and i32 %22, 1
%39 = icmp eq i32 %38, 0
%40 = select i1 %37, i1 true, i1 %39
br i1 %40, label %43, label %41
41: ; preds = %32, %27
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %71
43: ; preds = %32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %29, i32 %22)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %46
46: ; preds = %43, %68
%47 = phi i32 [ 0, %43 ], [ %69, %68 ]
%48 = phi i32 [ %30, %43 ], [ %52, %68 ]
%49 = icmp slt i32 %48, %29
%50 = sub i32 %48, %29
%51 = select i1 %49, i32 %30, i32 0
%52 = add i32 %51, %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = icmp slt i32 %52, 0
br i1 %54, label %55, label %57
55: ; preds = %46
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
br label %57
57: ; preds = %55, %46
%58 = phi i32 [ 1, %55 ], [ 0, %46 ]
%59 = load i32, i32* %5
%60 = icmp eq i32 %52, %59
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
br label %63
63: ; preds = %61, %57
%64 = phi i32 [ 1, %61 ], [ %58, %57 ]
%65 = icmp ugt i32 %47, 25
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %71
68: ; preds = %63
%69 = add nuw nsw i32 %47, 1
%70 = icmp eq i32 %64, 0
br i1 %70, label %46, label %71
71: ; preds = %68, %66, %41, %25
%72 = phi i32 [ 0, %25 ], [ 0, %41 ], [ 1, %66 ], [ 1, %68 ]
ret i32 %72
}