#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*/ Bubble_sort(int *, int);
int /*<<< orphan*/ Generate_list(int *, int);
int /*<<< orphan*/ Get_args(int, char **, int *, char *);
int /*<<< orphan*/ Print_list(int *, int, char *);
int /*<<< orphan*/ Read_list(int *, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int main(int argc, char *argv[]) {
  int n;
  char g_i;
  int *a;
  Get_args(argc, argv, &n, &g_i);
  a = (int *)malloc(n * sizeof(int));
  if (g_i == 'g') {
    Generate_list(a, n);
    Print_list(a, n, "Before sort");
  } else {
    Read_list(a, n);
  }
  Bubble_sort(a, n);
  Print_list(a, n, "After sort");
  free(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x15(%rbp),%rcx
call   1050 <Get_args@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x67,%eax
jne    11de <main+0x6e>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <Generate_list@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe2c(%rip),%rdx
call   1090 <Print_list@plt>
jmp    11ea <main+0x7a>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <Read_list@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <Bubble_sort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe08(%rip),%rdx
call   1090 <Print_list@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdx
lea    0xb(%rsp),%rcx
call   1050 <Get_args@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
cmpb   $0x67,0xb(%rsp)
mov    0xc(%rsp),%esi
mov    %rax,%rdi
jne    11bb <main+0x4b>
call   1040 <Generate_list@plt>
mov    0xc(%rsp),%esi
lea    0xe4f(%rip),%rdx
mov    %rbx,%rdi
call   1090 <Print_list@plt>
jmp    11c0 <main+0x50>
call   1070 <Read_list@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1080 <Bubble_sort@plt>
mov    0xc(%rsp),%esi
lea    0xe35(%rip),%rdx
mov    %rbx,%rdi
call   1090 <Print_list@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Before sort\00"
@.str.1 = [11 x i8] c"After sort\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @Get_args(i32 %9, i8** %10, i32* %6, i8* %7)
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %8
%18 = load i8, i8* %7
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 103
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load i32*, i32** %8
%23 = load i32, i32* %6
%24 = call i32 @Generate_list(i32* %22, i32 %23)
%25 = load i32*, i32** %8
%26 = load i32, i32* %6
%27 = call i32 @Print_list(i32* %25, i32 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %32
28: ; preds = %2
%29 = load i32*, i32** %8
%30 = load i32, i32* %6
%31 = call i32 @Read_list(i32* %29, i32 %30)
br label %32
32: ; preds = %28, %21
%33 = load i32*, i32** %8
%34 = load i32, i32* %6
%35 = call i32 @Bubble_sort(i32* %33, i32 %34)
%36 = load i32*, i32** %8
%37 = load i32, i32* %6
%38 = call i32 @Print_list(i32* %36, i32 %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32*, i32** %8
%40 = call i32 @free(i32* %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Before sort\00"
@.str.1 = [11 x i8] c"After sort\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8
%5 = bitcast i32* %3 to i8*
%6 = call i32 @Get_args(i32 %0, i8** %1, i32* %3, i8* %4)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 103
%13 = load i32, i32* %3
br i1 %12, label %14, label %18
14: ; preds = %2
%15 = call i32 @Generate_list(i32* %10, i32 %13)
%16 = load i32, i32* %3
%17 = call i32 @Print_list(i32* %10, i32 %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = call i32 @Read_list(i32* %10, i32 %13)
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* %3
%22 = call i32 @Bubble_sort(i32* %10, i32 %21)
%23 = load i32, i32* %3
%24 = call i32 @Print_list(i32* %10, i32 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @free(i32* %10)
ret i32 0
}