#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 isHappy(int);
int /*<<< orphan*/ printf(char *, int, ...);
int rand();
int main() {
  int i = 0;
  printf("The number 19 is a happy number, %d\n", isHappy(19));
  for (i; i < 10; i++) {
    int n = rand() % 10000;
    printf("The number %d is a happy number, %d\n", n, isHappy(n));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x13,%edi
call   1030 <isHappy@plt>
mov    %eax,%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jge    11ab <main+0x7b>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <isHappy@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1160 <main+0x30>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x13,%edi
call   1030 <isHappy@plt>
lea    0xebb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
lea    0xea3(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <isHappy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"The number 19 is a happy number, %d\0A\00"
@.str.1 = [37 x i8] c"The number %d is a happy number, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @isHappy(i32 19)
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* %2
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 10000
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = call i32 @isHappy(i32 %14)
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %7
20: ; preds = %7
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [37 x i8] c"The number 19 is a happy number, %d\0A\00"
@.str.1 = [37 x i8] c"The number %d is a happy number, %d\0A\00"
define i32 @main() {
%1 = tail call i32 @isHappy(i32 19)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 10000
%5 = tail call i32 @isHappy(i32 %4)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %5)
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 10000
%9 = tail call i32 @isHappy(i32 %8)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 10000
%13 = tail call i32 @isHappy(i32 %12)
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 10000
%17 = tail call i32 @isHappy(i32 %16)
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 10000
%21 = tail call i32 @isHappy(i32 %20)
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 10000
%25 = tail call i32 @isHappy(i32 %24)
%26 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 10000
%29 = tail call i32 @isHappy(i32 %28)
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 10000
%33 = tail call i32 @isHappy(i32 %32)
%34 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33)
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 10000
%37 = tail call i32 @isHappy(i32 %36)
%38 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37)
%39 = tail call i32 (...) @rand()
%40 = srem i32 %39, 10000
%41 = tail call i32 @isHappy(i32 %40)
%42 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41)
ret i32 0
}