#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 *alloca(int);
int test_fun(int x, int y) {
  int *x_ref = alloca(sizeof(int));
  int *y_ref = alloca(sizeof(int));
  int *c = alloca(sizeof(int));
  *x_ref = x;
  *y_ref = y;
  *c = 0;
  while ((*x_ref > 1) && (*x_ref < *y_ref)) {
    *x_ref = (*x_ref) * (*x_ref);
    *c = *c + 1;
  }
  return *c;
}


x86 assembly (clang, -O0):
<test_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x1,(%rcx)
mov    %al,-0x21(%rbp)
jle    1188 <test_fun+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1198 <test_fun+0x88>
jmp    11bf <test_fun+0xaf>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
imul   (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1164 <test_fun+0x54>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fun>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %ebp,(%rbx)
mov    %r15d,(%r14)
movl   $0x0,(%rax)
mov    (%rbx),%edx
xor    %ecx,%ecx
cmp    $0x2,%edx
jl     1178 <test_fun+0x68>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    (%r14),%edx
jge    1178 <test_fun+0x68>
imul   %edx,%edx
mov    %edx,(%rbx)
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    (%rbx),%edx
cmp    $0x1,%edx
jg     1160 <test_fun+0x50>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_fun(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = call i32* @alloca(i32 4)
store i32* %8, i32** %5
%9 = call i32* @alloca(i32 4)
store i32* %9, i32** %6
%10 = call i32* @alloca(i32 4)
store i32* %10, i32** %7
%11 = load i32, i32* %3
%12 = load i32*, i32** %5
store i32 %11, i32* %12
%13 = load i32, i32* %4
%14 = load i32*, i32** %6
store i32 %13, i32* %14
%15 = load i32*, i32** %7
store i32 0, i32* %15
br label %16
16: ; preds = %28, %2
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = icmp slt i32 %22, %24
br label %26
26: ; preds = %20, %16
%27 = phi i1 [ false, %16 ], [ %25, %20 ]
br i1 %27, label %28, label %39
28: ; preds = %26
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = mul nsw i32 %30, %32
%34 = load i32*, i32** %5
store i32 %33, i32* %34
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
%38 = load i32*, i32** %7
store i32 %37, i32* %38
br label %16
39: ; preds = %26
%40 = load i32*, i32** %7
%41 = load i32, i32* %40
ret i32 %41
}

LLVM IR (-O2):
define i32 @test_fun(i32 %0, i32 %1) {
%3 = tail call i32* @alloca(i32 4)
%4 = tail call i32* @alloca(i32 4)
%5 = tail call i32* @alloca(i32 4)
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %21
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp slt i32 %6, %9
br i1 %10, label %14, label %21
11: ; preds = %14
%12 = load i32, i32* %4
%13 = icmp slt i32 %19, %12
br i1 %13, label %14, label %21
14: ; preds = %8, %11
%15 = phi i32 [ %19, %11 ], [ %6, %8 ]
%16 = mul nsw i32 %15, %15
store i32 %16, i32* %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 1
br i1 %20, label %11, label %21
21: ; preds = %14, %11, %8, %2
%22 = phi i32 [ 0, %2 ], [ 0, %8 ], [ %18, %11 ], [ %18, %14 ]
ret i32 %22
}