#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);
int /*<<< orphan*/ wczytaj_liczbe_calkowita(int *);
int main() {
  int n, suma = 0;
  size_t i;
  wczytaj_liczbe_calkowita(&n);
  for (i = 1; i <= n; i++) {
    suma += i;
  }
  printf("Suma: %d\n", suma);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <wczytaj_liczbe_calkowita@plt>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
ja     1177 <main+0x57>
mov    -0x18(%rbp),%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1147 <main+0x27>
mov    -0xc(%rbp),%esi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x4(%rsp),%rdi
call   1030 <wczytaj_liczbe_calkowita@plt>
movslq 0x4(%rsp),%rax
test   %rax,%rax
je     1155 <main+0x35>
lea    -0x1(%rax),%rcx
movabs $0x1fffffffe,%rdx
add    %rax,%rdx
imul   %rcx,%rdx
shr    %rdx
lea    (%rdx,%rax,2),%esi
add    $0xffffffff,%esi
jmp    1157 <main+0x37>
xor    %esi,%esi
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Suma: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @wczytaj_liczbe_calkowita(i32* %2)
store i64 1, i64* %4
br label %6
6: ; preds = %17, %0
%7 = load i64, i64* %4
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = icmp ule i64 %7, %9
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i64, i64* %4
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = add i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %3
br label %17
17: ; preds = %11
%18 = load i64, i64* %4
%19 = add i64 %18, 1
store i64 %19, i64* %4
br label %6
20: ; preds = %6
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [10 x i8] c"Suma: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @wczytaj_liczbe_calkowita(i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %0
%7 = sext i32 %4 to i64
%8 = add nuw nsw i64 %7, 1
%9 = trunc i64 %8 to i32
%10 = shl i32 %9, 1
%11 = trunc i64 %8 to i33
%12 = add nsw i33 %11, -2
%13 = add nsw i33 %11, -3
%14 = mul i33 %12, %13
%15 = lshr i33 %14, 1
%16 = trunc i33 %15 to i32
%17 = add i32 %10, %16
%18 = add i32 %17, -3
br label %19
19: ; preds = %6, %0
%20 = phi i32 [ 0, %0 ], [ %18, %6 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}