#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__ isright(int, int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *);
int main() {
  int n, m;
  while (scanf("%d", &n) != -1) {
    if (!n)
      break;
    for (m = 1; m < n; m++)
      if (isright(n, m))
        break;
    printf("%d\n", m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0xffffffff,%eax
je     11bb <main+0x8b>
cmpl   $0x0,-0x8(%rbp)
jne    1167 <main+0x37>
jmp    11bb <main+0x8b>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a7 <main+0x77>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <isright@plt>
cmp    $0x0,%rax
je     1194 <main+0x64>
jmp    11a7 <main+0x77>
jmp    1199 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <main+0x3e>
mov    -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0xffffffff,%eax
je     11b9 <main+0x89>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     11b9 <main+0x89>
lea    0xea7(%rip),%r14
lea    0xe9d(%rip),%r15
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     1197 <main+0x67>
mov    $0x1,%ebp
nop
mov    %ebp,%esi
call   1050 <isright@plt>
test   %rax,%rax
jne    1197 <main+0x67>
add    $0x1,%ebp
mov    0x4(%rsp),%edi
cmp    %edi,%ebp
jl     1180 <main+0x50>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    $0xffffffff,%eax
je     11b9 <main+0x89>
mov    0x4(%rsp),%edi
test   %edi,%edi
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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
br label %4
4: ; preds = %26, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp ne i32 %5, -1
br i1 %6, label %7, label %29
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %7
br label %29
11: ; preds = %7
store i32 1, i32* %3
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i64 @isright(i32 %17, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %12
26: ; preds = %21, %12
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %4
29: ; preds = %10, %4
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 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp ne i32 %3, -1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %28
8: ; preds = %0, %20
%9 = phi i32 [ %25, %20 ], [ %5, %0 ]
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %20
11: ; preds = %8, %16
%12 = phi i32 [ %18, %16 ], [ %9, %8 ]
%13 = phi i32 [ %17, %16 ], [ 1, %8 ]
%14 = call i64 @isright(i32 %12, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = add nuw nsw i32 %13, 1
%18 = load i32, i32* %1
%19 = icmp slt i32 %17, %18
br i1 %19, label %11, label %20
20: ; preds = %16, %11, %8
%21 = phi i32 [ 1, %8 ], [ %13, %11 ], [ %17, %16 ]
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%24 = icmp ne i32 %23, -1
%25 = load i32, i32* %1
%26 = icmp ne i32 %25, 0
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %8, label %28
28: ; preds = %20, %0
ret i32 0
}