#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 */
long insert(int);
int /*<<< orphan*/ printf(char *, int);
int rand();
int remove_element(long);
int remove_largest();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  long ids[50];
  int i;
  srand(time(NULL));
  for (i = 0; i < 50; i++) {
    int new_element = rand();
    ids[i] = insert(new_element);
    printf("%d was inserted in the list\n", new_element);
  }
  int removed = remove_element(ids[0]);
  printf("%d was removed from list\n", removed);
  int largest = remove_largest();
  printf("%d is the largest element and was removed\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x32,-0x1a4(%rbp)
jge    1200 <main+0x90>
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%edi
call   1070 <insert@plt>
mov    %rax,%rcx
movslq -0x1a4(%rbp),%rax
mov    %rcx,-0x1a0(%rbp,%rax,8)
ff
mov    -0x1a8(%rbp),%esi
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11a3 <main+0x33>
mov    -0x1a0(%rbp),%rdi
call   1080 <remove_element@plt>
mov    %eax,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <remove_largest@plt>
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%esi
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x190,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe70(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <insert@plt>
mov    %rax,(%rsp,%rbx,8)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    11a0 <main+0x30>
mov    (%rsp),%rdi
call   1080 <remove_element@plt>
lea    0xe45(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <remove_largest@plt>
lea    0xe4a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"%d was inserted in the list\0A\00"
@.str.1 = [26 x i8] c"%d was removed from list\0A\00"
@.str.2 = [43 x i8] c"%d is the largest element and was removed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [50 x i64]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %7
br label %13
13: ; preds = %25, %2
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 50
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = call i32 (...) @rand()
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = call i64 @insert(i32 %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [50 x i64], [50 x i64]* %6, i64 0, i64 %21
store i64 %19, i64* %22
%23 = load i32, i32* %8
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %13
28: ; preds = %13
%29 = getelementptr inbounds [50 x i64], [50 x i64]* %6, i64 0, i64 0
%30 = load i64, i64* %29
%31 = call i32 @remove_element(i64 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = call i32 (...) @remove_largest()
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"%d was inserted in the list\0A\00"
@.str.1 = [26 x i8] c"%d was removed from list\0A\00"
@.str.2 = [43 x i8] c"%d is the largest element and was removed\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i64]
%4 = bitcast [50 x i64]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %13, %7 ]
%9 = tail call i32 (...) @rand()
%10 = tail call i64 @insert(i32 %9)
%11 = getelementptr inbounds [50 x i64], [50 x i64]* %3, i64 0, i64 %8
store i64 %10, i64* %11
%12 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, 50
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = getelementptr inbounds [50 x i64], [50 x i64]* %3, i64 0, i64 0
%17 = load i64, i64* %16
%18 = tail call i32 @remove_element(i64 %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = tail call i32 (...) @remove_largest()
%21 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}