#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_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ removeNewLine(char *);
int scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  printf("Please choose a type: \n");
  printf("1 --> int\n"
         "2 --> double\n"
         "3 --> string\n");
  int type;
  if (scanf("%d", &type) != 1) {
    printf("Not a int!");
    exit(EXIT_FAILURE);
  } else {
    switch (type) {
    case 1: {
      int intVal;
      printf("Enter number: ");
      if ((scanf("%d", &intVal)) != 1) {
        printf("Not a int!");
        exit(EXIT_FAILURE);
      } else {
        intVal++;
        printf("%d", intVal);
      }
      break;
    }
    case 2: {
      double dbVal;
      printf("Enter number: ");
      if ((scanf("%lf", &dbVal)) != 1) {
        printf("Not a double!");
        exit(EXIT_FAILURE);
      } else {
        dbVal++;
        printf("%.1lf", dbVal);
      }
      break;
    }
    case 3: {
      char strVal[20];
      printf("Enter string: ");
      getchar();
      fgets(strVal, 20, stdin);
      removeNewLine(strVal);
      printf("%s*", strVal);
      break;
    }
    default:
      printf("The choise may be in range [1..3]!");
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     11c2 <main+0x62>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     11f8 <main+0x98>
jmp    11d6 <main+0x76>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     125c <main+0xfc>
jmp    11e7 <main+0x87>
mov    -0x34(%rbp),%eax
sub    $0x3,%eax
je     12cb <main+0x16b>
jmp    1317 <main+0x1b7>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe38(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     123d <main+0xdd>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1325 <main+0x1c5>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf1(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     12a1 <main+0x141>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movsd  0xd57(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xdb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1325 <main+0x1c5>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    -0x30(%rbp),%rdi
mov    0x2cfd(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1040 <fgets@plt>
lea    -0x30(%rbp),%rdi
call   1060 <removeNewLine@plt>
lea    -0x30(%rbp),%rsi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1325 <main+0x1c5>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132a <main+0x1ca>
mov    0x2c9f(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12be <main+0x14e>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     120c <main+0x9c>
cmp    $0x2,%eax
je     1257 <main+0xe7>
cmp    $0x1,%eax
jne    12a1 <main+0x131>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12be <main+0x14e>
mov    0x10(%rsp),%esi
add    $0x1,%esi
mov    %esi,0x10(%rsp)
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12af <main+0x13f>
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1070 <removeNewLine@plt>
lea    0xe01(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12af <main+0x13f>
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb9(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    12da <main+0x16a>
movsd  0x10(%rsp),%xmm0
addsd  0xd75(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd9f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12af <main+0x13f>
lea    0xda8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
ret
lea    0xd46(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    0xd48(%rip),%rdi
jmp    12c5 <main+0x155>

LLVM IR (-O0):
@.str = [24 x i8] c"Please choose a type: \0A\00"
@.str.1 = [37 x i8] c"1 --> int\0A2 --> double\0A3 --> string\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"Not a int!\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [15 x i8] c"Enter number: \00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [14 x i8] c"Not a double!\00"
@.str.7 = [6 x i8] c"%.1lf\00"
@.str.8 = [15 x i8] c"Enter string: \00"
@stdin = global i32 0
@.str.9 = [4 x i8] c"%s*\00"
@.str.10 = [35 x i8] c"The choise may be in range [1..3]!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca [20 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i32, i32* %2
switch i32 %15, label %54 [
i32 1, label %16
i32 2, label %30
i32 3, label %44
]
16: ; preds = %14
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %16
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24
br label %56
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %4)
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %30
%39 = load double, double* %4
%40 = fadd double %39, 1.000000e+00
store double %40, double* %4
%41 = load double, double* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %41)
br label %43
43: ; preds = %38
br label %56
44: ; preds = %14
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%46 = call i32 (...) @getchar()
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%48 = load i32, i32* @stdin
%49 = call i32 @fgets(i8* %47, i32 20, i32 %48)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%51 = call i32 @removeNewLine(i8* %50)
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %52)
br label %56
54: ; preds = %14
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
br label %56
56: ; preds = %54, %44, %43, %29
br label %57
57: ; preds = %56
%58 = load i32, i32* @EXIT_SUCCESS
ret i32 %58
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"Not a int!\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [15 x i8] c"Enter number: \00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [14 x i8] c"Not a double!\00"
@.str.7 = [6 x i8] c"%.1lf\00"
@.str.8 = [15 x i8] c"Enter string: \00"
@stdin = global i32 0
@.str.9 = [4 x i8] c"%s*\00"
@.str.10 = [35 x i8] c"The choise may be in range [1..3]!\00"
@EXIT_SUCCESS = global i32 0
@str = [23 x i8] c"Please choose a type: \00"
@str.11 = [36 x i8] c"1 --> int\0A2 --> double\0A3 --> string\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [20 x i8]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i32, i32* %1
switch i32 %15, label %50 [
i32 1, label %16
i32 2, label %29
i32 3, label %42
]
16: ; preds = %14
%17 = bitcast i32* %2 to i8*
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%20 = icmp eq i32 %19, 1
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %52
29: ; preds = %14
%30 = bitcast double* %3 to i8*
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %3)
%33 = icmp eq i32 %32, 1
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %29
%39 = load double, double* %3
%40 = fadd double %39, 1.000000e+00
store double %40, double* %3
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %40)
br label %52
42: ; preds = %14
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%45 = call i32 (...) @getchar()
%46 = load i32, i32* @stdin
%47 = call i32 @fgets(i8* %43, i32 20, i32 %46)
%48 = call i32 @removeNewLine(i8* %43)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %43)
br label %52
50: ; preds = %14
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
br label %52
52: ; preds = %25, %38, %42, %50
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}