#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 */
size_t intlen(int);
char *malloc(int);
char pow(double, double);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
char *pwHelper(char *pw) {
  int newPW = 0;
  int i;
  for (i = 0; i < strlen(pw); i++) {
    newPW += pow((double)-1, (double)i + 2) * pw[i] *
             pow((double)10, (double)strlen(pw) - i - 1);
  }
  char *numstr = malloc(sizeof(char) * (intlen(newPW) + 1));
  sprintf(numstr, "%d", newPW);
  numstr[intlen(newPW)] = '\0';
  return numstr;
}


x86 assembly (clang, -O0):
<pwHelper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1207 <pwHelper+0xb7>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe85(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe71(%rip),%xmm0
call   1060 <pow@plt>
movsbl %al,%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
imul   %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cvtsi2sd %eax,%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
call   1060 <pow@plt>
mov    %al,%cl
mov    -0x20(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116a <pwHelper+0x1a>
mov    -0xc(%rbp),%edi
call   1030 <intlen@plt>
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdf0(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <intlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwHelper>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e3 <pwHelper+0x93>
xor    %ebx,%ebx
xor    %r15d,%r15d
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,(%rsp)
addsd  0xe7c(%rip),%xmm1
movsd  0xe7c(%rip),%xmm0
call   1060 <pow@plt>
movsbl %al,%eax
movsbl (%r14,%rbx,1),%ebp
imul   %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  (%rsp),%xmm1
addsd  0xe50(%rip),%xmm1
movsd  0xe50(%rip),%xmm0
call   1060 <pow@plt>
movsbl %al,%eax
imul   %ebp,%eax
add    %eax,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1170 <pwHelper+0x20>
jmp    11e6 <pwHelper+0x96>
xor    %r15d,%r15d
mov    %r15d,%edi
call   1030 <intlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe18(%rip),%rsi
mov    %rax,%rdi
mov    %r15d,%edx
call   1070 <sprintf@plt>
mov    %r15d,%edi
call   1030 <intlen@plt>
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i8* @pwHelper(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %36, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %39
11: ; preds = %6
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 2.000000e+00
%15 = call signext i8 @pow(double -1.000000e+00, double %14)
%16 = sext i8 %15 to i32
%17 = load i8*, i8** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = mul nsw i32 %16, %22
%24 = load i8*, i8** %2
%25 = call i32 @strlen(i8* %24)
%26 = sitofp i32 %25 to double
%27 = load i32, i32* %4
%28 = sitofp i32 %27 to double
%29 = fsub double %26, %28
%30 = fsub double %29, 1.000000e+00
%31 = call signext i8 @pow(double 1.000000e+01, double %30)
%32 = sext i8 %31 to i32
%33 = mul nsw i32 %23, %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, %33
store i32 %35, i32* %3
br label %36
36: ; preds = %11
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %6
39: ; preds = %6
%40 = load i32, i32* %3
%41 = call i64 @intlen(i32 %40)
%42 = add i64 %41, 1
%43 = mul i64 1, %42
%44 = trunc i64 %43 to i32
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %5
%46 = load i8*, i8** %5
%47 = load i32, i32* %3
%48 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = load i8*, i8** %5
%50 = load i32, i32* %3
%51 = call i64 @intlen(i32 %50)
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 0, i8* %52
%53 = load i8*, i8** %5
ret i8* %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define noalias i8* @pwHelper(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %28
4: ; preds = %1, %4
%5 = phi i64 [ %24, %4 ], [ 0, %1 ]
%6 = phi i32 [ %23, %4 ], [ 0, %1 ]
%7 = trunc i64 %5 to i32
%8 = sitofp i32 %7 to double
%9 = fadd double %8, 2.000000e+00
%10 = tail call signext i8 @pow(double -1.000000e+00, double %9)
%11 = sext i8 %10 to i32
%12 = getelementptr inbounds i8, i8* %0, i64 %5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = mul nsw i32 %14, %11
%16 = tail call i32 @strlen(i8* %0)
%17 = sitofp i32 %16 to double
%18 = fsub double %17, %8
%19 = fadd double %18, -1.000000e+00
%20 = tail call signext i8 @pow(double 1.000000e+01, double %19)
%21 = sext i8 %20 to i32
%22 = mul nsw i32 %15, %21
%23 = add nsw i32 %22, %6
%24 = add nuw nsw i64 %5, 1
%25 = tail call i32 @strlen(i8* %0)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %4, label %28
28: ; preds = %4, %1
%29 = phi i32 [ 0, %1 ], [ %23, %4 ]
%30 = tail call i64 @intlen(i32 %29)
%31 = trunc i64 %30 to i32
%32 = add i32 %31, 1
%33 = tail call i8* @malloc(i32 %32)
%34 = tail call i32 @sprintf(i8* dereferenceable(1) %33, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%35 = tail call i64 @intlen(i32 %29)
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
ret i8* %33
}