#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*/ insert_into_a_sorted_array(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int array[50] = {1, 3, 5, 7, 9, 11, 13};
  int num = 6;
  int i;
  insert_into_a_sorted_array(array, 50, num);
  for (i = 0; array[i] != 0; i++) {
    printf("%d\t", array[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0xc8,%edx
call   1040 <memcpy@plt>
movl   $0x6,-0xd4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%edx
mov    $0x32,%esi
call   1050 <insert_into_a_sorted_array@plt>
movl   $0x0,-0xd8(%rbp)
movslq -0xd8(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
je     11c8 <main+0x98>
movslq -0xd8(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1185 <main+0x55>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    $0xc8,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x6,%edx
call   1050 <insert_into_a_sorted_array@plt>
mov    (%rsp),%esi
test   %esi,%esi
je     1192 <main+0x62>
lea    0x4(%rsp),%rbx
lea    0xf52(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%rbx),%esi
add    $0x4,%rbx
test   %esi,%esi
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.array = <{ i32, i32, i32, i32, i32, i32, i32, [43 x i32] }> <{ i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, [43 x i32] zeroinitializer }>
@.str = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [50 x i32]* %2 to i8*
store i32 6, i32* %3
%6 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @insert_into_a_sorted_array(i32* %6, i32 50, i32 %7)
store i32 0, i32* %4
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %15
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %9
24: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = <{ i32, i32, i32, i32, i32, i32, i32, [43 x i32] }> <{ i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, [43 x i32] zeroinitializer }>
@.str = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
%3 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%4 = call i32 @insert_into_a_sorted_array(i32* %3, i32 50, i32 6)
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %11, %7 ], [ 0, %0 ]
%9 = phi i32 [ %13, %7 ], [ %5, %0 ]
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = add nuw i64 %8, 1
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %0
ret i32 0
}