#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 i, int j, int k, int tmp) {
  int *i_ref = alloca(sizeof(int));
  int *j_ref = alloca(sizeof(int));
  int *k_ref = alloca(sizeof(int));
  int *tmp_ref = alloca(sizeof(int));
  int *c = alloca(sizeof(int));
  *i_ref = i;
  *j_ref = j;
  *k_ref = k;
  *tmp_ref = tmp;
  *c = 0;
  while ((*i_ref <= 100) && (*j_ref <= k)) {
    *tmp_ref = *i_ref;
    *i_ref = *j_ref;
    *j_ref = *tmp_ref + 1;
    *k_ref = *k_ref - 1;
    *c = *c + 1;
  }
  return *c;
}


x86 assembly (clang, -O0):
<test_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-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,%edi
call   1030 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x64,(%rcx)
mov    %al,-0x39(%rbp)
jg     11b9 <test_fun+0xa9>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
setle  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11c9 <test_fun+0xb9>
jmp    1213 <test_fun+0x103>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
jmp    1198 <test_fun+0x88>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fun>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,0x4(%rsp)
mov    %edx,%r14d
mov    %esi,(%rsp)
mov    %edi,%r13d
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r12
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbp
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r15
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %r13d,(%r12)
mov    (%rsp),%ecx
mov    %ecx,0x0(%rbp)
mov    %r14d,(%r15)
mov    0x4(%rsp),%ecx
mov    %ecx,(%rbx)
movl   $0x0,(%rax)
mov    (%r12),%edx
xor    %ecx,%ecx
cmp    $0x64,%edx
jg     11bb <test_fun+0xab>
nopw   0x0(%rax,%rax,1)
cmp    %r14d,0x0(%rbp)
jg     11bb <test_fun+0xab>
mov    %edx,(%rbx)
mov    0x0(%rbp),%ecx
mov    %ecx,(%r12)
mov    (%rbx),%ecx
add    $0x1,%ecx
mov    %ecx,0x0(%rbp)
addl   $0xffffffff,(%r15)
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    (%r12),%edx
cmp    $0x65,%edx
jl     1190 <test_fun+0x80>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_fun(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = call i32* @alloca(i32 4)
store i32* %14, i32** %9
%15 = call i32* @alloca(i32 4)
store i32* %15, i32** %10
%16 = call i32* @alloca(i32 4)
store i32* %16, i32** %11
%17 = call i32* @alloca(i32 4)
store i32* %17, i32** %12
%18 = call i32* @alloca(i32 4)
store i32* %18, i32** %13
%19 = load i32, i32* %5
%20 = load i32*, i32** %9
store i32 %19, i32* %20
%21 = load i32, i32* %6
%22 = load i32*, i32** %10
store i32 %21, i32* %22
%23 = load i32, i32* %7
%24 = load i32*, i32** %11
store i32 %23, i32* %24
%25 = load i32, i32* %8
%26 = load i32*, i32** %12
store i32 %25, i32* %26
%27 = load i32*, i32** %13
store i32 0, i32* %27
br label %28
28: ; preds = %39, %4
%29 = load i32*, i32** %9
%30 = load i32, i32* %29
%31 = icmp sle i32 %30, 100
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i32*, i32** %10
%34 = load i32, i32* %33
%35 = load i32, i32* %7
%36 = icmp sle i32 %34, %35
br label %37
37: ; preds = %32, %28
%38 = phi i1 [ false, %28 ], [ %36, %32 ]
br i1 %38, label %39, label %58
39: ; preds = %37
%40 = load i32*, i32** %9
%41 = load i32, i32* %40
%42 = load i32*, i32** %12
store i32 %41, i32* %42
%43 = load i32*, i32** %10
%44 = load i32, i32* %43
%45 = load i32*, i32** %9
store i32 %44, i32* %45
%46 = load i32*, i32** %12
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
%49 = load i32*, i32** %10
store i32 %48, i32* %49
%50 = load i32*, i32** %11
%51 = load i32, i32* %50
%52 = sub nsw i32 %51, 1
%53 = load i32*, i32** %11
store i32 %52, i32* %53
%54 = load i32*, i32** %13
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
%57 = load i32*, i32** %13
store i32 %56, i32* %57
br label %28
58: ; preds = %37
%59 = load i32*, i32** %13
%60 = load i32, i32* %59
ret i32 %60
}

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