#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 *, float);
int sscanf(char *, char *, float *, int *);
int main(int argc, char *argv[]) {
  char *p = "  3.49 4.1111 \n\n       3.3333    9.919199";
  float f[4];
  int i, fcou, bcou;
  int totfcou = 0, totbcou = 0;
  while ((fcou = sscanf(p + totbcou, "%f%n", f + totfcou, &bcou)) > 0) {
    totbcou += bcou;
    totfcou += fcou;
  }
  for (i = 0; i < 4; ++i)
    printf("%f\n", f[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x44(%rbp),%rax
add    %rax,%rdi
lea    -0x30(%rbp),%rdx
movslq -0x40(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xeba(%rip),%rsi
lea    -0x3c(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jle    119c <main+0x7c>
mov    -0x3c(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    114f <main+0x2f>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11d1 <main+0xb1>
movslq -0x34(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a3 <main+0x83>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xecd(%rip),%r14
lea    0xef0(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r14,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
jle    118d <main+0x6d>
xor    %ebx,%ebx
lea    0xed1(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebp,%ebp
add    %eax,%ebp
movslq 0xc(%rsp),%rax
movslq %ebx,%rbx
add    %rax,%rbx
mov    %rbx,%rdi
add    %r14,%rdi
movslq %ebp,%rax
lea    (%rsp,%rax,4),%rdx
add    $0x10,%rdx
mov    %r15,%rsi
mov    %r12,%rcx
call   1040 <sscanf@plt>
test   %eax,%eax
jg     1160 <main+0x40>
movss  0x10(%rsp),%xmm0
lea    0xe95(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movss  0x18(%rsp),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movss  0x1c(%rsp),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c" 3.49 4.1111 \0A\0A 3.3333 9.919199\00"
@.str.1 = [5 x i8] c"%f%n\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [4 x float]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %11
store i32 0, i32* %12
br label %13
13: ; preds = %24, %2
%14 = load i8*, i8** %6
%15 = load i32, i32* %12
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %21, i32* %10)
store i32 %22, i32* %9
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %13
%25 = load i32, i32* %10
%26 = load i32, i32* %12
%27 = add nsw i32 %26, %25
store i32 %27, i32* %12
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = add nsw i32 %29, %28
store i32 %30, i32* %11
br label %13
31: ; preds = %13
store i32 0, i32* %8
br label %32
32: ; preds = %41, %31
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 4
br i1 %34, label %35, label %44
35: ; preds = %32
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 %37
%39 = load float, float* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %32
44: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c" 3.49 4.1111 \0A\0A 3.3333 9.919199\00"
@.str.1 = [5 x i8] c"%f%n\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x float]
%4 = alloca i32
%5 = bitcast [4 x float]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 0
%8 = call i32 @sscanf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %7, i32* %4)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %22, %2
%11 = load float, float* %7
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float %11)
%13 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 1
%14 = load float, float* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float %14)
%16 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 2
%17 = load float, float* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float %17)
%19 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 3
%20 = load float, float* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float %20)
ret i32 0
22: ; preds = %2, %22
%23 = phi i32 [ %33, %22 ], [ %8, %2 ]
%24 = phi i32 [ %27, %22 ], [ 0, %2 ]
%25 = phi i32 [ %28, %22 ], [ 0, %2 ]
%26 = load i32, i32* %4
%27 = add nsw i32 %26, %24
%28 = add nsw i32 %23, %25
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds [42 x i8], [42 x i8]* @.str, i64 0, i64 %29
%31 = sext i32 %28 to i64
%32 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 %31
%33 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %32, i32* %4)
%34 = icmp sgt i32 %33, 0
br i1 %34, label %22, label %10
}