#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 *, unsigned int, int);
scalar_t__ scanf(char *, unsigned int *);
int test(unsigned int);
int main() {
  int i, ans;
  unsigned int n = 0;
  while (scanf("%d", &n)) {
    if (n == 0)
      break;
    ans = test(n);
    printf("f91(%d) = %d\n", n, ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     1191 <main+0x61>
cmpl   $0x0,-0x10(%rbp)
jne    116f <main+0x3f>
jmp    1191 <main+0x61>
mov    -0x10(%rbp),%edi
call   1050 <test@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     11ab <main+0x7b>
mov    0xc(%rsp),%edi
test   %edi,%edi
je     11ab <main+0x7b>
lea    0xe9d(%rip),%r14
lea    0xe93(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1050 <test@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     11ab <main+0x7b>
mov    0xc(%rsp),%edi
test   %edi,%edi
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"f91(%d) = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %12, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %18
12: ; preds = %8
%13 = load i32, i32* %4
%14 = call i32 @test(i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
br label %5
18: ; preds = %11, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"f91(%d) = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp eq i64 %3, 0
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %18, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %15, %8 ], [ %5, %0 ]
%10 = call i32 @test(i32 %9)
%11 = load i32, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %10)
%13 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%14 = icmp eq i64 %13, 0
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %18, label %8
18: ; preds = %8, %0
ret i32 0
}