#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);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ string_alunos(char **, int);
int main() {
  int num;
  printf("Quantas strings voce deseja armazenar? ");
  scanf("%d", &num);
  char *strings[num];
  printf("\n");
  printf("Digite as palavras:\n");
  for (int i = 0; i < num; i++) {
    strings[i] = malloc(31);
    if (strings[i] != NULL)
      scanf("%30s[^\n]", strings[i]);
    else {
      printf("*** Não foi possível alocar memoria! ***");
      exit(1);
    }
  }
  string_alunos(strings, num);
  for (int i = 0; i < num; i++)
    free(strings[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124f <main+0xef>
mov    $0x1f,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1226 <main+0xc6>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
jmp    123c <main+0xdc>
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1241 <main+0xe1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d3 <main+0x73>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <string_alunos@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128d <main+0x12d>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1262 <main+0x102>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe6a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe86(%rip),%rdi
lea    -0x24(%rbp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %rsp,%r15
mov    -0x24(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe86(%rip),%rdi
call   1050 <puts@plt>
mov    -0x24(%rbp),%esi
test   %esi,%esi
jle    121d <main+0x9d>
lea    0xe3f(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    $0x1f,%edi
call   1080 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     1258 <main+0xd8>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rsi
cmp    %rsi,%rbx
jl     11f0 <main+0x70>
mov    %r12,%rdi
call   1070 <string_alunos@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1246 <main+0xc6>
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xb0>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd5(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Quantas strings voce deseja armazenar? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [21 x i8] c"Digite as palavras:\0A\00"
@.str.4 = [9 x i8] c"%30s[^\0A]\00"
@.str.5 = [43 x i8] c"*** N\C3\A3o foi poss\C3\ADvel alocar memoria! ***\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8*, i64 %10
store i64 %10, i64* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %15
15: ; preds = %39, %0
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %42
19: ; preds = %15
%20 = call i8* @malloc(i32 31)
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %12, i64 %22
store i8* %20, i8** %23
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %12, i64 %25
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %35
29: ; preds = %19
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %12, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %38
35: ; preds = %19
%36 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %15
42: ; preds = %15
%43 = load i32, i32* %2
%44 = call i32 @string_alunos(i8** %12, i32 %43)
store i32 0, i32* %6
br label %45
45: ; preds = %55, %42
%46 = load i32, i32* %6
%47 = load i32, i32* %2
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %12, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 @free(i8* %53)
br label %55
55: ; preds = %49
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %45
58: ; preds = %45
%59 = load i8*, i8** %3
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [40 x i8] c"Quantas strings voce deseja armazenar? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"%30s[^\0A]\00"
@.str.5 = [43 x i8] c"*** N\C3\A3o foi poss\C3\ADvel alocar memoria! ***\00"
@str = [20 x i8] c"Digite as palavras:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i8*, i64 %6
%9 = call i32 @putchar(i32 10)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %23, %0
%14 = phi i32 [ %11, %0 ], [ %26, %23 ]
%15 = call i32 @string_alunos(i8** %8, i32 %14)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %33, label %32
18: ; preds = %0, %23
%19 = phi i64 [ %25, %23 ], [ 0, %0 ]
%20 = call dereferenceable_or_null(31) i8* @malloc(i32 31)
%21 = getelementptr inbounds i8*, i8** %8, i64 %19
store i8* %20, i8** %21
%22 = icmp eq i8* %20, null
br i1 %22, label %29, label %23
23: ; preds = %18
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%25 = add nuw nsw i64 %19, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %18, label %13
29: ; preds = %18
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %33, %13
ret i32 0
33: ; preds = %13, %33
%34 = phi i64 [ %38, %33 ], [ 0, %13 ]
%35 = getelementptr inbounds i8*, i8** %8, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @free(i8* %36)
%38 = add nuw nsw i64 %34, 1
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %38, %40
br i1 %41, label %33, label %32
}