#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*/ exponent(char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, float);
int strlen(char *);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  int answer, i;
  char *two_exp;
  two_exp = malloc(sizeof(char) * 400);
  memset(two_exp, '0', 400);
  *two_exp = '2';
  exponent(two_exp, 1000);
  answer = 0;
  for (i = 0; i < strlen(two_exp); i++)
    answer += (*(two_exp + i) - '0');
  float stop = timeit();
  printf("Answer: %d\n", answer);
  printf("Time: %f\n", stop - start);
  free(two_exp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
mov    $0x190,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x30,%esi
mov    $0x190,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rax
movb   $0x32,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0x3e8,%esi
call   1090 <exponent@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    1215 <main+0xa5>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d6 <main+0x66>
mov    $0x0,%al
call   1080 <timeit@plt>
movss  %xmm0,-0x2c(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
movss  -0x2c(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xdc9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1080 <timeit@plt>
movss  %xmm0,0xc(%rsp)
mov    $0x190,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x30,%esi
mov    $0x190,%edx
call   1060 <memset@plt>
movb   $0x32,(%r14)
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1090 <exponent@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11f9 <main+0x89>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%eax
add    %eax,%r15d
add    $0xffffffd0,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11d0 <main+0x60>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
jmp    11fc <main+0x8c>
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1080 <timeit@plt>
movss  %xmm0,0x8(%rsp)
lea    0xdea(%rip),%rdi
movss  0x4(%rsp),%xmm0
call   1050 <printf@plt>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
lea    0xdd8(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call float (...) @timeit()
store float %11, float* %6
%12 = call i8* @malloc(i32 400)
store i8* %12, i8** %9
%13 = load i8*, i8** %9
%14 = call i32 @memset(i8* %13, i32 48, i32 400)
%15 = load i8*, i8** %9
store i8 50, i8* %15
%16 = load i8*, i8** %9
%17 = call i32 @exponent(i8* %16, i32 1000)
store i32 0, i32* %7
store i32 0, i32* %8
br label %18
18: ; preds = %33, %2
%19 = load i32, i32* %8
%20 = load i8*, i8** %9
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %36
23: ; preds = %18
%24 = load i8*, i8** %9
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 48
%31 = load i32, i32* %7
%32 = add nsw i32 %31, %30
store i32 %32, i32* %7
br label %33
33: ; preds = %23
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %18
36: ; preds = %18
%37 = call float (...) @timeit()
store float %37, float* %10
%38 = load i32, i32* %7
%39 = sitofp i32 %38 to float
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %39)
%41 = load float, float* %10
%42 = load float, float* %6
%43 = fsub float %41, %42
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %43)
%45 = load i8*, i8** %9
%46 = call i32 @free(i8* %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
%4 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%5 = tail call i32 @memset(i8* %4, i32 48, i32 400)
store i8 50, i8* %4
%6 = tail call i32 @exponent(i8* %4, i32 1000)
%7 = tail call i32 @strlen(i8* %4)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %2, %9
%10 = phi i64 [ %17, %9 ], [ 0, %2 ]
%11 = phi i32 [ %16, %9 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %4, i64 %10
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = add i32 %11, -48
%16 = add i32 %15, %14
%17 = add nuw nsw i64 %10, 1
%18 = tail call i32 @strlen(i8* %4)
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %9, label %21
21: ; preds = %9
%22 = sitofp i32 %16 to float
br label %23
23: ; preds = %21, %2
%24 = phi float [ 0.000000e+00, %2 ], [ %22, %21 ]
%25 = tail call float (...) @timeit()
%26 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %24)
%27 = fsub float %25, %3
%28 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %27)
%29 = tail call i32 @free(i8* %4)
ret i32 0
}