#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 */
scalar_t__ ceil(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int G, B;
  scanf("%d", &G);
  scanf("%d", &B);
  while (G != -1 || B != -1) {
    if (G == 0) {
      printf("%d\n", B);
    } else if (B == 0) {
      printf("%d\n", G);
    } else {
      printf("%d\n",
             (G > B) ? (int)ceil(G / (B + 1.0f)) : (int)ceil(B / (G + 1.0f)));
    }
    scanf("%d", &G);
    scanf("%d", &B);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0xffffffff,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jne    1178 <main+0x48>
cmpl   $0xffffffff,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1188 <main+0x58>
jmp    125a <main+0x12a>
cmpl   $0x0,-0x8(%rbp)
jne    11a6 <main+0x76>
mov    -0xc(%rbp),%esi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
jmp    1235 <main+0x105>
cmpl   $0x0,-0xc(%rbp)
jne    11c4 <main+0x94>
mov    -0x8(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
jmp    1230 <main+0x100>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11fb <main+0xcb>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
movss  0xe1e(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
jmp    1221 <main+0xf1>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
movss  0xdf3(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
jmp    1235 <main+0x105>
lea    0xdc8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xdb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec5(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%esi
cmp    $0xffffffff,%eax
jne    116c <main+0x3c>
cmp    $0xffffffff,%esi
je     1201 <main+0xd1>
lea    0xe94(%rip),%r14
lea    0xe8a(%rip),%rbx
lea    0x4(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %eax,%eax
je     11d2 <main+0xa2>
test   %esi,%esi
je     11d0 <main+0xa0>
cmp    %esi,%eax
mov    %esi,%ecx
cmovg  %eax,%ecx
cmovg  %esi,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
addss  0xe48(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %rax,%rsi
jmp    11d2 <main+0xa2>
nopw   0x0(%rax,%rax,1)
mov    %eax,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%esi
cmp    $0xffffffff,%eax
jne    1190 <main+0x60>
cmp    $0xffffffff,%esi
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %54, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, -1
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ true, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %57
14: ; preds = %12
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %54
20: ; preds = %14
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %53
26: ; preds = %20
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to float
%33 = load i32, i32* %3
%34 = sitofp i32 %33 to float
%35 = fadd float %34, 1.000000e+00
%36 = fdiv float %32, %35
%37 = fptosi float %36 to i32
%38 = call i64 @ceil(i32 %37)
%39 = trunc i64 %38 to i32
br label %50
40: ; preds = %26
%41 = load i32, i32* %3
%42 = sitofp i32 %41 to float
%43 = load i32, i32* %2
%44 = sitofp i32 %43 to float
%45 = fadd float %44, 1.000000e+00
%46 = fdiv float %42, %45
%47 = fptosi float %46 to i32
%48 = call i64 @ceil(i32 %47)
%49 = trunc i64 %48 to i32
br label %50
50: ; preds = %40, %30
%51 = phi i32 [ %39, %30 ], [ %49, %40 ]
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %23
br label %54
54: ; preds = %53, %17
%55 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %6
57: ; preds = %12
ret i32 0
}

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