#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*/ DESCRIBE(char *);
int /*<<< orphan*/ IF(char *);
int /*<<< orphan*/ THEN(char *);
int /*<<< orphan*/ WHEN(char *);
int /*<<< orphan*/ insertion(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ isEqual(int, int);
int /*<<< orphan*/ isLesserThan(int, int);
int *malloc(int);
int /*<<< orphan*/ troca(int *, int /*<<< orphan*/, int);
int main() {
  DESCRIBE("INSERTION SORT");
  WHEN("ORDENAR:");
  IF("VETOR DE TAMANHO 'SIZE'");
  THEN("TODO ELEMENTO DA POSIÇÃO X DEVE SER MENOR DO QUE DA POSICAO X+1 (MENOS "
       "ULTIMO ELEMENTO)");
  int *p;
  p = malloc(sizeof(int) * 9);
  for (int i = 0; i < 9; i++) {
    p[i] = 9 - i;
  }
  insertion(p, 0, 9);
  for (int i = 0; i < 9 - 1; i++) {
    isLesserThan(p[i], p[i + 1]);
  }
  DESCRIBE("AUXILIARES:");
  WHEN("USO FUNÇÃO TROCA()");
  IF("VARIAVEL A=1 E B=2 E CHAMAR TROCA NAS DUAS");
  THEN("FICARA A=2 E B=1");
  int *d;
  d = malloc(sizeof(int) * 2);
  d[0] = 1;
  d[1] = 2;
  troca(d, 0, 1);
  isEqual(d[0], 2);
  isEqual(d[1], 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
call   1040 <DESCRIBE@plt>
lea    0xe5d(%rip),%rdi
call   10b0 <WHEN@plt>
lea    0xe5a(%rip),%rdi
call   10a0 <IF@plt>
lea    0xe66(%rip),%rdi
call   1030 <THEN@plt>
mov    $0x24,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    120f <main+0x7f>
mov    $0x9,%edx
sub    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <main+0x54>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <insertion@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    125e <main+0xce>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1070 <isLesserThan@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1226 <main+0x96>
lea    0xe25(%rip),%rdi
call   1040 <DESCRIBE@plt>
lea    0xe25(%rip),%rdi
call   10b0 <WHEN@plt>
lea    0xe2e(%rip),%rdi
call   10a0 <IF@plt>
lea    0xe4d(%rip),%rdi
call   1030 <THEN@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1080 <troca@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    $0x2,%esi
call   1090 <isEqual@plt>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
mov    $0x1,%esi
call   1090 <isEqual@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe88(%rip),%rdi
call   1040 <DESCRIBE@plt>
lea    0xe8b(%rip),%rdi
call   10b0 <WHEN@plt>
lea    0xe88(%rip),%rdi
call   10a0 <IF@plt>
lea    0xe94(%rip),%rdi
call   1030 <THEN@plt>
mov    $0x24,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movaps 0xe2b(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe31(%rip),%xmm0
movups %xmm0,0x10(%rax)
movl   $0x1,0x20(%rax)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <insertion@plt>
mov    (%rbx),%edi
mov    0x4(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x4(%rbx),%edi
mov    0x8(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0xc(%rbx),%edi
mov    0x10(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x10(%rbx),%edi
mov    0x14(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x14(%rbx),%edi
mov    0x18(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x18(%rbx),%edi
mov    0x1c(%rbx),%esi
call   1070 <isLesserThan@plt>
mov    0x1c(%rbx),%edi
mov    0x20(%rbx),%esi
call   1070 <isLesserThan@plt>
lea    0xe53(%rip),%rdi
call   1040 <DESCRIBE@plt>
lea    0xe53(%rip),%rdi
call   10b0 <WHEN@plt>
lea    0xe5c(%rip),%rdi
call   10a0 <IF@plt>
lea    0xe7b(%rip),%rdi
call   1030 <THEN@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movabs $0x200000001,%rax
mov    %rax,(%rbx)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1080 <troca@plt>
mov    (%rbx),%edi
mov    $0x2,%esi
call   1090 <isEqual@plt>
mov    0x4(%rbx),%edi
mov    $0x1,%esi
call   1090 <isEqual@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"INSERTION SORT\00"
@.str.1 = [9 x i8] c"ORDENAR:\00"
@.str.2 = [24 x i8] c"VETOR DE TAMANHO 'SIZE'\00"
@.str.3 = [90 x i8] c"TODO ELEMENTO DA POSI\C3\87\C3\83O X DEVE SER MENOR DO QUE DA POSICAO X+1 (MENOS ULTIMO ELEMENTO)\00"
@.str.4 = [12 x i8] c"AUXILIARES:\00"
@.str.5 = [21 x i8] c"USO FUN\C3\87\C3\83O TROCA()\00"
@.str.6 = [43 x i8] c"VARIAVEL A=1 E B=2 E CHAMAR TROCA NAS DUAS\00"
@.str.7 = [17 x i8] c"FICARA A=2 E B=1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32 @DESCRIBE(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @WHEN(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @IF(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @THEN(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32* @malloc(i32 36)
store i32* %10, i32** %2
store i32 0, i32* %3
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 9
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sub nsw i32 9, %15
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
br label %21
21: ; preds = %14
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %11
24: ; preds = %11
%25 = load i32*, i32** %2
%26 = call i32 @insertion(i32* %25, i32 0, i32 9)
store i32 0, i32* %4
br label %27
27: ; preds = %43, %24
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 8
br i1 %29, label %30, label %46
30: ; preds = %27
%31 = load i32*, i32** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %2
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %36, i64 %39
%41 = load i32, i32* %40
%42 = call i32 @isLesserThan(i32 %35, i32 %41)
br label %43
43: ; preds = %30
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %27
46: ; preds = %27
%47 = call i32 @DESCRIBE(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 @WHEN(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 @IF(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%50 = call i32 @THEN(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32* @malloc(i32 8)
store i32* %51, i32** %5
%52 = load i32*, i32** %5
%53 = getelementptr inbounds i32, i32* %52, i64 0
store i32 1, i32* %53
%54 = load i32*, i32** %5
%55 = getelementptr inbounds i32, i32* %54, i64 1
store i32 2, i32* %55
%56 = load i32*, i32** %5
%57 = call i32 @troca(i32* %56, i32 0, i32 1)
%58 = load i32*, i32** %5
%59 = getelementptr inbounds i32, i32* %58, i64 0
%60 = load i32, i32* %59
%61 = call i32 @isEqual(i32 %60, i32 2)
%62 = load i32*, i32** %5
%63 = getelementptr inbounds i32, i32* %62, i64 1
%64 = load i32, i32* %63
%65 = call i32 @isEqual(i32 %64, i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"INSERTION SORT\00"
@.str.1 = [9 x i8] c"ORDENAR:\00"
@.str.2 = [24 x i8] c"VETOR DE TAMANHO 'SIZE'\00"
@.str.3 = [90 x i8] c"TODO ELEMENTO DA POSI\C3\87\C3\83O X DEVE SER MENOR DO QUE DA POSICAO X+1 (MENOS ULTIMO ELEMENTO)\00"
@.str.4 = [12 x i8] c"AUXILIARES:\00"
@.str.5 = [21 x i8] c"USO FUN\C3\87\C3\83O TROCA()\00"
@.str.6 = [43 x i8] c"VARIAVEL A=1 E B=2 E CHAMAR TROCA NAS DUAS\00"
@.str.7 = [17 x i8] c"FICARA A=2 E B=1\00"
define i32 @main() {
%1 = tail call i32 @DESCRIBE(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @WHEN(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @IF(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @THEN(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32* @malloc(i32 36)
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = getelementptr inbounds i32, i32* %5, i64 2
%8 = getelementptr inbounds i32, i32* %5, i64 3
%9 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 9, i32 8, i32 7, i32 6>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %5, i64 4
%11 = getelementptr inbounds i32, i32* %5, i64 5
%12 = getelementptr inbounds i32, i32* %5, i64 6
%13 = getelementptr inbounds i32, i32* %5, i64 7
%14 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 5, i32 4, i32 3, i32 2>, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %5, i64 8
store i32 1, i32* %15
%16 = tail call i32 @insertion(i32* %5, i32 0, i32 9)
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = tail call i32 @isLesserThan(i32 %17, i32 %18)
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = tail call i32 @isLesserThan(i32 %20, i32 %21)
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = tail call i32 @isLesserThan(i32 %23, i32 %24)
%26 = load i32, i32* %8
%27 = load i32, i32* %10
%28 = tail call i32 @isLesserThan(i32 %26, i32 %27)
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = tail call i32 @isLesserThan(i32 %29, i32 %30)
%32 = load i32, i32* %11
%33 = load i32, i32* %12
%34 = tail call i32 @isLesserThan(i32 %32, i32 %33)
%35 = load i32, i32* %12
%36 = load i32, i32* %13
%37 = tail call i32 @isLesserThan(i32 %35, i32 %36)
%38 = load i32, i32* %13
%39 = load i32, i32* %15
%40 = tail call i32 @isLesserThan(i32 %38, i32 %39)
%41 = tail call i32 @DESCRIBE(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%42 = tail call i32 @WHEN(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%43 = tail call i32 @IF(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%44 = tail call i32 @THEN(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%45 = tail call i32* @malloc(i32 8)
store i32 1, i32* %45
%46 = getelementptr inbounds i32, i32* %45, i64 1
store i32 2, i32* %46
%47 = tail call i32 @troca(i32* %45, i32 0, i32 1)
%48 = load i32, i32* %45
%49 = tail call i32 @isEqual(i32 %48, i32 2)
%50 = load i32, i32* %46
%51 = tail call i32 @isEqual(i32 %50, i32 1)
ret i32 0
}