#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 > 0) || (*y_ref > 0)) {
    if (*x_ref > 0) {
      *x_ref = *x_ref - 1;
    } else {
      if (*y_ref > 0) {
        *y_ref = *y_ref - 1;
      } else {
      }
    }
    *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
mov    $0x1,%al
cmpl   $0x0,(%rcx)
mov    %al,-0x21(%rbp)
jg     1183 <test_fun+0x73>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1193 <test_fun+0x83>
jmp    11f3 <test_fun+0xe3>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11b4 <test_fun+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11df <test_fun+0xcf>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11d5 <test_fun+0xc5>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11da <test_fun+0xca>
jmp    11da <test_fun+0xca>
jmp    11df <test_fun+0xcf>
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)
xor    %ecx,%ecx
jmp    115a <test_fun+0x4a>
nopl   0x0(%rax)
add    $0xffffffff,%edx
mov    %edx,(%rsi)
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    (%rbx),%edx
mov    %rbx,%rsi
test   %edx,%edx
jg     1150 <test_fun+0x40>
mov    (%r14),%edx
mov    %r14,%rsi
test   %edx,%edx
jg     1150 <test_fun+0x40>
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 = %46, %2
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = icmp sgt i32 %22, 0
br label %24
24: ; preds = %20, %16
%25 = phi i1 [ true, %16 ], [ %23, %20 ]
br i1 %25, label %26, label %51
26: ; preds = %24
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = sub nsw i32 %32, 1
%34 = load i32*, i32** %5
store i32 %33, i32* %34
br label %46
35: ; preds = %26
%36 = load i32*, i32** %6
%37 = load i32, i32* %36
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load i32*, i32** %6
%41 = load i32, i32* %40
%42 = sub nsw i32 %41, 1
%43 = load i32*, i32** %6
store i32 %42, i32* %43
br label %45
44: ; preds = %35
br label %45
45: ; preds = %44, %39
br label %46
46: ; preds = %45, %30
%47 = load i32*, i32** %7
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
%50 = load i32*, i32** %7
store i32 %49, i32* %50
br label %16
51: ; preds = %24
%52 = load i32*, i32** %7
%53 = load i32, i32* %52
ret i32 %53
}

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
br label %6
6: ; preds = %13, %2
%7 = phi i32 [ 0, %2 ], [ %18, %13 ]
store i32 %7, i32* %5
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10, %6
%14 = phi i32 [ %8, %6 ], [ %11, %10 ]
%15 = phi i32* [ %3, %6 ], [ %4, %10 ]
%16 = add nsw i32 %14, -1
store i32 %16, i32* %15
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
br label %6
19: ; preds = %10
ret i32 %7
}