#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 scanf(char *, void *);
int f4_in(const char type, void *ptr) {
  switch (type) {
  case 'c':
    return scanf("%c", ptr);
  case 'd':
    return scanf("%d", ptr);
  case 'f':
    return scanf("%f", ptr);
  case 's':
    return scanf("%s", ptr);
  }
}


x86 assembly (clang, -O0):
<f4_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x10,%eax
ja     11a7 <f4_in+0x97>
mov    -0x18(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
lea    0xeed(%rip),%rdi
call   1030 <scanf@plt>
mov    %eax,-0x4(%rbp)
jmp    11a7 <f4_in+0x97>
mov    -0x10(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1030 <scanf@plt>
mov    %eax,-0x4(%rbp)
jmp    11a7 <f4_in+0x97>
mov    -0x10(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <scanf@plt>
mov    %eax,-0x4(%rbp)
jmp    11a7 <f4_in+0x97>
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1030 <scanf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f4_in>:
mov    %edi,%eax
add    $0xffffff9d,%eax
cmp    $0x10,%eax
ja     113d <f4_in+0x2d>
lea    0xf23(%rip),%rdi
lea    0xed8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0f(%rip),%rdi
jmp    1030 <scanf@plt>
ret
lea    0xf05(%rip),%rdi
jmp    1030 <scanf@plt>
lea    0xefc(%rip),%rdi
jmp    1030 <scanf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @f4_in(i8 signext %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %4
store i8* %1, i8** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %20 [
i32 99, label %8
i32 100, label %11
i32 102, label %14
i32 115, label %17
]
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 %10, i32* %3
br label %20
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 %13, i32* %3
br label %20
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 %16, i32* %3
br label %20
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %8, %11, %14, %17, %2
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @f4_in(i8 signext %0, i8* %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %10 [
i32 99, label %7
i32 100, label %4
i32 102, label %5
i32 115, label %6
]
4: ; preds = %2
br label %7
5: ; preds = %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %6, %5, %4
%8 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32 @scanf(i8* %8, i8* %1)
br label %10
10: ; preds = %7, %2
%11 = phi i32 [ undef, %2 ], [ %9, %7 ]
ret i32 %11
}