#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 main(void) {
  int num, sum, i, j, repeat_num, each_num;
  each_num = 0;
  repeat_num = 0;
  sum = 0;
  printf("please input number a:\n");
  scanf("%d", &num);
  printf("please input repete number:\n");
  scanf("%d", &repeat_num);
  for (i = 1; i <= repeat_num; i++) {
    for (j = 0; j < i; j++) {
      each_num = num + each_num * 10;
    }
    sum = sum + each_num;
    each_num = 0;
  }
  printf("num=%d,repeat_num=%d,sum=%d\n", num, repeat_num, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11de <main+0xbe>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c0 <main+0xa0>
mov    -0x8(%rbp),%eax
imul   $0xa,-0x1c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <main+0x7a>
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1187 <main+0x67>
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
test   %edx,%edx
jle    121d <main+0xed>
mov    $0x1,%edi
xor    %r8d,%r8d
xor    %ecx,%ecx
jmp    11af <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %eax,%ecx
lea    0x1(%rdi),%eax
add    $0x1,%r8d
cmp    %edx,%edi
mov    %eax,%edi
je     121f <main+0xef>
mov    $0x0,%eax
cmp    $0x7,%r8d
jb     1205 <main+0xd5>
mov    %edi,%ebx
and    $0xfffffff8,%ebx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
add    $0xfffffff8,%ebx
jne    11d0 <main+0xa0>
test   $0x7,%dil
je     11a0 <main+0x70>
mov    %edi,%ebx
and    $0x7,%ebx
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%eax
add    $0xffffffff,%ebx
jne    1210 <main+0xe0>
jmp    11a0 <main+0x70>
xor    %ecx,%ecx
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"please input number a:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"please input repete number:\0A\00"
@.str.3 = [29 x i8] c"num=%d,repeat_num=%d,sum=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 1, i32* %4
br label %12
12: ; preds = %33, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %36
16: ; preds = %12
store i32 0, i32* %5
br label %17
17: ; preds = %26, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* %2
%23 = load i32, i32* %7
%24 = mul nsw i32 %23, 10
%25 = add nsw i32 %22, %24
store i32 %25, i32* %7
br label %26
26: ; preds = %21
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %17
29: ; preds = %17
%30 = load i32, i32* %3
%31 = load i32, i32* %7
%32 = add nsw i32 %30, %31
store i32 %32, i32* %3
store i32 0, i32* %7
br label %33
33: ; preds = %29
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %12
36: ; preds = %12
%37 = load i32, i32* %2
%38 = load i32, i32* %6
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"num=%d,repeat_num=%d,sum=%d\0A\00"
@str = [23 x i8] c"please input number a:\00"
@str.4 = [28 x i8] c"please input repete number:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1
%11 = load i32, i32* %1
br i1 %10, label %58, label %12
12: ; preds = %0, %52
%13 = phi i32 [ %57, %52 ], [ 0, %0 ]
%14 = phi i32 [ %55, %52 ], [ 1, %0 ]
%15 = phi i32 [ %54, %52 ], [ 0, %0 ]
%16 = and i32 %14, 7
%17 = icmp ult i32 %13, 7
br i1 %17, label %41, label %18
18: ; preds = %12
%19 = and i32 %14, -8
br label %20
20: ; preds = %20, %18
%21 = phi i32 [ 0, %18 ], [ %38, %20 ]
%22 = phi i32 [ 0, %18 ], [ %39, %20 ]
%23 = mul nsw i32 %21, 10
%24 = add nsw i32 %11, %23
%25 = mul nsw i32 %24, 10
%26 = add nsw i32 %11, %25
%27 = mul nsw i32 %26, 10
%28 = add nsw i32 %11, %27
%29 = mul nsw i32 %28, 10
%30 = add nsw i32 %11, %29
%31 = mul nsw i32 %30, 10
%32 = add nsw i32 %11, %31
%33 = mul nsw i32 %32, 10
%34 = add nsw i32 %11, %33
%35 = mul nsw i32 %34, 10
%36 = add nsw i32 %11, %35
%37 = mul nsw i32 %36, 10
%38 = add nsw i32 %11, %37
%39 = add i32 %22, 8
%40 = icmp eq i32 %39, %19
br i1 %40, label %41, label %20
41: ; preds = %20, %12
%42 = phi i32 [ undef, %12 ], [ %38, %20 ]
%43 = phi i32 [ 0, %12 ], [ %38, %20 ]
%44 = icmp eq i32 %16, 0
br i1 %44, label %52, label %45
45: ; preds = %41, %45
%46 = phi i32 [ %49, %45 ], [ %43, %41 ]
%47 = phi i32 [ %50, %45 ], [ 0, %41 ]
%48 = mul nsw i32 %46, 10
%49 = add nsw i32 %11, %48
%50 = add i32 %47, 1
%51 = icmp eq i32 %50, %16
br i1 %51, label %52, label %45
52: ; preds = %45, %41
%53 = phi i32 [ %42, %41 ], [ %49, %45 ]
%54 = add nsw i32 %53, %15
%55 = add nuw i32 %14, 1
%56 = icmp eq i32 %14, %9
%57 = add i32 %13, 1
br i1 %56, label %58, label %12
58: ; preds = %52, %0
%59 = phi i32 [ 0, %0 ], [ %54, %52 ]
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %9, i32 %59)
ret i32 0
}