#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 */
struct MedianFinder {
  int dummy;
};

/* Variables and functions */
struct MedianFinder *MedianFinderCreate();
int /*<<< orphan*/ MedianFinderFree(struct MedianFinder *);
int /*<<< orphan*/ addNum(struct MedianFinder *, int);
double findMedian(struct MedianFinder *);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  struct MedianFinder *mf = MedianFinderCreate();
  addNum(mf, 1);
  addNum(mf, 2);
  printf("%f\n", findMedian(mf));
  addNum(mf, 3);
  printf("%f\n", findMedian(mf));
  MedianFinderFree(mf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <MedianFinderCreate@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1070 <addNum@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1070 <addNum@plt>
mov    -0x10(%rbp),%rdi
call   1050 <findMedian@plt>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1070 <addNum@plt>
mov    -0x10(%rbp),%rdi
call   1050 <findMedian@plt>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <MedianFinderFree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <MedianFinderCreate@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1070 <addNum@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <addNum@plt>
mov    %rbx,%rdi
call   1050 <findMedian@plt>
lea    0xe79(%rip),%r14
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <addNum@plt>
mov    %rbx,%rdi
call   1050 <findMedian@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <MedianFinderFree@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.MedianFinder = type { i32 }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.MedianFinder*
store i32 0, i32* %1
%3 = call %struct.MedianFinder* (...) @MedianFinderCreate()
store %struct.MedianFinder* %3, %struct.MedianFinder** %2
%4 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%5 = call i32 @addNum(%struct.MedianFinder* %4, i32 1)
%6 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%7 = call i32 @addNum(%struct.MedianFinder* %6, i32 2)
%8 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%9 = call double @findMedian(%struct.MedianFinder* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %9)
%11 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%12 = call i32 @addNum(%struct.MedianFinder* %11, i32 3)
%13 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%14 = call double @findMedian(%struct.MedianFinder* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %14)
%16 = load %struct.MedianFinder*, %struct.MedianFinder** %2
%17 = call i32 @MedianFinderFree(%struct.MedianFinder* %16)
ret i32 0
}

LLVM IR (-O2):
%struct.MedianFinder = type { i32 }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = tail call %struct.MedianFinder* (...) @MedianFinderCreate()
%2 = tail call i32 @addNum(%struct.MedianFinder* %1, i32 1)
%3 = tail call i32 @addNum(%struct.MedianFinder* %1, i32 2)
%4 = tail call double @findMedian(%struct.MedianFinder* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 @addNum(%struct.MedianFinder* %1, i32 3)
%7 = tail call double @findMedian(%struct.MedianFinder* %1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %7)
%9 = tail call i32 @MedianFinderFree(%struct.MedianFinder* %1)
ret i32 0
}