#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 */
char ReadChar();
int ReadInt();
void Scanf(char *formatSpecifier, ...) {
  char *argPtr = (char *)(&formatSpecifier) + sizeof(char *);
  int *argInt;
  char *argChar;
  while ((*formatSpecifier) != '\0') {
    if ((*formatSpecifier) == '%') {
      formatSpecifier++;
      if ((*formatSpecifier) == 'd') {
        argInt = (int *)(*((int *)argPtr));
        (*argInt) = ReadInt();
        argPtr += sizeof(int *);
      } else if ((*formatSpecifier) == 'c') {
        argChar = (char *)(*((int *)argPtr));
        (*argChar) = ReadChar();
        argPtr += sizeof(char *);
      } else {
        return;
      }
    }
    formatSpecifier++;
  }
}


x86 assembly (clang, -O0):
<Scanf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fa <Scanf+0xda>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11e9 <Scanf+0xc9>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    119f <Scanf+0x7f>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ReadInt@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e4 <Scanf+0xc4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    11da <Scanf+0xba>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <ReadChar@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11df <Scanf+0xbf>
jmp    11fa <Scanf+0xda>
jmp    11e4 <Scanf+0xc4>
jmp    11e9 <Scanf+0xc9>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1138 <Scanf+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Scanf>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rdi,0x8(%rsp)
lea    0x10(%rsp),%r14
jmp    1148 <Scanf+0x28>
nopl   0x0(%rax,%rax,1)
test   %al,%al
je     1183 <Scanf+0x63>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x25,%al
jne    1140 <Scanf+0x20>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0x63,%al
je     1170 <Scanf+0x50>
cmp    $0x64,%al
jne    1183 <Scanf+0x63>
movslq (%r14),%r15
xor    %eax,%eax
call   1030 <ReadInt@plt>
mov    %eax,(%r15)
jmp    117d <Scanf+0x5d>
xchg   %ax,%ax
movslq (%r14),%r15
xor    %eax,%eax
call   1040 <ReadChar@plt>
mov    %al,(%r15)
add    $0x8,%r14
jmp    1144 <Scanf+0x24>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Scanf(i8* %0, ...) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = bitcast i8** %2 to i8*
%7 = getelementptr inbounds i8, i8* %6, i64 8
store i8* %7, i8** %3
br label %8
8: ; preds = %53, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %56
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 37
br i1 %17, label %18, label %53
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 100
br i1 %24, label %25, label %35
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
store i32* %30, i32** %4
%31 = call i32 (...) @ReadInt()
%32 = load i32*, i32** %4
store i32 %31, i32* %32
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 8
store i8* %34, i8** %3
br label %52
35: ; preds = %18
%36 = load i8*, i8** %2
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 99
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %5
%46 = call signext i8 (...) @ReadChar()
%47 = load i8*, i8** %5
store i8 %46, i8* %47
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 8
store i8* %49, i8** %3
br label %51
50: ; preds = %35
br label %56
51: ; preds = %40
br label %52
52: ; preds = %51, %25
br label %53
53: ; preds = %52, %13
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %2
br label %8
56: ; preds = %50, %8
ret void
}

LLVM IR (-O2):
define void @Scanf(i8* %0, ...) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = getelementptr inbounds i8*, i8** %2, i64 1
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %26, %1
%6 = phi i8* [ %0, %1 ], [ %29, %26 ]
%7 = phi i8* [ %4, %1 ], [ %28, %26 ]
%8 = load i8, i8* %6
switch i8 %8, label %26 [
i8 0, label %30
i8 37, label %9
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
switch i8 %11, label %30 [
i8 100, label %12
i8 99, label %19
]
12: ; preds = %9
%13 = bitcast i8* %7 to i32*
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = tail call i32 (...) @ReadInt()
store i32 %17, i32* %16
%18 = getelementptr inbounds i8, i8* %7, i64 8
br label %26
19: ; preds = %9
%20 = bitcast i8* %7 to i32*
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
%24 = tail call signext i8 (...) @ReadChar()
store i8 %24, i8* %23
%25 = getelementptr inbounds i8, i8* %7, i64 8
br label %26
26: ; preds = %5, %12, %19
%27 = phi i8* [ %10, %12 ], [ %10, %19 ], [ %6, %5 ]
%28 = phi i8* [ %18, %12 ], [ %25, %19 ], [ %7, %5 ]
%29 = getelementptr inbounds i8, i8* %27, i64 1
br label %5
30: ; preds = %5, %9
ret void
}