#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*/ echo(int);
scalar_t__ getch();
char *leerUnStringArbitrariamenteLargo();
int /*<<< orphan*/ printf(char *, ...);
char *readFloatAsString();
char *readPassword(int);
int main() {
  int op = 0;
  char *s;
  printf("Que deseas introducir?\n1)string\n2)password 5 chars\n3)float\n");
  op = (int)(getch() - '0');
  echo(op + '0');
  printf("\n");
  switch (op) {
  case 1:
    printf("Introduce un string arbitrariamente largo:\n");
    s = leerUnStringArbitrariamenteLargo();
    break;
  case 2:
    printf("Introduce un password de 5 chars maximo:\n");
    s = readPassword(5);
    break;
  case 3:
    printf("Introduce un float:\n");
    s = readFloatAsString();
    break;
  }
  printf("input:%s\n", s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe83(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
call   1070 <getch@plt>
add    $0xffffffd0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
add    $0x30,%edi
call   1030 <echo@plt>
mov    -0x15(%rbp),%al
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     11e5 <main+0x85>
jmp    11c3 <main+0x63>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1203 <main+0xa3>
jmp    11d4 <main+0x74>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1224 <main+0xc4>
jmp    123d <main+0xdd>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <leerUnStringArbitrariamenteLargo@plt>
mov    %rax,-0x10(%rbp)
jmp    123d <main+0xdd>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
call   1080 <readPassword@plt>
mov    %rax,-0x10(%rbp)
jmp    123d <main+0xdd>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <readFloatAsString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe82(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1040 <echo@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x33,%ebx
je     11ca <main+0x4a>
cmp    $0x32,%ebx
jne    11df <main+0x5f>
lea    0xea0(%rip),%rdi
call   1050 <puts@plt>
mov    $0x5,%edi
call   10a0 <readPassword@plt>
jmp    11f2 <main+0x72>
lea    0xe74(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1080 <readFloatAsString@plt>
jmp    11f2 <main+0x72>
lea    0xe9c(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <leerUnStringArbitrariamenteLargo@plt>
lea    0xe07(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Que deseas introducir?\0A1)string\0A2)password 5 chars\0A3)float\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [44 x i8] c"Introduce un string arbitrariamente largo:\0A\00"
@.str.3 = [42 x i8] c"Introduce un password de 5 chars maximo:\0A\00"
@.str.4 = [21 x i8] c"Introduce un float:\0A\00"
@.str.5 = [10 x i8] c"input:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%5 = call i64 (...) @getch()
%6 = sub nsw i64 %5, 48
%7 = trunc i64 %6 to i32
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = add nsw i32 %8, 48
%10 = call i32 @echo(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %2
switch i32 %12, label %22 [
i32 1, label %13
i32 2, label %16
i32 3, label %19
]
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%15 = call i8* (...) @leerUnStringArbitrariamenteLargo()
store i8* %15, i8** %3
br label %22
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%18 = call i8* @readPassword(i32 5)
store i8* %18, i8** %3
br label %22
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%21 = call i8* (...) @readFloatAsString()
store i8* %21, i8** %3
br label %22
22: ; preds = %0, %19, %16, %13
%23 = load i8*, i8** %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.5 = [10 x i8] c"input:%s\0A\00"
@str = [59 x i8] c"Que deseas introducir?\0A1)string\0A2)password 5 chars\0A3)float\00"
@str.6 = [20 x i8] c"Introduce un float:\00"
@str.7 = [41 x i8] c"Introduce un password de 5 chars maximo:\00"
@str.8 = [43 x i8] c"Introduce un string arbitrariamente largo:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 (...) @getch()
%3 = trunc i64 %2 to i32
%4 = tail call i32 @echo(i32 %3)
%5 = tail call i32 @putchar(i32 10)
switch i32 %3, label %15 [
i32 49, label %6
i32 50, label %9
i32 51, label %12
]
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.8, i64 0, i64 0))
%8 = tail call i8* (...) @leerUnStringArbitrariamenteLargo()
br label %16
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i8* @readPassword(i32 5)
br label %16
12: ; preds = %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%14 = tail call i8* (...) @readFloatAsString()
br label %16
15: ; preds = %0
unreachable
16: ; preds = %12, %9, %6
%17 = phi i8* [ %14, %12 ], [ %11, %9 ], [ %8, %6 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %17)
ret i32 0
}