#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void inserir(int vet[10], int *ini, int *fim, int *num) {
  if (*num == 10) {
    printf("\n\a\tA fila esta cheia!\n");
    return;
  }
  int val;
  printf("\n\tDigite um valor -> ");
  scanf("%d", &val);
  if (*num == 0) {
    ++(*ini);
    ++(*fim);
  } else if (*fim == 10 - 1)
    *fim = 0;
  else
    ++(*fim);
  vet[*fim] = val;
  ++(*num);
  return;
}


x86 assembly (clang, -O0):
<inserir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0xa,(%rax)
jne    1156 <inserir+0x36>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
jmp    11e2 <inserir+0xc2>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    119a <inserir+0x7a>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11c6 <inserir+0xa6>
mov    -0x18(%rbp),%rax
cmpl   $0x9,(%rax)
jne    11b6 <inserir+0x96>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11c1 <inserir+0xa1>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11c6 <inserir+0xa6>
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inserir>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpl   $0xa,(%rcx)
jne    1154 <inserir+0x24>
lea    0xed5(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,(%rbx)
je     1192 <inserir+0x62>
mov    (%r15),%ecx
lea    0x1(%rcx),%edx
xor    %eax,%eax
cmp    $0x9,%ecx
cmovne %edx,%eax
jmp    119d <inserir+0x6d>
addl   $0x1,(%r12)
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
mov    0x4(%rsp),%ecx
cltq
mov    %ecx,(%r14,%rax,4)
addl   $0x1,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A\07\09A fila esta cheia!\0A\00"
@.str.1 = [22 x i8] c"\0A\09Digite um valor -> \00"
@.str.2 = [3 x i8] c"%d\00"
define void @inserir(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i32*, i32** %8
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %49
15: ; preds = %4
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%18 = load i32*, i32** %8
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %15
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 1
store i32 %24, i32* %22
%25 = load i32*, i32** %7
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
br label %39
28: ; preds = %15
%29 = load i32*, i32** %7
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 9
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32*, i32** %7
store i32 0, i32* %33
br label %38
34: ; preds = %28
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %35
br label %38
38: ; preds = %34, %32
br label %39
39: ; preds = %38, %21
%40 = load i32, i32* %9
%41 = load i32*, i32** %5
%42 = load i32*, i32** %7
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %41, i64 %44
store i32 %40, i32* %45
%46 = load i32*, i32** %8
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
br label %49
49: ; preds = %39, %13
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"\0A\09Digite um valor -> \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [22 x i8] c"\0A\07\09A fila esta cheia!\00"
define void @inserir(i32* nocapture writeonly %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3) {
%5 = alloca i32
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 10
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %33
10: ; preds = %4
%11 = bitcast i32* %5 to i8*
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
br label %26
21: ; preds = %10
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 9
%24 = add nsw i32 %22, 1
%25 = select i1 %23, i32 0, i32 %24
br label %26
26: ; preds = %21, %16
%27 = phi i32 [ %20, %16 ], [ %25, %21 ]
store i32 %27, i32* %2
%28 = load i32, i32* %5
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i32, i32* %0, i64 %29
store i32 %28, i32* %30
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %33
33: ; preds = %26, %8
ret void
}