#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  struct {
    int cod;
    char nome_da_obra[41];
    char nome_do_autor[41];
    char nome_da_editora[41];
  } livro[5];
  for (int i = 0; i < 5; i++) {
    printf("\n---------- Cadastro dos Livros -----------\n");
    livro[i].cod = i;
    printf("Insira o nome da Obra: ");
    fgets(livro[i].nome_da_obra, 40, stdin);
    printf("Insira o nome do autor: ");
    fgets(livro[i].nome_do_autor, 40, stdin);
    printf("Insira o nome da Editora: ");
    fgets(livro[i].nome_da_editora, 40, stdin);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x294(%rbp)
cmpl   $0x5,-0x294(%rbp)
jge    122e <main+0x10e>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x294(%rbp),%ecx
movslq -0x294(%rbp),%rdx
lea    -0x290(%rbp),%rax
shl    $0x7,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
movslq -0x294(%rbp),%rax
lea    -0x290(%rbp),%rdi
shl    $0x7,%rax
add    %rax,%rdi
add    $0x4,%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1040 <fgets@plt>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movslq -0x294(%rbp),%rax
lea    -0x290(%rbp),%rdi
shl    $0x7,%rax
add    %rax,%rdi
add    $0x2d,%rdi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1040 <fgets@plt>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
movslq -0x294(%rbp),%rax
lea    -0x290(%rbp),%rdi
shl    $0x7,%rax
add    %rax,%rdi
add    $0x56,%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1040 <fgets@plt>
mov    -0x294(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x294(%rbp)
jmp    113c <main+0x1c>
mov    -0x4(%rbp),%eax
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x288,%rsp
lea    0x2d(%rsp),%rbx
xor    %ebp,%ebp
lea    0xeb1(%rip),%r15
mov    0x2e92(%rip),%r14
lea    0xebb(%rip),%r12
lea    0xecd(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,-0x2d(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
lea    -0x29(%rbx),%rdi
mov    (%r14),%edx
mov    $0x28,%esi
call   1050 <fgets@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x28,%esi
call   1050 <fgets@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
lea    0x29(%rbx),%rdi
mov    (%r14),%edx
mov    $0x28,%esi
call   1050 <fgets@plt>
add    $0x1,%rbp
sub    $0xffffffffffffff80,%rbx
cmp    $0x5,%rbp
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x288,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i32, [41 x i8], [41 x i8], [41 x i8] }
@.str = [45 x i8] c"\0A---------- Cadastro dos Livros -----------\0A\00"
@.str.1 = [24 x i8] c"Insira o nome da Obra: \00"
@stdin = global i32 0
@.str.2 = [25 x i8] c"Insira o nome do autor: \00"
@.str.3 = [27 x i8] c"Insira o nome da Editora: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x %struct.anon]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %38, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 5
br i1 %6, label %7, label %41
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %2, i64 0, i64 %11
%13 = getelementptr inbounds %struct.anon, %struct.anon* %12, i32 0, i32 0
store i32 %9, i32* %13
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %2, i64 0, i64 %16
%18 = getelementptr inbounds %struct.anon, %struct.anon* %17, i32 0, i32 1
%19 = getelementptr inbounds [41 x i8], [41 x i8]* %18, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 40, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %2, i64 0, i64 %24
%26 = getelementptr inbounds %struct.anon, %struct.anon* %25, i32 0, i32 2
%27 = getelementptr inbounds [41 x i8], [41 x i8]* %26, i64 0, i64 0
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %27, i32 40, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %2, i64 0, i64 %32
%34 = getelementptr inbounds %struct.anon, %struct.anon* %33, i32 0, i32 3
%35 = getelementptr inbounds [41 x i8], [41 x i8]* %34, i64 0, i64 0
%36 = load i32, i32* @stdin
%37 = call i32 @fgets(i8* %35, i32 40, i32 %36)
br label %38
38: ; preds = %7
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %4
41: ; preds = %4
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
%struct.anon = type { i32, [41 x i8], [41 x i8], [41 x i8] }
@.str.1 = [24 x i8] c"Insira o nome da Obra: \00"
@stdin = global i32 0
@.str.2 = [25 x i8] c"Insira o nome do autor: \00"
@.str.3 = [27 x i8] c"Insira o nome da Editora: \00"
@str = [44 x i8] c"\0A---------- Cadastro dos Livros -----------\00"
define i32 @main() {
%1 = alloca [5 x %struct.anon]
%2 = bitcast [5 x %struct.anon]* %1 to i8*
br label %4
3: ; preds = %4
ret i32 0
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %21, %4 ]
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%7 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %1, i64 0, i64 %5, i32 0
%8 = trunc i64 %5 to i32
store i32 %8, i32* %7
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %1, i64 0, i64 %5, i32 1, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 40, i32 %11)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %1, i64 0, i64 %5, i32 2, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 40, i32 %15)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* %1, i64 0, i64 %5, i32 3, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %18, i32 40, i32 %19)
%21 = add nuw nsw i64 %5, 1
%22 = icmp eq i64 %21, 5
br i1 %22, label %3, label %4
}