#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 x = 0, n = 0;
  int i = 1;
  printf("x: ");
  scanf("%d", &x);
  printf("n: ");
  scanf("%d", &n);
  printf("\nx=%d, n=%d", x, n);
  for (i; i < n; i++) {
    x *= x;
  }
  printf("\nRésultat: %d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b8 <main+0x98>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1194 <main+0x74>
mov    -0x8(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec7(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
cmp    $0x2,%edx
jl     11ec <main+0xcc>
lea    -0x1(%rdx),%ecx
add    $0xfffffffe,%edx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%edx
jb     11cd <main+0xad>
and    $0xfffffff8,%ecx
nopl   0x0(%rax,%rax,1)
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
imul   %esi,%esi
add    $0xfffffff8,%ecx
jne    11b0 <main+0x90>
test   %eax,%eax
je     11e8 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
imul   %esi,%esi
add    $0xffffffff,%eax
jne    11e0 <main+0xc0>
mov    %esi,0x8(%rsp)
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"x: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"n: \00"
@.str.3 = [12 x i8] c"\0Ax=%d, n=%d\00"
@.str.4 = [16 x i8] c"\0AR\C3\A9sultat: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 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* %3)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %4
br label %13
13: ; preds = %21, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i32, i32* %2
%19 = load i32, i32* %2
%20 = mul nsw i32 %19, %18
store i32 %20, i32* %2
br label %21
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %13
24: ; preds = %13
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"x: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"n: \00"
@.str.3 = [12 x i8] c"\0Ax=%d, n=%d\00"
@.str.4 = [16 x i8] c"\0AR\C3\A9sultat: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 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 ([4 x i8], [4 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 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = icmp sgt i32 %12, 1
br i1 %14, label %15, label %47
15: ; preds = %0
%16 = add i32 %12, -1
%17 = add i32 %12, -2
%18 = and i32 %16, 7
%19 = icmp ult i32 %17, 7
br i1 %19, label %35, label %20
20: ; preds = %15
%21 = and i32 %16, -8
br label %22
22: ; preds = %22, %20
%23 = phi i32 [ %13, %20 ], [ %32, %22 ]
%24 = phi i32 [ 0, %20 ], [ %33, %22 ]
%25 = mul nsw i32 %23, %23
%26 = mul nsw i32 %25, %25
%27 = mul nsw i32 %26, %26
%28 = mul nsw i32 %27, %27
%29 = mul nsw i32 %28, %28
%30 = mul nsw i32 %29, %29
%31 = mul nsw i32 %30, %30
%32 = mul nsw i32 %31, %31
%33 = add i32 %24, 8
%34 = icmp eq i32 %33, %21
br i1 %34, label %35, label %22
35: ; preds = %22, %15
%36 = phi i32 [ undef, %15 ], [ %32, %22 ]
%37 = phi i32 [ %13, %15 ], [ %32, %22 ]
%38 = icmp eq i32 %18, 0
br i1 %38, label %45, label %39
39: ; preds = %35, %39
%40 = phi i32 [ %42, %39 ], [ %37, %35 ]
%41 = phi i32 [ %43, %39 ], [ 0, %35 ]
%42 = mul nsw i32 %40, %40
%43 = add i32 %41, 1
%44 = icmp eq i32 %43, %18
br i1 %44, label %45, label %39
45: ; preds = %39, %35
%46 = phi i32 [ %36, %35 ], [ %42, %39 ]
store i32 %46, i32* %1
br label %47
47: ; preds = %45, %0
%48 = phi i32 [ %46, %45 ], [ %13, %0 ]
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %48)
ret i32 0
}