#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 */
struct large {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ large_free(struct large *);
int /*<<< orphan*/ large_mul(struct large *, struct large *);
struct large *large_new(int);
int /*<<< orphan*/ large_set(struct large *, int);
struct large *large_pow(int base, int expo) {
  struct large *ret = large_new(base * expo + 1);
  struct large *lba = large_new(5);
  int i;
  large_set(lba, base);
  large_set(ret, base);
  for (i = 1; i < expo; ++i) {
    large_mul(ret, lba);
  }
  large_free(lba);
  return ret;
}


x86 assembly (clang, -O0):
<large_pow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
imul   -0x8(%rbp),%edi
add    $0x1,%edi
call   1050 <large_new@plt>
mov    %rax,-0x10(%rbp)
mov    $0x5,%edi
call   1050 <large_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <large_set@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <large_set@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b5 <large_pow+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <large_mul@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118e <large_pow+0x4e>
mov    -0x18(%rbp),%rdi
call   1030 <large_free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<large_pow>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%edi
imul   %ebp,%edi
add    $0x1,%edi
call   1050 <large_new@plt>
mov    %rax,%r14
mov    $0x5,%edi
call   1050 <large_new@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %ebp,%esi
call   1060 <large_set@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <large_set@plt>
cmp    $0x2,%ebx
jl     11a0 <large_pow+0x60>
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <large_mul@plt>
add    $0xffffffff,%ebx
jne    1190 <large_pow+0x50>
mov    %r15,%rdi
call   1030 <large_free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.large = type { i32 }
define %struct.large* @large_pow(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.large*
%6 = alloca %struct.large*
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = mul nsw i32 %8, %9
%11 = add nsw i32 %10, 1
%12 = call %struct.large* @large_new(i32 %11)
store %struct.large* %12, %struct.large** %5
%13 = call %struct.large* @large_new(i32 5)
store %struct.large* %13, %struct.large** %6
%14 = load %struct.large*, %struct.large** %6
%15 = load i32, i32* %3
%16 = call i32 @large_set(%struct.large* %14, i32 %15)
%17 = load %struct.large*, %struct.large** %5
%18 = load i32, i32* %3
%19 = call i32 @large_set(%struct.large* %17, i32 %18)
store i32 1, i32* %7
br label %20
20: ; preds = %28, %2
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load %struct.large*, %struct.large** %5
%26 = load %struct.large*, %struct.large** %6
%27 = call i32 @large_mul(%struct.large* %25, %struct.large* %26)
br label %28
28: ; preds = %24
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %20
31: ; preds = %20
%32 = load %struct.large*, %struct.large** %6
%33 = call i32 @large_free(%struct.large* %32)
%34 = load %struct.large*, %struct.large** %5
ret %struct.large* %34
}

LLVM IR (-O2):
%struct.large = type { i32 }
define %struct.large* @large_pow(i32 %0, i32 %1) {
%3 = mul nsw i32 %1, %0
%4 = add nsw i32 %3, 1
%5 = tail call %struct.large* @large_new(i32 %4)
%6 = tail call %struct.large* @large_new(i32 5)
%7 = tail call i32 @large_set(%struct.large* %6, i32 %0)
%8 = tail call i32 @large_set(%struct.large* %5, i32 %0)
%9 = icmp sgt i32 %1, 1
br i1 %9, label %10, label %15
10: ; preds = %2, %10
%11 = phi i32 [ %13, %10 ], [ 1, %2 ]
%12 = tail call i32 @large_mul(%struct.large* %5, %struct.large* %6)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %10
15: ; preds = %10, %2
%16 = tail call i32 @large_free(%struct.large* %6)
ret %struct.large* %5
}