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


x86 assembly (clang, -O0):
<f>:
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,%edi
call   1030 <alloca@plt>
mov    %rax,-0x28(%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   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     11be <f+0xae>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,(%rcx)
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
setl   %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    117c <f+0x6c>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %edi,%ebp
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r15
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %ebp,(%r15)
mov    %r12d,(%r14)
movl   $0x1,(%rbx)
movl   $0x0,(%rax)
cmpl   $0x0,(%rbx)
je     1191 <f+0x81>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%ecx
lea    0x1(%rcx),%edx
mov    %edx,(%r15)
xor    %edx,%edx
cmp    (%r14),%ecx
setl   %dl
mov    %edx,(%rbx)
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
cmpl   $0x0,(%rbx)
jne    1170 <f+0x60>
jmp    1193 <f+0x83>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @f(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)
%6 = tail call i32* @alloca(i32 4)
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %2, %9
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
%12 = load i32, i32* %4
%13 = icmp slt i32 %10, %12
%14 = zext i1 %13 to i32
store i32 %14, i32* %5
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %2
%20 = phi i32 [ 0, %2 ], [ %16, %9 ]
ret i32 %20
}