#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wm_1_bubble_sort(int);
int /*<<< orphan*/ wm_1_setter(int);
int run_wasm(int n) {
  int result = 0;
  const int max = 1000000;
  int i, j;
  if (n > max) {
    n = max;
    fprintf(stderr, "Asking for too much, bubble.wast only allows 1M elements, "
                    "setting to 1M\n");
  }
  for (i = 0; i < 1; i++) {
    wm_1_setter(n);
    wm_1_bubble_sort(n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<run_wasm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xf4240,-0xc(%rbp)
cmpl   $0xf4240,-0x4(%rbp)
jle    1172 <run_wasm+0x42>
movl   $0xf4240,-0x4(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    11a1 <run_wasm+0x71>
mov    -0x4(%rbp),%edi
call   1050 <wm_1_setter@plt>
mov    -0x4(%rbp),%edi
call   1040 <wm_1_bubble_sort@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <run_wasm+0x49>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_wasm>:
push   %rbx
mov    %edi,%ebx
cmp    $0xf4241,%edi
jl     1155 <run_wasm+0x25>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xf4240,%ebx
mov    %ebx,%edi
call   1050 <wm_1_setter@plt>
mov    %ebx,%edi
call   1040 <wm_1_bubble_sort@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [73 x i8] c"Asking for too much, bubble.wast only allows 1M elements, setting to 1M\0A\00"
define i32 @run_wasm(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 1000000, i32* %4
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 1000000
br i1 %8, label %9, label %12
9: ; preds = %1
store i32 1000000, i32* %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %1
store i32 0, i32* %5
br label %13
13: ; preds = %21, %12
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %2
%18 = call i32 @wm_1_setter(i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @wm_1_bubble_sort(i32 %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %13
24: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [73 x i8] c"Asking for too much, bubble.wast only allows 1M elements, setting to 1M\0A\00"
define i32 @run_wasm(i32 %0) {
%2 = icmp sgt i32 %0, 1000000
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %3, %1
%7 = phi i32 [ 1000000, %3 ], [ %0, %1 ]
%8 = tail call i32 @wm_1_setter(i32 %7)
%9 = tail call i32 @wm_1_bubble_sort(i32 %7)
ret i32 0
}