#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int max_cycle_length(int, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ swap(int *, int *);
int main(int argc, char **argv) {
  int start, end;
  int orig_start, orig_end;
  if (argc != 2) {
    printf("Usage: %s INPUT_FILE\n\n", argv[0]);
    exit(-1);
  }
  if (access(argv[1], F_OK)) {
    printf("Error: INPUT_FILE %s does not exist\n\n", argv[1]);
    exit(-1);
  }
  freopen(argv[1], "r", stdin);
  while (scanf("%d %d", &start, &end) == 2) {
    orig_start = start;
    orig_end = end;
    if (start > end)
      swap(&start, &end);
    printf("%d %d %d\n", orig_start, orig_end, max_cycle_length(start, end));
  }
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bf <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0x0,%rax
je     11ff <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
lea    0xe26(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe1c(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    1290 <main+0x110>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    125e <main+0xde>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <swap@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <max_cycle_length@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121c <main+0x9c>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    126a <main+0xea>
mov    0x8(%rbx),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
mov    0x8(%rbx),%rcx
test   %rax,%rax
jne    1276 <main+0xf6>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rsi
mov    %rcx,%rdi
call   1050 <freopen@plt>
lea    0xe6a(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    124b <main+0xcb>
lea    0x4(%rsp),%r14
mov    %rsp,%r13
lea    0xe4f(%rip),%r15
lea    0xe42(%rip),%r12
jmp    1228 <main+0xa8>
nop
call   1060 <max_cycle_length@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    124b <main+0xcb>
mov    0x4(%rsp),%ebp
mov    (%rsp),%ebx
mov    %ebx,%esi
mov    %ebp,%edi
cmp    %ebx,%ebp
jle    1200 <main+0x80>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <swap@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
jmp    1200 <main+0x80>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd8c(%rip),%rdi
jmp    1280 <main+0x100>
lea    0xd9a(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [10 x i8] c"%d %d %d\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @F_OK
%23 = call i64 @access(i8* %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %18
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* @stdin
%36 = call i32 @freopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %48, %31
%38 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %7)
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %55
40: ; preds = %37
%41 = load i32, i32* %6
store i32 %41, i32* %8
%42 = load i32, i32* %7
store i32 %42, i32* %9
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 @swap(i32* %6, i32* %7)
br label %48
48: ; preds = %46, %40
%49 = load i32, i32* %8
%50 = load i32, i32* %9
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = call i32 @max_cycle_length(i32 %51, i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %49, i32 %50, i32 %53)
br label %37
55: ; preds = %37
%56 = load i32, i32* @stdin
%57 = call i32 @fclose(i32 %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @F_OK
%16 = tail call i64 @access(i8* %14, i32 %15)
%17 = icmp eq i64 %16, 0
%18 = load i8*, i8** %13
br i1 %17, label %22, label %19
19: ; preds = %12
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %12
%23 = load i32, i32* @stdin
%24 = tail call i32 @freopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %42
27: ; preds = %22, %35
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call i32 @swap(i32* %3, i32* %4)
%33 = load i32, i32* %3
%34 = load i32, i32* %4
br label %35
35: ; preds = %31, %27
%36 = phi i32 [ %34, %31 ], [ %29, %27 ]
%37 = phi i32 [ %33, %31 ], [ %28, %27 ]
%38 = call i32 @max_cycle_length(i32 %37, i32 %36)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 %29, i32 %38)
%40 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%41 = icmp eq i32 %40, 2
br i1 %41, label %27, label %42
42: ; preds = %35, %22
%43 = load i32, i32* @stdin
%44 = call i32 @fclose(i32 %43)
ret i32 0
}