#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 a, b, c;
  long long int out;
  printf("podaj liczbe której potęgę bedziemy obliczać: ");
  scanf("%d", &a);
  printf("podaj wartość potęgi: ");
  scanf("%d", &b);
  out = a;
  for (c = 2; c <= b; c++) {
    out = out * a;
  }
  printf("wynik z %d do potęgi %d to: %lld \n", a, b, out);
  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    0xeef(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11a4 <main+0x84>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117a <main+0x5a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe9b(%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
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef9(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    %rsi,%rcx
cmp    $0x2,%edx
jl     11c9 <main+0xa9>
lea    -0x1(%rdx),%edi
lea    -0x2(%rdx),%ebx
mov    %edi,%eax
and    $0x7,%eax
mov    %rsi,%rcx
cmp    $0x7,%ebx
jb     11b5 <main+0x95>
and    $0xfffffff8,%edi
mov    %rsi,%rcx
nopl   0x0(%rax)
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
add    $0xfffffff8,%edi
jne    1190 <main+0x70>
test   %eax,%eax
je     11c9 <main+0xa9>
nopl   0x0(%rax)
imul   %rsi,%rcx
add    $0xffffffff,%eax
jne    11c0 <main+0xa0>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [51 x i8] c"podaj liczbe kt\C3\B3rej pot\C4\99g\C4\99 bedziemy oblicza\C4\87: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"podaj warto\C5\9B\C4\87 pot\C4\99gi: \00"
@.str.3 = [36 x i8] c"wynik z %d do pot\C4\99gi %d to: %lld \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
store i64 %11, i64* %5
store i32 2, i32* %4
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i64, i64* %5
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = mul nsw i64 %17, %19
store i64 %20, i64* %5
br label %21
21: ; preds = %16
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %12
24: ; preds = %12
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i64, i64* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %26, i64 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"podaj liczbe kt\C3\B3rej pot\C4\99g\C4\99 bedziemy oblicza\C4\87: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"podaj warto\C5\9B\C4\87 pot\C4\99gi: \00"
@.str.3 = [36 x i8] c"wynik z %d do pot\C4\99gi %d to: %lld \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 ([51 x i8], [51 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, 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* %1
%10 = sext i32 %9 to i64
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 2
br i1 %12, label %43, label %13
13: ; preds = %0
%14 = add i32 %11, -1
%15 = add i32 %11, -2
%16 = and i32 %14, 7
%17 = icmp ult i32 %15, 7
br i1 %17, label %33, label %18
18: ; preds = %13
%19 = and i32 %14, -8
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ %10, %18 ], [ %30, %20 ]
%22 = phi i32 [ 0, %18 ], [ %31, %20 ]
%23 = mul nsw i64 %21, %10
%24 = mul nsw i64 %23, %10
%25 = mul nsw i64 %24, %10
%26 = mul nsw i64 %25, %10
%27 = mul nsw i64 %26, %10
%28 = mul nsw i64 %27, %10
%29 = mul nsw i64 %28, %10
%30 = mul nsw i64 %29, %10
%31 = add i32 %22, 8
%32 = icmp eq i32 %31, %19
br i1 %32, label %33, label %20
33: ; preds = %20, %13
%34 = phi i64 [ undef, %13 ], [ %30, %20 ]
%35 = phi i64 [ %10, %13 ], [ %30, %20 ]
%36 = icmp eq i32 %16, 0
br i1 %36, label %43, label %37
37: ; preds = %33, %37
%38 = phi i64 [ %40, %37 ], [ %35, %33 ]
%39 = phi i32 [ %41, %37 ], [ 0, %33 ]
%40 = mul nsw i64 %38, %10
%41 = add i32 %39, 1
%42 = icmp eq i32 %41, %16
br i1 %42, label %43, label %37
43: ; preds = %33, %37, %0
%44 = phi i64 [ %10, %0 ], [ %34, %33 ], [ %40, %37 ]
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %11, i64 %44)
ret i32 0
}