#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ ft_usage(char *);
int get_flags(int, char **, char *);
int *read_stack(int, char **, int *, int);
int /*<<< orphan*/ sort_print(int *, int, int, char);
int main(int ar, char **av) {
  int *stack;
  int wrong;
  char flag;
  int count_flag;
  wrong = 0;
  flag = 0;
  count_flag = 0;
  stack = 0;
  if (ar == 1)
    ft_usage(av[0]);
  else {
    count_flag = get_flags(ar, av, &flag);
    stack = (read_stack(ar, av, &wrong, count_flag));
    if (wrong == 0)
      exit(0);
    else
      sort_print(stack, ar - count_flag, wrong, flag);
  }
  free(stack);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x1d(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ab <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <ft_usage@plt>
jmp    1201 <main+0xa1>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1d(%rbp),%rdx
call   1080 <get_flags@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%ecx
lea    -0x1c(%rbp),%rdx
call   1040 <read_stack@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11e6 <main+0x86>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsbl -0x1d(%rbp),%ecx
call   1060 <sort_print@plt>
jmp    1201 <main+0xa1>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movl   $0x0,0xc(%rsp)
movb   $0x0,0xb(%rsp)
cmp    $0x1,%edi
jne    118a <main+0x2a>
mov    (%r14),%rdi
call   1050 <ft_usage@plt>
xor    %r14d,%r14d
jmp    11c8 <main+0x68>
mov    %edi,%ebx
lea    0xb(%rsp),%rdx
mov    %r14,%rsi
call   1080 <get_flags@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%ecx
call   1040 <read_stack@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     11db <main+0x7b>
mov    %rax,%r14
sub    %ebp,%ebx
movsbl 0xb(%rsp),%ecx
mov    %rax,%rdi
mov    %ebx,%esi
call   1060 <sort_print@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8 0, i8* %8
store i32 0, i32* %9
store i32* null, i32** %6
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @ft_usage(i8* %15)
br label %38
17: ; preds = %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @get_flags(i32 %18, i8** %19, i8* %8)
store i32 %20, i32* %9
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = call i32* @read_stack(i32 %21, i8** %22, i32* %7, i32 %23)
store i32* %24, i32** %6
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %17
%30 = load i32*, i32** %6
%31 = load i32, i32* %4
%32 = load i32, i32* %9
%33 = sub nsw i32 %31, %32
%34 = load i32, i32* %7
%35 = load i8, i8* %8
%36 = call i32 @sort_print(i32* %30, i32 %33, i32 %34, i8 signext %35)
br label %37
37: ; preds = %29
br label %38
38: ; preds = %37, %12
%39 = load i32*, i32** %6
%40 = call i32 @free(i32* %39)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
store i8 0, i8* %4
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @ft_usage(i8* %8)
br label %21
10: ; preds = %2
%11 = call i32 @get_flags(i32 %0, i8** %1, i8* %4)
%12 = call i32* @read_stack(i32 %0, i8** %1, i32* %3, i32 %11)
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %10
%18 = sub nsw i32 %0, %11
%19 = load i8, i8* %4
%20 = call i32 @sort_print(i32* %12, i32 %18, i32 %13, i8 signext %19)
br label %21
21: ; preds = %17, %7
%22 = phi i32* [ null, %7 ], [ %12, %17 ]
%23 = call i32 @free(i32* %22)
ret i32 0
}