#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);
int sscanf(char const *, char *, ...);
int main() {
  int ret, err = 0, e1, e2;
  double d1, d2;
  const char j1[] = "3.0E+10", j2[] = "12E-01-0.1E-2";
  const char a1[] = "3.0", a2[] = "-12,1000";
  ret = sscanf(j1, "%11lf", &d1);
  if (ret != 1) {
    printf("Error wrong sscanf double return %d.\n", ret);
    err++;
  }
  ret = sscanf(j2, "%11lf%11lf", &d1, &d2);
  if (ret != 2) {
    printf("Error wrong sscanf double return %d.\n", ret);
    err++;
  }
  ret = sscanf(a1, "%1d", &e1);
  if (ret != 1) {
    printf("Error wrong sscanf int return %d.\n", ret);
    err++;
  }
  ret = sscanf(a2, "%1d%2d", &e1, &e2);
  if (ret != 2) {
    printf("Error wrong sscanf int return %d.\n", ret);
    err++;
  }
  if (err)
    return err;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x3e(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x36(%rbp)
mov    0xeb8(%rip),%ax
mov    %ax,-0x32(%rbp)
mov    0xeb0(%rip),%eax
mov    %eax,-0x42(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x4b(%rbp)
mov    0xea8(%rip),%al
mov    %al,-0x43(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11b8 <main+0x98>
mov    -0x8(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x3e(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f7 <main+0xd7>
mov    -0x8(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x42(%rbp),%rdi
lea    0xe52(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1232 <main+0x112>
mov    -0x8(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x4b(%rbp),%rdi
lea    0xe3e(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1271 <main+0x151>
mov    -0x8(%rbp),%esi
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1286 <main+0x166>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128d <main+0x16d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movabs $0x30312b45302e33,%rax
mov    %rax,0x20(%rsp)
movabs $0x322d45312e302d,%rax
mov    %rax,0x3e(%rsp)
movabs $0x302d31302d453231,%rax
31 2d 30
mov    %rax,0x38(%rsp)
movl   $0x302e33,0x8(%rsp)
movabs $0x303030312c32312d,%rax
30 30 30
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0xecd(%rip),%rsi
xor    %ebx,%ebx
lea    0x20(%rsp),%rdi
lea    0x28(%rsp),%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11a0 <main+0x80>
lea    0xe83(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
lea    0xe96(%rip),%rsi
lea    0x38(%rsp),%rdi
lea    0x28(%rsp),%rdx
lea    0x48(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11d3 <main+0xb3>
lea    0xe4e(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
lea    0xe6e(%rip),%rsi
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1201 <main+0xe1>
lea    0xe55(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
lea    0xe67(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x34(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     1234 <main+0x114>
lea    0xe22(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.j1 = [8 x i8] c"3.0E+10\00"
@__const.main.j2 = [14 x i8] c"12E-01-0.1E-2\00"
@__const.main.a1 = [4 x i8] c"3.0\00"
@__const.main.a2 = [9 x i8] c"-12,1000\00"
@.str = [6 x i8] c"%11lf\00"
@.str.1 = [38 x i8] c"Error wrong sscanf double return %d.\0A\00"
@.str.2 = [11 x i8] c"%11lf%11lf\00"
@.str.3 = [4 x i8] c"%1d\00"
@.str.4 = [35 x i8] c"Error wrong sscanf int return %d.\0A\00"
@.str.5 = [7 x i8] c"%1d%2d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca [8 x i8]
%9 = alloca [14 x i8]
%10 = alloca [4 x i8]
%11 = alloca [9 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%12 = bitcast [8 x i8]* %8 to i8*
%13 = bitcast [14 x i8]* %9 to i8*
%14 = bitcast [4 x i8]* %10 to i8*
%15 = bitcast [9 x i8]* %11 to i8*
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %6)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %0
%21 = load i32, i32* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %20, %0
%26 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %6, double* %7)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = icmp ne i32 %28, 2
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* %2
%32 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %35
35: ; preds = %30, %25
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %4)
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i32, i32* %2
%42 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %45
45: ; preds = %40, %35
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%47 = call i32 (i8*, i8*, ...) @sscanf(i8* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5)
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 2
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i32, i32* %2
%52 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %55
55: ; preds = %50, %45
%56 = load i32, i32* %3
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = load i32, i32* %3
store i32 %59, i32* %1
br label %61
60: ; preds = %55
store i32 0, i32* %1
br label %61
61: ; preds = %60, %58
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@__const.main.j2 = [14 x i8] c"12E-01-0.1E-2\00"
@__const.main.a2 = [9 x i8] c"-12,1000\00"
@.str = [6 x i8] c"%11lf\00"
@.str.1 = [38 x i8] c"Error wrong sscanf double return %d.\0A\00"
@.str.2 = [11 x i8] c"%11lf%11lf\00"
@.str.3 = [4 x i8] c"%1d\00"
@.str.4 = [35 x i8] c"Error wrong sscanf int return %d.\0A\00"
@.str.5 = [7 x i8] c"%1d%2d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca [14 x i8]
%7 = alloca i32
%8 = alloca [9 x i8]
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast double* %3 to i8*
%12 = bitcast double* %4 to i8*
%13 = bitcast i64* %5 to i8*
store i64 13564860796251699, i64* %5
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %6, i64 0, i64 0
%15 = bitcast i32* %7 to i8*
store i32 3157555, i32* %7
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %21, label %19
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %21
21: ; preds = %19, %0
%22 = phi i32 [ 1, %19 ], [ 0, %0 ]
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %3, double* %4)
%24 = icmp eq i32 %23, 2
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%27 = add nuw nsw i32 %22, 1
br label %28
28: ; preds = %25, %21
%29 = phi i32 [ %27, %25 ], [ %22, %21 ]
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%31 = icmp eq i32 %30, 1
br i1 %31, label %35, label %32
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%34 = add nuw nsw i32 %29, 1
br label %35
35: ; preds = %32, %28
%36 = phi i32 [ %34, %32 ], [ %29, %28 ]
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%38 = icmp eq i32 %37, 2
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%41 = add nuw nsw i32 %36, 1
br label %42
42: ; preds = %39, %35
%43 = phi i32 [ %41, %39 ], [ %36, %35 ]
ret i32 %43
}