#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 const *, char const *, char const *, double);
int /*<<< orphan*/ sscanf(char const *, char const *, double *);
int main(void) {
  double d;
  size_t i;
  const char *read_format = "%lf%*s";
  const char *write_format = "sscanf(\"%s\", \"%s\", &d); d == %lf\n";
  const char *strs[] = {
      "123.45 blah",
      "123.45,678",
      "123,456.78",
      "123.45",
  };
  for (i = 0; i < 4; i++) {
    sscanf(strs[i], read_format, &d);
    printf(write_format, strs[i], read_format, d);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cb1(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2cae(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cab(%rip),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x4,-0x18(%rbp)
jae    11c6 <main+0xa6>
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x10(%rbp),%xmm0
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <main+0x59>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xefa(%rip),%r12
lea    0xeca(%rip),%rbx
mov    %rsp,%r14
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
lea    0xeb4(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xecd(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xeb0(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xe93(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%lf%*s\00"
@.str.1 = [34 x i8] c"sscanf(\22%s\22, \22%s\22, &d); d == %lf\0A\00"
@.str.2 = [12 x i8] c"123.45 blah\00"
@.str.3 = [11 x i8] c"123.45,678\00"
@.str.4 = [11 x i8] c"123,456.78\00"
@.str.5 = [7 x i8] c"123.45\00"
@__const.main.strs = [4 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0)]
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [4 x i8*]
store i32 0, i32* %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8** %5
%7 = bitcast [4 x i8*]* %6 to i8*
store i64 0, i64* %3
br label %8
8: ; preds = %24, %0
%9 = load i64, i64* %3
%10 = icmp ult i64 %9, 4
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i64, i64* %3
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = load i8*, i8** %4
%16 = call i32 @sscanf(i8* %14, i8* %15, double* %2)
%17 = load i8*, i8** %5
%18 = load i64, i64* %3
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %4
%22 = load double, double* %2
%23 = call i32 @printf(i8* %17, i8* %20, i8* %21, double %22)
br label %24
24: ; preds = %11
%25 = load i64, i64* %3
%26 = add i64 %25, 1
store i64 %26, i64* %3
br label %8
27: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%lf%*s\00"
@.str.1 = [34 x i8] c"sscanf(\22%s\22, \22%s\22, &d); d == %lf\0A\00"
@.str.2 = [12 x i8] c"123.45 blah\00"
@.str.3 = [11 x i8] c"123.45,678\00"
@.str.4 = [11 x i8] c"123,456.78\00"
@.str.5 = [7 x i8] c"123.45\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @sscanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %4)
%6 = call i32 @sscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %1)
%7 = load double, double* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call i32 @sscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %1)
%10 = load double, double* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %10)
%12 = call i32 @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %1)
%13 = load double, double* %1
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %13)
ret i32 0
}