#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 *, ...);
void bigint_print(const unsigned char *x, unsigned long xlen) {
  long i;
  printf("(");
  for (i = xlen - 1; i > 0; i--)
    printf("%u*2^(%u) + ", x[i], xlen - 1 - i);
  printf("%u*2^(%u))", x[0], xlen - 1);
}


x86 assembly (clang, -O0):
<bigint_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    117c <bigint_print+0x6c>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
sub    -0x18(%rbp),%rdx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <bigint_print+0x2a>
mov    -0x8(%rbp),%rax
movzbl (%rax),%esi
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bigint_print>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
mov    %rdi,%r15
mov    $0x28,%edi
call   1030 <putchar@plt>
lea    -0x1(%r13),%r14
test   %r14,%r14
jle    1171 <bigint_print+0x51>
lea    0xeb7(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%r15,%r13,1),%esi
mov    %r12,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%r13
add    $0x1,%rbx
cmp    $0x1,%r13
ja     1150 <bigint_print+0x30>
movzbl (%r15),%esi
lea    0xe91(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [13 x i8] c"%u*2^(%u) + \00"
@.str.2 = [11 x i8] c"%u*2^(%u))\00"
define void @bigint_print(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* %4
%8 = sub i64 %7, 1
store i64 %8, i64* %5
br label %9
9: ; preds = %23, %2
%10 = load i64, i64* %5
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = load i64, i64* %5
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = load i64, i64* %4
%19 = sub i64 %18, 1
%20 = load i64, i64* %5
%21 = sub i64 %19, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %17, i64 %21)
br label %23
23: ; preds = %12
%24 = load i64, i64* %5
%25 = add nsw i64 %24, -1
store i64 %25, i64* %5
br label %9
26: ; preds = %9
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = load i64, i64* %4
%32 = sub i64 %31, 1
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %30, i64 %32)
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"%u*2^(%u) + \00"
@.str.2 = [11 x i8] c"%u*2^(%u))\00"
define void @bigint_print(i8* nocapture %0, i64 %1) {
%3 = tail call i32 @putchar(i32 40)
%4 = add i64 %1, -1
%5 = icmp sgt i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %2, %6
%7 = phi i64 [ %13, %6 ], [ %4, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = sub nuw nsw i64 %4, %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10, i64 %11)
%13 = add nsw i64 %7, -1
%14 = icmp ugt i64 %7, 1
br i1 %14, label %6, label %15
15: ; preds = %6, %2
%16 = load i8, i8* %0
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %17, i64 %4)
ret void
}