#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 */
unsigned int nseq(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int main(void) {
  unsigned int i, m = 0, im = 0;
  for (i = 1; i < 500000; i++) {
    unsigned int k = nseq(i);
    if (k > m) {
      m = k;
      im = i;
      printf("sequence length = %u for %u\n", m, im);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x7a120,-0x8(%rbp)
jae    1199 <main+0x79>
mov    -0x8(%rbp),%edi
call   1040 <nseq@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jbe    1186 <main+0x66>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <main+0x6b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r15d,%r15d
mov    $0x1,%ebx
lea    0xeca(%rip),%r14
jmp    114b <main+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x7a120,%ebx
je     116a <main+0x4a>
mov    %ebx,%edi
call   1040 <nseq@plt>
cmp    %r15d,%eax
jbe    1140 <main+0x20>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %ebp,%r15d
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"sequence length = %u for %u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %2
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %2
%8 = icmp ult i32 %7, 500000
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 @nseq(i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp ugt i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = load i32, i32* %5
store i32 %16, i32* %3
%17 = load i32, i32* %2
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %15, %9
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = add i32 %23, 1
store i32 %24, i32* %2
br label %6
25: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"sequence length = %u for %u\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %8
%2 = phi i32 [ 1, %0 ], [ %10, %8 ]
%3 = phi i32 [ 0, %0 ], [ %9, %8 ]
%4 = tail call i32 @nseq(i32 %2)
%5 = icmp ugt i32 %4, %3
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %2)
br label %8
8: ; preds = %6, %1
%9 = phi i32 [ %4, %6 ], [ %3, %1 ]
%10 = add nuw nsw i32 %2, 1
%11 = icmp eq i32 %10, 500000
br i1 %11, label %12, label %1
12: ; preds = %8
ret i32 0
}