#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 atoi(char *);
int count_421(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char **argv) {
  int n = 10;
  int i, v;
  int max_i, max_v;
  if (argc > 1) {
    n = atoi(argv[1]);
  }
  max_i = 1;
  max_v = 0;
  for (i = 2; i <= n; i++) {
    v = count_421(i);
    if (v >= max_v) {
      max_i = i;
      max_v = v;
    }
  }
  printf("%d: %d\n", max_i, max_v);
  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)
movl   $0xa,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11be <main+0x8e>
mov    -0x18(%rbp),%edi
call   1040 <count_421@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     11ab <main+0x7b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11b0 <main+0x80>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117c <main+0x4c>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xa,%r14d
cmp    $0x2,%edi
jl     115d <main+0x2d>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
cmp    $0x2,%eax
jge    115d <main+0x2d>
xor    %ebp,%ebp
mov    $0x1,%r15d
jmp    1193 <main+0x63>
neg    %r14d
mov    $0x2,%ebx
mov    $0x1,%r15d
xor    %ebp,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1040 <count_421@plt>
cmp    %ebp,%eax
cmovge %ebx,%r15d
cmovge %eax,%ebp
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <main+0x40>
lea    0xe66(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%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
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
br label %18
18: ; preds = %13, %2
store i32 1, i32* %9
store i32 0, i32* %10
store i32 2, i32* %7
br label %19
19: ; preds = %33, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i32, i32* %7
%25 = call i32 @count_421(i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = load i32, i32* %10
%28 = icmp sge i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* %7
store i32 %30, i32* %9
%31 = load i32, i32* %8
store i32 %31, i32* %10
br label %32
32: ; preds = %29, %23
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %19
36: ; preds = %19
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 2
br i1 %8, label %21, label %9
9: ; preds = %2, %4
%10 = phi i32 [ %7, %4 ], [ 10, %2 ]
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ %18, %11 ], [ 0, %9 ]
%13 = phi i32 [ %17, %11 ], [ 1, %9 ]
%14 = phi i32 [ %19, %11 ], [ 2, %9 ]
%15 = tail call i32 @count_421(i32 %14)
%16 = icmp slt i32 %15, %12
%17 = select i1 %16, i32 %13, i32 %14
%18 = select i1 %16, i32 %12, i32 %15
%19 = add nuw i32 %14, 1
%20 = icmp eq i32 %14, %10
br i1 %20, label %21, label %11
21: ; preds = %11, %4
%22 = phi i32 [ 1, %4 ], [ %17, %11 ]
%23 = phi i32 [ 0, %4 ], [ %18, %11 ]
%24 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
ret i32 0
}