#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 sscanf(char const *, char const *, float *);
int check_sscanf(const char *s, const char *format, const float n) {
  float f;
  if (sscanf(s, format, &f) != 1) {
    printf("nothing found for \"%s\"\n", s);
    return 1;
  }
  if (f != n) {
    printf("got %f expected %f from \"%s\"\n", f, n, s);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_sscanf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     116d <check_sscanf+0x4d>
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11be <check_sscanf+0x9e>
movss  -0x20(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jne    1187 <check_sscanf+0x67>
jp     1187 <check_sscanf+0x67>
jmp    11b7 <check_sscanf+0x97>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x10(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11be <check_sscanf+0x9e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_sscanf>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    116b <check_sscanf+0x4b>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jne    1150 <check_sscanf+0x30>
jnp    1183 <check_sscanf+0x63>
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    117c <check_sscanf+0x5c>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    1185 <check_sscanf+0x65>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"nothing found for \22%s\22\0A\00"
@.str.1 = [30 x i8] c"got %f expected %f from \22%s\22\0A\00"
define i32 @check_sscanf(i8* %0, i8* %1, float %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca float
%8 = alloca float
store i8* %0, i8** %5
store i8* %1, i8** %6
store float %2, float* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i32 @sscanf(i8* %9, i8* %10, float* %8)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %4
br label %28
16: ; preds = %3
%17 = load float, float* %8
%18 = load float, float* %7
%19 = fcmp une float %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load float, float* %8
%22 = fpext float %21 to double
%23 = load float, float* %7
%24 = fpext float %23 to double
%25 = load i8*, i8** %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %22, double %24, i8* %25)
store i32 1, i32* %4
br label %28
27: ; preds = %16
store i32 0, i32* %4
br label %28
28: ; preds = %27, %20, %13
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@.str = [24 x i8] c"nothing found for \22%s\22\0A\00"
@.str.1 = [30 x i8] c"got %f expected %f from \22%s\22\0A\00"
define i32 @check_sscanf(i8* %0, i8* nocapture %1, float %2) {
%4 = alloca float
%5 = bitcast float* %4 to i8*
%6 = call i32 @sscanf(i8* %0, i8* %1, float* %4)
%7 = icmp eq i32 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %17
10: ; preds = %3
%11 = load float, float* %4
%12 = fcmp une float %11, %2
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = fpext float %11 to double
%15 = fpext float %2 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %14, double %15, i8* %0)
br label %17
17: ; preds = %10, %13, %8
%18 = phi i32 [ 1, %8 ], [ 1, %13 ], [ 0, %10 ]
ret i32 %18
}