#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void f2m_print_human(uint32_t t, uint32_t *A) {
  uint32_t i;
  bool first = true;
  printf("f(z) = ");
  for (i = t; i > 0;) {
    i--;
    uint32_t j;
    uint32_t mask = 0x80000000;
    for (j = 0; j < 32; j++) {
      if (A[i] & (mask >> j)) {
        if (first) {
          first = false;
        } else {
          printf(" + ");
        }
        int exp = i * 32 + (31 - j);
        if (exp == 0) {
          printf("1");
        } else if (exp == 1) {
          printf("z");
        } else {
          printf("z^%d", exp);
        }
      }
    }
  }
  if (first) {
    printf("0");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<f2m_print_human>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1229 <f2m_print_human+0x119>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
movl   $0x80000000,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    1224 <f2m_print_human+0x114>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1211 <f2m_print_human+0x101>
cmpl   $0x0,-0x18(%rbp)
je     119b <f2m_print_human+0x8b>
movl   $0x0,-0x18(%rbp)
jmp    11a9 <f2m_print_human+0x99>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
shl    $0x5,%eax
mov    $0x1f,%ecx
sub    -0x1c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11d9 <f2m_print_human+0xc9>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <f2m_print_human+0xfc>
cmpl   $0x1,-0x24(%rbp)
jne    11f6 <f2m_print_human+0xe6>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <f2m_print_human+0xf7>
mov    -0x24(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <f2m_print_human+0xfc>
jmp    1211 <f2m_print_human+0x101>
jmp    1216 <f2m_print_human+0x106>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <f2m_print_human+0x4b>
jmp    113a <f2m_print_human+0x2a>
cmpl   $0x0,-0x18(%rbp)
je     1241 <f2m_print_human+0x131>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2m_print_human>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r13
mov    %edi,%r12d
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jle    11ff <f2m_print_human+0xdf>
mov    %r12d,%eax
shl    $0x5,%r12d
add    $0xffffffff,%r12d
mov    $0x1,%r14d
jmp    1175 <f2m_print_human+0x55>
xchg   %ax,%ax
add    $0xffffffe0,%r12d
cmpq   $0x2,0x8(%rsp)
mov    0x10(%rsp),%rax
jl     11fa <f2m_print_human+0xda>
mov    %rax,0x8(%rsp)
add    $0xffffffffffffffff,%rax
mov    %rax,0x10(%rsp)
mov    %eax,%r15d
mov    %r12d,%ebp
xor    %ebx,%ebx
jmp    11a8 <f2m_print_human+0x88>
nopl   (%rax)
mov    $0x31,%edi
call   1030 <putchar@plt>
xor    %r14d,%r14d
add    $0x1,%ebx
add    $0xffffffff,%ebp
cmp    $0x20,%ebx
je     1160 <f2m_print_human+0x40>
mov    $0x80000000,%eax
mov    %ebx,%ecx
sar    %cl,%eax
test   %eax,0x0(%r13,%r15,4)
je     119d <f2m_print_human+0x7d>
test   %r14d,%r14d
je     11e0 <f2m_print_human+0xc0>
cmp    $0x1,%ebp
je     11f3 <f2m_print_human+0xd3>
test   %ebp,%ebp
je     1190 <f2m_print_human+0x70>
xor    %r14d,%r14d
lea    0xe3c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119d <f2m_print_human+0x7d>
nopl   0x0(%rax,%rax,1)
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebp
jne    11c2 <f2m_print_human+0xa2>
mov    $0x7a,%edi
jmp    1195 <f2m_print_human+0x75>
test   %r14d,%r14d
je     1209 <f2m_print_human+0xe9>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"f(z) = \00"
@.str.1 = [4 x i8] c" + \00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"z\00"
@.str.4 = [5 x i8] c"z^%d\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @f2m_print_human(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 1, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %3
store i32 %11, i32* %5
br label %12
12: ; preds = %62, %2
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %63
15: ; preds = %12
%16 = load i32, i32* %5
%17 = add nsw i32 %16, -1
store i32 %17, i32* %5
store i32 -2147483648, i32* %8
store i32 0, i32* %7
br label %18
18: ; preds = %59, %15
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 32
br i1 %20, label %21, label %62
21: ; preds = %18
%22 = load i32*, i32** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = ashr i32 %27, %28
%30 = and i32 %26, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %58
32: ; preds = %21
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 0, i32* %6
br label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
%39 = load i32, i32* %5
%40 = mul nsw i32 %39, 32
%41 = load i32, i32* %7
%42 = sub nsw i32 31, %41
%43 = add nsw i32 %40, %42
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %57
48: ; preds = %38
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
53: ; preds = %48
%54 = load i32, i32* %9
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %51
br label %57
57: ; preds = %56, %46
br label %58
58: ; preds = %57, %21
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %18
62: ; preds = %18
br label %12
63: ; preds = %12
%64 = load i32, i32* %6
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"f(z) = \00"
@.str.1 = [4 x i8] c" + \00"
@.str.4 = [5 x i8] c"z^%d\00"
define void @f2m_print_human(i32 %0, i32* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %43
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %9
7: ; preds = %37
%8 = icmp sgt i64 %10, 1
br i1 %8, label %9, label %41
9: ; preds = %5, %7
%10 = phi i64 [ %6, %5 ], [ %12, %7 ]
%11 = phi i32 [ 1, %5 ], [ %38, %7 ]
%12 = add nsw i64 %10, -1
%13 = trunc i64 %12 to i32
%14 = and i64 %12, 4294967295
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = shl nsw i32 %13, 5
br label %17
17: ; preds = %9, %37
%18 = phi i32 [ %11, %9 ], [ %38, %37 ]
%19 = phi i32 [ 0, %9 ], [ %39, %37 ]
%20 = load i32, i32* %15
%21 = ashr i32 -2147483648, %19
%22 = and i32 %20, %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %17
%25 = icmp eq i32 %18, 0
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %24, %26
%29 = sub nuw nsw i32 31, %19
%30 = add nuw nsw i32 %29, %16
switch i32 %30, label %35 [
i32 0, label %31
i32 1, label %33
]
31: ; preds = %28
%32 = tail call i32 @putchar(i32 49)
br label %37
33: ; preds = %28
%34 = tail call i32 @putchar(i32 122)
br label %37
35: ; preds = %28
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %30)
br label %37
37: ; preds = %31, %35, %33, %17
%38 = phi i32 [ %18, %17 ], [ 0, %33 ], [ 0, %35 ], [ 0, %31 ]
%39 = add nuw nsw i32 %19, 1
%40 = icmp eq i32 %39, 32
br i1 %40, label %7, label %17
41: ; preds = %7
%42 = icmp eq i32 %38, 0
br i1 %42, label %45, label %43
43: ; preds = %2, %41
%44 = tail call i32 @putchar(i32 48)
br label %45
45: ; preds = %43, %41
%46 = tail call i32 @putchar(i32 10)
ret void
}