#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*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, char, float);
int /*<<< orphan*/ sscanf(char *, char *, int *, char *, float *);
int main() {
  int i = 10;
  char ch = 'A';
  char str[20];
  float a = 3.14;
  printf("%d %c %f \n", i, ch, a);
  sprintf(str, "%d %c %f \n", i, ch, a);
  printf("%s \n", str);
  int d = 9;
  char e = 'B';
  float f = 6.0;
  printf("Before reading values from string str we have %d %c %f \n", d, e, f);
  sscanf(str, "%d %c %f", &d, &e, &f);
  printf("After reading values from string we have %d %c %f \n", d, e, f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movb   $0x41,-0x9(%rbp)
movss  0xeb2(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%esi
movsbl -0x9(%rbp),%edx
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf0a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x9(%rbp),%al
movss  -0x24(%rbp),%xmm0
lea    0xeed(%rip),%rsi
movsbl %al,%ecx
call   1050 <sprintf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x9,-0x28(%rbp)
movb   $0x42,-0x29(%rbp)
movss  0xe48(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%esi
movsbl -0x29(%rbp),%edx
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe60(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x29(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <sscanf@plt>
mov    -0x28(%rbp),%esi
movsbl -0x29(%rbp),%edx
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf46(%rip),%rbx
movsd  0xeba(%rip),%xmm0
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x41,%edx
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x10(%rsp),%r14
movss  0xea9(%rip),%xmm0
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0x41,%ecx
call   1050 <sprintf@plt>
lea    0xe91(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x9,0xc(%rsp)
movb   $0x42,0x7(%rsp)
movl   $0x40c00000,0x8(%rsp)
40
lea    0xe70(%rip),%rdi
movsd  0xe57(%rip),%xmm0
mov    $0x9,%esi
mov    $0x42,%edx
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x7(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r14,%rdi
call   1040 <sscanf@plt>
mov    0xc(%rsp),%esi
movsbl 0x7(%rsp),%edx
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%d %c %f \0A\00"
@.str.1 = [5 x i8] c"%s \0A\00"
@.str.2 = [57 x i8] c"Before reading values from string str we have %d %c %f \0A\00"
@.str.3 = [9 x i8] c"%d %c %f\00"
@.str.4 = [52 x i8] c"After reading values from string we have %d %c %f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca [20 x i8]
%5 = alloca float
%6 = alloca i32
%7 = alloca i8
%8 = alloca float
store i32 0, i32* %1
store i32 10, i32* %2
store i8 65, i8* %3
store float 0x40091EB860000000, float* %5
%9 = load i32, i32* %2
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = load float, float* %5
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, double %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* %2
%17 = load i8, i8* %3
%18 = load float, float* %5
%19 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %16, i8 signext %17, float %18)
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 9, i32* %6
store i8 66, i8* %7
store float 6.000000e+00, float* %8
%22 = load i32, i32* %6
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %24, double %26)
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %6, i8* %7, float* %8)
%30 = load i32, i32* %6
%31 = load i8, i8* %7
%32 = sext i8 %31 to i32
%33 = load float, float* %8
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %32, double %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%d %c %f \0A\00"
@.str.1 = [5 x i8] c"%s \0A\00"
@.str.2 = [57 x i8] c"Before reading values from string str we have %d %c %f \0A\00"
@.str.3 = [9 x i8] c"%d %c %f\00"
@.str.4 = [52 x i8] c"After reading values from string we have %d %c %f \0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = alloca i8
%4 = alloca float
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i32 65, double 0x40091EB860000000)
%7 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i8 signext 65, float 0x40091EB860000000)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = bitcast i32* %2 to i8*
store i32 9, i32* %2
store i8 66, i8* %3
%10 = bitcast float* %4 to i8*
store float 6.000000e+00, float* %4
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 9, i32 66, double 6.000000e+00)
%12 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %2, i8* %3, float* %4)
%13 = load i32, i32* %2
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = load float, float* %4
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %15, double %17)
ret i32 0
}