#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*/ init_bubble_c(int);
int /*<<< orphan*/ run_bubble_c(void *, int);
int /*<<< orphan*/ stderr;
int run_c(void *data, int n) {
  int result = 0;
  const int max = 1000000;
  int i;
  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++) {
    init_bubble_c(n);
    run_bubble_c(data, n);
  }
}


x86 assembly (clang, -O0):
<run_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xf4240,-0x1c(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jle    1176 <run_c+0x46>
movl   $0xf4240,-0x14(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    11a9 <run_c+0x79>
mov    -0x14(%rbp),%edi
call   1050 <init_bubble_c@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <run_bubble_c@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117d <run_c+0x4d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_c>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0xf4241,%esi
jl     115a <run_c+0x2a>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xf4240,%ebp
mov    %ebp,%edi
call   1050 <init_bubble_c@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <run_bubble_c@plt>

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_c(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 1000000, i32* %7
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 1000000
br i1 %10, label %11, label %14
11: ; preds = %2
store i32 1000000, i32* %5
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
store i32 0, i32* %8
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %5
%20 = call i32 @init_bubble_c(i32 %19)
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = call i32 @run_bubble_c(i8* %21, i32 %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %15
27: ; preds = %15
%28 = load i32, i32* %3
ret i32 %28
}

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_c(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1000000
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %2
%8 = phi i32 [ 1000000, %4 ], [ %1, %2 ]
%9 = tail call i32 @init_bubble_c(i32 %8)
%10 = tail call i32 @run_bubble_c(i8* %0, i32 %8)
ret i32 undef
}