#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  double sum, s;
  int n, i, a, j;
  printf("Input a, n: ");
  scanf("%d %d", &a, &n);
  sum = 0;
  for (i = 1; i <= n; i++) {
    s = 0;
    for (j = 1; j <= i; j++) {
      s = s * 10 + a;
    }
    sum = sum + s;
  }
  printf("s=%.0f", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11d1 <main+0xb1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11b4 <main+0x94>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xe67(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117b <main+0x5b>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <main+0x40>
movsd  -0x10(%rbp),%xmm0
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xedc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1212 <main+0xf2>
cvtsi2sdl 0x8(%rsp),%xmm1
add    $0x1,%eax
xorpd  %xmm0,%xmm0
mov    $0x2,%edx
mov    $0x1,%ecx
movsd  0xe8a(%rip),%xmm2
jmp    1194 <main+0x74>
nopl   0x0(%rax,%rax,1)
addsd  %xmm3,%xmm0
lea    0x1(%rdx),%esi
add    $0x1,%ecx
cmp    %eax,%edx
mov    %esi,%edx
je     1216 <main+0xf6>
mov    %ebx,%esi
lea    0x1(%rsi),%ebx
xorpd  %xmm3,%xmm3
cmp    $0x7,%esi
jb     11f5 <main+0xd5>
mov    %ecx,%esi
and    $0xfffffff8,%esi
xorpd  %xmm3,%xmm3
nopl   0x0(%rax,%rax,1)
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
add    $0xfffffff8,%esi
jne    11b0 <main+0x90>
test   $0x7,%bl
je     1180 <main+0x60>
mov    %ecx,%esi
and    $0x7,%esi
nop
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
add    $0xffffffff,%esi
jne    1200 <main+0xe0>
jmp    1180 <main+0x60>
xorpd  %xmm0,%xmm0
lea    0xdfe(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Input a, n: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"s=%.0f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %4)
store double 0.000000e+00, double* %2
store i32 1, i32* %5
br label %10
10: ; preds = %31, %0
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
store double 0.000000e+00, double* %3
store i32 1, i32* %7
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load double, double* %3
%21 = load i32, i32* %6
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double %20, double 1.000000e+01, double %22)
store double %23, double* %3
br label %24
24: ; preds = %19
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %15
27: ; preds = %15
%28 = load double, double* %2
%29 = load double, double* %3
%30 = fadd double %28, %29
store double %30, double* %2
br label %31
31: ; preds = %27
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %10
34: ; preds = %10
%35 = load double, double* %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Input a, n: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"s=%.0f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %51, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = sitofp i32 %10 to double
%12 = add i32 %7, 1
br label %13
13: ; preds = %9, %45
%14 = phi i32 [ 0, %9 ], [ %50, %45 ]
%15 = phi i32 [ 2, %9 ], [ %48, %45 ]
%16 = phi double [ 0.000000e+00, %9 ], [ %47, %45 ]
%17 = add i32 %14, 1
%18 = and i32 %17, 7
%19 = icmp ult i32 %14, 7
br i1 %19, label %35, label %20
20: ; preds = %13
%21 = and i32 %17, -8
br label %22
22: ; preds = %22, %20
%23 = phi double [ 0.000000e+00, %20 ], [ %32, %22 ]
%24 = phi i32 [ 0, %20 ], [ %33, %22 ]
%25 = call double @llvm.fmuladd.f64(double %23, double 1.000000e+01, double %11)
%26 = call double @llvm.fmuladd.f64(double %25, double 1.000000e+01, double %11)
%27 = call double @llvm.fmuladd.f64(double %26, double 1.000000e+01, double %11)
%28 = call double @llvm.fmuladd.f64(double %27, double 1.000000e+01, double %11)
%29 = call double @llvm.fmuladd.f64(double %28, double 1.000000e+01, double %11)
%30 = call double @llvm.fmuladd.f64(double %29, double 1.000000e+01, double %11)
%31 = call double @llvm.fmuladd.f64(double %30, double 1.000000e+01, double %11)
%32 = call double @llvm.fmuladd.f64(double %31, double 1.000000e+01, double %11)
%33 = add i32 %24, 8
%34 = icmp eq i32 %33, %21
br i1 %34, label %35, label %22
35: ; preds = %22, %13
%36 = phi double [ undef, %13 ], [ %32, %22 ]
%37 = phi double [ 0.000000e+00, %13 ], [ %32, %22 ]
%38 = icmp eq i32 %18, 0
br i1 %38, label %45, label %39
39: ; preds = %35, %39
%40 = phi double [ %42, %39 ], [ %37, %35 ]
%41 = phi i32 [ %43, %39 ], [ 0, %35 ]
%42 = call double @llvm.fmuladd.f64(double %40, double 1.000000e+01, double %11)
%43 = add i32 %41, 1
%44 = icmp eq i32 %43, %18
br i1 %44, label %45, label %39
45: ; preds = %39, %35
%46 = phi double [ %36, %35 ], [ %42, %39 ]
%47 = fadd double %16, %46
%48 = add nuw i32 %15, 1
%49 = icmp eq i32 %15, %12
%50 = add i32 %14, 1
br i1 %49, label %51, label %13
51: ; preds = %45, %0
%52 = phi double [ 0.000000e+00, %0 ], [ %47, %45 ]
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %52)
ret i32 0
}