#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int step(int, int /*<<< orphan*/);
int main(void) {
  int iNumber;
  scanf("%d", &iNumber);
  if (iNumber > 9999 || iNumber == 0000 || iNumber == 1111 || iNumber == 2222 ||
      iNumber == 3333 || iNumber == 4444 || iNumber == 5555 ||
      iNumber == 6666 || iNumber == 7777 || iNumber == 8888 ||
      iNumber == 9999) {
    return 1;
  }
  int iter = 0;
  if (iNumber != 6174) {
    iter = step(iNumber, 0);
  }
  printf("%d iterations.\n", iter);
  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   1050 <scanf@plt>
cmpl   $0x270f,-0x8(%rbp)
jg     11db <main+0xab>
cmpl   $0x0,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x457,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x8ae,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0xd05,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x115c,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x15b3,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x1a0a,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x1e61,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x22b8,-0x8(%rbp)
je     11db <main+0xab>
cmpl   $0x270f,-0x8(%rbp)
jne    11e7 <main+0xb7>
movl   $0x1,-0x4(%rbp)
jmp    121e <main+0xee>
movl   $0x0,-0xc(%rbp)
cmpl   $0x181e,-0x8(%rbp)
je     1208 <main+0xd8>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <step@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%eax
cmp    $0x270f,%edi
jle    1155 <main+0x25>
pop    %rcx
ret
cmp    $0x15b2,%edi
jle    1181 <main+0x51>
cmp    $0x1e60,%edi
jg     11a3 <main+0x73>
cmp    $0x15b3,%edi
je     1153 <main+0x23>
xor    %esi,%esi
cmp    $0x181e,%edi
je     11d2 <main+0xa2>
cmp    $0x1a0a,%edi
je     1153 <main+0x23>
jmp    11c9 <main+0x99>
cmp    $0x8ad,%edi
jle    11bd <main+0x8d>
cmp    $0x8ae,%edi
je     1153 <main+0x23>
cmp    $0xd05,%edi
je     1153 <main+0x23>
cmp    $0x115c,%edi
je     1153 <main+0x23>
jmp    11c9 <main+0x99>
cmp    $0x1e61,%edi
je     1153 <main+0x23>
cmp    $0x22b8,%edi
je     1153 <main+0x23>
cmp    $0x270f,%edi
je     1153 <main+0x23>
jmp    11c9 <main+0x99>
test   %edi,%edi
je     1153 <main+0x23>
cmp    $0x457,%edi
je     1153 <main+0x23>
xor    %esi,%esi
call   1040 <step@plt>
mov    %eax,%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [16 x i8] c"%d iterations.\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 = load i32, i32* %2
%6 = icmp sgt i32 %5, 9999
br i1 %6, label %37, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %37, label %10
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 1111
br i1 %12, label %37, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 2222
br i1 %15, label %37, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 3333
br i1 %18, label %37, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 4444
br i1 %21, label %37, label %22
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 5555
br i1 %24, label %37, label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 6666
br i1 %27, label %37, label %28
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 7777
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 8888
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 9999
br i1 %36, label %37, label %38
37: ; preds = %34, %31, %28, %25, %22, %19, %16, %13, %10, %7, %0
store i32 1, i32* %1
br label %47
38: ; preds = %34
store i32 0, i32* %3
%39 = load i32, i32* %2
%40 = icmp ne i32 %39, 6174
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %2
%43 = call i32 @step(i32 %42, i32 0)
store i32 %43, i32* %3
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %3
%46 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %45)
store i32 0, i32* %1
br label %47
47: ; preds = %44, %37
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [16 x i8] c"%d iterations.\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 = load i32, i32* %1
%5 = freeze i32 %4
%6 = icmp sgt i32 %5, 9999
br i1 %6, label %13, label %7
7: ; preds = %0
switch i32 %5, label %8 [
i32 9999, label %13
i32 8888, label %13
i32 7777, label %13
i32 6666, label %13
i32 5555, label %13
i32 4444, label %13
i32 3333, label %13
i32 2222, label %13
i32 1111, label %13
i32 0, label %13
i32 6174, label %10
]
8: ; preds = %7
%9 = call i32 @step(i32 %5, i32 0)
br label %10
10: ; preds = %7, %8
%11 = phi i32 [ %9, %8 ], [ 0, %7 ]
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %7, %7, %7, %7, %7, %7, %7, %7, %7, %7, %0, %10
%14 = phi i32 [ 0, %10 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %7 ], [ 1, %0 ]
ret i32 %14
}