#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*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  int choice;
  printf("Please choose a type:\n");
  printf("1 --> int\n");
  printf("2 --> double\n");
  printf("3 --> string\n");
  scanf("%d", &choice);
  if (choice == 1) {
    int intNum;
    printf("Please enter an integer: ");
    scanf("%d", &intNum);
    printf("%d", intNum + 1);
  } else if (choice == 2) {
    double doubleNum;
    printf("Please enter an integer: ");
    scanf("%lf", &doubleNum);
    printf("%.1f", doubleNum + 1);
  } else if (choice == 3) {
    char str[100];
    printf("Please enter a  string: ");
    fgets(str, 100, stdin);
    if (str[0] == '\n') {
      fgets(str, 100, stdin);
    }
    int length = strlen(str) - 1;
    if (str[length] == '\n') {
      str[length] = '\0';
    }
    printf("%s*", str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11df <main+0x9f>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12cb <main+0x18b>
cmpl   $0x2,-0x8(%rbp)
jne    1229 <main+0xe9>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsd  0xdef(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12c6 <main+0x186>
cmpl   $0x3,-0x8(%rbp)
jne    12c1 <main+0x181>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
movsbl -0x80(%rbp),%eax
cmp    $0xa,%eax
jne    127c <main+0x13c>
lea    -0x80(%rbp),%rdi
mov    0x2d78(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x84(%rbp)
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    12af <main+0x16f>
movslq -0x84(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c6 <main+0x186>
jmp    12cb <main+0x18b>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     122e <main+0xde>
cmp    $0x2,%eax
je     11ef <main+0x9f>
cmp    $0x1,%eax
jne    129a <main+0x14a>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3e(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x10(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    129a <main+0x14a>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsd  0x10(%rsp),%xmm0
addsd  0xde2(%rip),%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    129a <main+0x14a>
lea    0xdf9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2da5(%rip),%r14
mov    (%r14),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
cmpb   $0xa,0x10(%rsp)
jne    1271 <main+0x121>
mov    (%r14),%edx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1287 <main+0x137>
movb   $0x0,0xf(%rsp,%rax,1)
lea    0xdb9(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Please choose a type:\0A\00"
@.str.1 = [11 x i8] c"1 --> int\0A\00"
@.str.2 = [14 x i8] c"2 --> double\0A\00"
@.str.3 = [14 x i8] c"3 --> string\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [26 x i8] c"Please enter an integer: \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [5 x i8] c"%.1f\00"
@.str.8 = [25 x i8] c"Please enter a string: \00"
@stdin = global i32 0
@.str.9 = [4 x i8] c"%s*\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca [100 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %20
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %64
20: ; preds = %0
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %4)
%26 = load double, double* %4
%27 = fadd double %26, 1.000000e+00
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %27)
br label %63
29: ; preds = %20
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %62
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 100, i32 %35)
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %45
41: ; preds = %32
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%43 = load i32, i32* @stdin
%44 = call i32 @fgets(i8* %42, i32 100, i32 %43)
br label %45
45: ; preds = %41, %32
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = sub nsw i32 %47, 1
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 10
br i1 %54, label %55, label %59
55: ; preds = %45
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %57
store i8 0, i8* %58
br label %59
59: ; preds = %55, %45
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %29
br label %63
63: ; preds = %62, %23
br label %64
64: ; preds = %63, %14
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [26 x i8] c"Please enter an integer: \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [5 x i8] c"%.1f\00"
@.str.8 = [25 x i8] c"Please enter a string: \00"
@stdin = global i32 0
@.str.9 = [4 x i8] c"%s*\00"
@str = [22 x i8] c"Please choose a type:\00"
@str.10 = [10 x i8] c"1 --> int\00"
@str.11 = [13 x i8] c"2 --> double\00"
@str.12 = [13 x i8] c"3 --> string\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [100 x i8]
%5 = bitcast i32* %1 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %46 [
i32 1, label %12
i32 2, label %19
i32 3, label %26
]
12: ; preds = %0
%13 = bitcast i32* %2 to i8*
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %46
19: ; preds = %0
%20 = bitcast double* %3 to i8*
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %3)
%23 = load double, double* %3
%24 = fadd double %23, 1.000000e+00
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double %24)
br label %46
26: ; preds = %0
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%29 = load i32, i32* @stdin
%30 = call i32 @fgets(i8* %27, i32 100, i32 %29)
%31 = load i8, i8* %27
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32, i32* @stdin
%35 = call i32 @fgets(i8* %27, i32 100, i32 %34)
br label %36
36: ; preds = %33, %26
%37 = call i32 @strlen(i8* %27)
%38 = add nsw i32 %37, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %36
store i8 0, i8* %40
br label %44
44: ; preds = %43, %36
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %27)
br label %46
46: ; preds = %0, %19, %44, %12
ret i32 0
}