#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 */
unsigned int radixToTen(unsigned int *num, int radix) {
  unsigned power(int x, int y);
  unsigned highestPower = 0;
  int *temp = num;
  while (temp != NULL) {
    temp++;
    highestPower++;
  }
  highestPower = power(highestPower, radix);
  unsigned ans = highestPower * (*num);
  while (num != NULL) {
    num++;
    ans += (highestPower / radix) * (*num);
  }
  return ans;
}


x86 assembly (clang, -O0):
<radixToTen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1153 <radixToTen+0x43>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <radixToTen+0x1e>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <power@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
imul   (%rcx),%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119f <radixToTen+0x8f>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    -0x8(%rbp),%rcx
imul   (%rcx),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <radixToTen+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radixToTen>:
push   %rax
xor    %edi,%edi
call   1030 <power@plt>

LLVM IR (-O0):
define i32 @radixToTen(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i32*, i32** %3
store i32* %8, i32** %6
br label %9
9: ; preds = %12, %2
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %6
%15 = load i32, i32* %5
%16 = add i32 %15, 1
store i32 %16, i32* %5
br label %9
17: ; preds = %9
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = call i32 @power(i32 %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = load i32*, i32** %3
%23 = load i32, i32* %22
%24 = mul i32 %21, %23
store i32 %24, i32* %7
br label %25
25: ; preds = %28, %17
%26 = load i32*, i32** %3
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i32*, i32** %3
%30 = getelementptr inbounds i32, i32* %29, i32 1
store i32* %30, i32** %3
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = udiv i32 %31, %32
%34 = load i32*, i32** %3
%35 = load i32, i32* %34
%36 = mul i32 %33, %35
%37 = load i32, i32* %7
%38 = add i32 %37, %36
store i32 %38, i32* %7
br label %25
39: ; preds = %25
%40 = load i32, i32* %7
ret i32 %40
}

LLVM IR (-O2):
define i32 @radixToTen(i32* readnone %0, i32 %1) {
%3 = icmp eq i32* %0, null
%4 = tail call i32 @power(i32 0, i32 %1)
unreachable
}