#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*/ LC_ALL;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int main() {
  setlocale(LC_ALL, "Portuguese");
  char nome[31];
  char sexo;
  printf("Digite o seu nome: ");
  fgets(nome, 30, stdin);
  nome[strcspn(nome, "\n")] = '\0';
  printf("Digite o seu sexo M (Masculino) ou F (Feminino): ");
  scanf("%c", &sexo);
  if (sexo == 'f' || sexo == 'F')
    printf("\nOlá %s o seu sexo é feminino.", nome);
  else if (sexo == 'm' || sexo == 'M')
    printf("\nOlá %s o seu sexo é masculino.", nome);
  else
    printf("Sexo inválido");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    $0x1e,%esi
call   1050 <fgets@plt>
lea    -0x30(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcspn@plt>
movb   $0x0,-0x30(%rbp,%rax,1)
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x31(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x31(%rbp),%eax
cmp    $0x66,%eax
je     11e6 <main+0x96>
movsbl -0x31(%rbp),%eax
cmp    $0x46,%eax
jne    11fd <main+0xad>
lea    -0x30(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <main+0xf1>
movsbl -0x31(%rbp),%eax
cmp    $0x6d,%eax
je     1217 <main+0xc7>
movsbl -0x31(%rbp),%eax
cmp    $0x4d,%eax
jne    122e <main+0xde>
lea    -0x30(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0xec>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <main+0xf1>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1050 <fgets@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcspn@plt>
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xf(%rsp),%al
and    $0xdf,%al
cmp    $0x4d,%al
je     11dd <main+0x8d>
cmp    $0x46,%al
jne    11f2 <main+0xa2>
lea    0xe7b(%rip),%rdi
jmp    11e4 <main+0x94>
lea    0xe93(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1200 <main+0xb0>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [20 x i8] c"Digite o seu nome: \00"
@stdin = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [50 x i8] c"Digite o seu sexo M (Masculino) ou F (Feminino): \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [33 x i8] c"\0AOl\C3\A1 %s o seu sexo \C3\A9 feminino.\00"
@.str.6 = [34 x i8] c"\0AOl\C3\A1 %s o seu sexo \C3\A9 masculino.\00"
@.str.7 = [15 x i8] c"Sexo inv\C3\A1lido\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [31 x i8]
%3 = alloca i8
store i32 0, i32* %1
%4 = load i32, i32* @LC_ALL
%5 = call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 30, i32 %8)
%10 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
%11 = call i64 @strcspn(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 102
br i1 %17, label %22, label %18
18: ; preds = %0
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 70
br i1 %21, label %22, label %25
22: ; preds = %18, %0
%23 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %39
25: ; preds = %18
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 109
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 77
br i1 %32, label %33, label %36
33: ; preds = %29, %25
%34 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %34)
br label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
br label %39
39: ; preds = %38, %22
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [20 x i8] c"Digite o seu nome: \00"
@stdin = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [50 x i8] c"Digite o seu sexo M (Masculino) ou F (Feminino): \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [33 x i8] c"\0AOl\C3\A1 %s o seu sexo \C3\A9 feminino.\00"
@.str.6 = [34 x i8] c"\0AOl\C3\A1 %s o seu sexo \C3\A9 masculino.\00"
@.str.7 = [15 x i8] c"Sexo inv\C3\A1lido\00"
define i32 @main() {
%1 = alloca [31 x i8]
%2 = alloca i8
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [31 x i8], [31 x i8]* %1, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %5, i32 30, i32 %7)
%9 = call i64 @strcspn(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [31 x i8], [31 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = and i8 %13, -33
switch i8 %14, label %19 [
i8 70, label %15
i8 77, label %17
]
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %5)
br label %21
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %21
21: ; preds = %17, %19, %15
ret i32 0
}