#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 i, n, number, triangularNumber, counter;
  printf("ÇëÊäÈëÄúÏëÒª¼ÆËãµÄÈý½ÇÐÎÊýµÄ¸öÊý£º");
  scanf("%i", &counter);
  for (i = 1; i <= counter; i++) {
    printf("What triangluar number do you want? ");
    scanf("%i", &number);
    triangularNumber = 0;
    for (n = 1; n <= number; n++) {
      triangularNumber += n;
    }
    printf("Triangular number %i is %i\n", number, triangularNumber);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11d1 <main+0xb1>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11af <main+0x8f>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x6c>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    11b8 <main+0x98>
lea    0xef3(%rip),%r14
lea    0xee9(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xf05(%rip),%r13
xor    %ebx,%ebx
jmp    1184 <main+0x64>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    (%rsp),%ebx
jge    11b8 <main+0x98>
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1170 <main+0x50>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%ebp
add    $0xffffffff,%ebp
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\84\C3\BA\C3\8F\C3\AB\C3\92\C2\AA\C2\BC\C3\86\C3\8B\C3\A3\C2\B5\C3\84\C3\88\C3\BD\C2\BD\C3\87\C3\90\C3\8E\C3\8A\C3\BD\C2\B5\C3\84\C2\B8\C3\B6\C3\8A\C3\BD\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [37 x i8] c"What triangluar number do you want? \00"
@.str.3 = [28 x i8] c"Triangular number %i is %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 1, i32* %2
br label %9
9: ; preds = %31, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %6
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
store i32 1, i32* %3
br label %16
16: ; preds = %24, %13
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
store i32 %23, i32* %5
br label %24
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %16
27: ; preds = %16
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %9
34: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [69 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\84\C3\BA\C3\8F\C3\AB\C3\92\C2\AA\C2\BC\C3\86\C3\8B\C3\A3\C2\B5\C3\84\C3\88\C3\BD\C2\BD\C3\87\C3\90\C3\8E\C3\8A\C3\BD\C2\B5\C3\84\C2\B8\C3\B6\C3\8A\C3\BD\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [37 x i8] c"What triangluar number do you want? \00"
@.str.3 = [28 x i8] c"Triangular number %i is %i\0A\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 ([69 x i8], [69 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* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %32, label %9
9: ; preds = %0, %26
%10 = phi i32 [ %29, %26 ], [ 1, %0 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %26, label %15
15: ; preds = %9
%16 = shl nuw i32 %13, 1
%17 = add nsw i32 %13, -1
%18 = zext i32 %17 to i33
%19 = add nsw i32 %13, -2
%20 = zext i32 %19 to i33
%21 = mul i33 %18, %20
%22 = lshr i33 %21, 1
%23 = trunc i33 %22 to i32
%24 = add i32 %16, -1
%25 = add i32 %24, %23
br label %26
26: ; preds = %15, %9
%27 = phi i32 [ 0, %9 ], [ %25, %15 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %27)
%29 = add nuw nsw i32 %10, 1
%30 = load i32, i32* %2
%31 = icmp slt i32 %10, %30
br i1 %31, label %9, label %32
32: ; preds = %26, %0
ret i32 0
}