#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 try_mfocrf(int);
int try_mtocrf(int);
int main(void) {
  int i, j;
  for (i = 0; i < 32; i++) {
    printf("0x%08x\n", try_mtocrf(1 << i));
  }
  printf("\n");
  j = 1;
  for (i = 0; i < 32; i++) {
    printf("0x%08x\n", try_mfocrf(j));
    j *= 3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    117d <main+0x4d>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1050 <try_mtocrf@plt>
mov    %eax,%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    11d0 <main+0xa0>
mov    -0xc(%rbp),%edi
call   1030 <try_mfocrf@plt>
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
imul   $0x3,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1199 <main+0x69>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    $0x1,%edi
mov    %ebp,%ecx
shl    %cl,%edi
call   1060 <try_mtocrf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x20,%ebp
jne    1150 <main+0x10>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x1,%ebx
mov    $0x20,%ebp
lea    0xe73(%rip),%r14
nopl   (%rax)
mov    %ebx,%edi
call   1030 <try_mfocrf@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rbx,%rbx,2),%ebx
add    $0xffffffff,%ebp
jne    1190 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"0x%08x\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 32
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %2
%9 = shl i32 1, %8
%10 = call i32 @try_mtocrf(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
store i32 0, i32* %2
br label %17
17: ; preds = %26, %15
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %3
%22 = call i32 @try_mfocrf(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 3
store i32 %25, i32* %3
br label %26
26: ; preds = %20
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %17
29: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"0x%08x\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %6, %1 ]
%3 = shl nuw i32 1, %2
%4 = tail call i32 @try_mtocrf(i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = add nuw nsw i32 %2, 1
%7 = icmp eq i32 %6, 32
br i1 %7, label %8, label %1
8: ; preds = %1
%9 = tail call i32 @putchar(i32 10)
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 1, %8 ], [ %15, %10 ]
%12 = phi i32 [ 0, %8 ], [ %16, %10 ]
%13 = tail call i32 @try_mfocrf(i32 %11)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = mul nsw i32 %11, 3
%16 = add nuw nsw i32 %12, 1
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %10
18: ; preds = %10
ret i32 0
}