#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 */
double dfac(int);
unsigned long long fac(int);
int /*<<< orphan*/ printf(char *, int, unsigned long long, double);
int main(int argc, char *argv[]) {
  int n;
  for (n = 0; n < 180; n++) {
    unsigned long long f = fac(n);
    double df = dfac(n);
    printf("n=%10d f=%30llu df=%30e\n", n, f, df);
    if (f == 0 && df == 0) {
      break;
    }
  }
  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   $0x0,-0x14(%rbp)
cmpl   $0xb4,-0x14(%rbp)
jge    11c6 <main+0x96>
mov    -0x14(%rbp),%edi
call   1030 <fac@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <dfac@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11b3 <main+0x83>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b3 <main+0x83>
jp     11b3 <main+0x83>
jmp    11c6 <main+0x96>
jmp    11b8 <main+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xec6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <fac@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1050 <dfac@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1040 <printf@plt>
test   %r15,%r15
sete   %al
movsd  0x8(%rsp),%xmm0
ucomisd 0xe78(%rip),%xmm0
setnp  %cl
sete   %dl
and    %cl,%dl
test   %dl,%al
jne    11a1 <main+0x71>
lea    0x1(%rbx),%eax
cmp    $0xb3,%ebx
mov    %eax,%ebx
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"n=%10d f=%30llu df=%30e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 180
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = load i32, i32* %6
%14 = call i64 @fac(i32 %13)
store i64 %14, i64* %7
%15 = load i32, i32* %6
%16 = call double @dfac(i32 %15)
store double %16, double* %8
%17 = load i32, i32* %6
%18 = load i64, i64* %7
%19 = load double, double* %8
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %17, i64 %18, double %19)
%21 = load i64, i64* %7
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %12
%24 = load double, double* %8
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %23
br label %31
27: ; preds = %23, %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %9
31: ; preds = %26, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"n=%10d f=%30llu df=%30e\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %11, %3 ]
%5 = tail call i64 @fac(i32 %4)
%6 = tail call double @dfac(i32 %4)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %4, i64 %5, double %6)
%8 = icmp eq i64 %5, 0
%9 = fcmp oeq double %6, 0.000000e+00
%10 = and i1 %8, %9
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 180
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %3
14: ; preds = %3
ret i32 0
}