#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);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main() {
  int a = 0, b = 0, c = 0, d = 0;
  int N = -1;
  long int i = 0;
  scanf("%i %i %i %i", &a, &b, &c, &d);
  if (a != b) {
    for (i = a; i <= 1000000000; i += a) {
      if (i % b != 0 && c % i == 0 && d % i != 0) {
        N = (int)i;
        break;
      }
    }
  }
  printf("%d\n", N);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe9f(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11fe <main+0xde>
movslq -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x3b9aca00,-0x20(%rbp)
3b
jg     11f9 <main+0xd9>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     11e3 <main+0xc3>
movslq -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    11e3 <main+0xc3>
movslq -0x14(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
je     11e3 <main+0xc3>
mov    -0x20(%rbp),%rax
mov    %eax,-0x18(%rbp)
jmp    11f9 <main+0xd9>
jmp    11e8 <main+0xc8>
movslq -0x8(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    118a <main+0x6a>
jmp    11fe <main+0xde>
mov    -0x18(%rbp),%esi
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeb5(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <scanf@plt>
movslq 0x14(%rsp),%r9
movslq 0x10(%rsp),%rcx
mov    $0xffffffff,%esi
cmp    %ecx,%r9d
je     1244 <main+0x124>
cmp    $0x3b9aca00,%r9d
jg     1244 <main+0x124>
movslq 0xc(%rsp),%r10
movslq 0x8(%rsp),%r8
mov    %r9,%rdi
jmp    11b0 <main+0x90>
mov    %r8,%rax
cqto
idiv   %rdi
test   %rdx,%rdx
je     1230 <main+0x110>
jmp    1242 <main+0x122>
xchg   %ax,%ax
mov    %rdi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11d0 <main+0xb0>
mov    %rdi,%rax
cqto
idiv   %rcx
test   %rdx,%rdx
jne    11db <main+0xbb>
jmp    1230 <main+0x110>
nopl   0x0(%rax,%rax,1)
mov    %edi,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
je     1230 <main+0x110>
mov    %r10,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1200 <main+0xe0>
mov    %r10,%rax
cqto
idiv   %rdi
test   %rdx,%rdx
jne    1230 <main+0x110>
jmp    120c <main+0xec>
cs nopw 0x0(%rax,%rax,1)
mov    %r10d,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
jne    1230 <main+0x110>
mov    %r8,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    1198 <main+0x78>
mov    %r8d,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
jne    1242 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %r9,%rdi
cmp    $0x3b9aca01,%rdi
jl     11b0 <main+0x90>
jmp    1244 <main+0x124>
mov    %edi,%esi
lea    0xdc1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"%i %i %i %i\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %10, %11
br i1 %12, label %37, label %13
13: ; preds = %0
%14 = sext i32 %10 to i64
%15 = icmp slt i32 %10, 1000000001
br i1 %15, label %16, label %37
16: ; preds = %13
%17 = sext i32 %11 to i64
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
br label %22
22: ; preds = %16, %34
%23 = phi i64 [ %14, %16 ], [ %35, %34 ]
%24 = srem i64 %23, %17
%25 = icmp eq i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %22
%27 = srem i64 %19, %23
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = srem i64 %21, %23
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = trunc i64 %23 to i32
br label %37
34: ; preds = %22, %26, %29
%35 = add nsw i64 %23, %14
%36 = icmp slt i64 %35, 1000000001
br i1 %36, label %22, label %37
37: ; preds = %34, %13, %32, %0
%38 = phi i32 [ %33, %32 ], [ -1, %0 ], [ -1, %13 ], [ -1, %34 ]
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
ret i32 0
}