#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 *, ...);
int main() {
  int ret, err = 0, e1, e2;
  const char a1[] = "3.0", a2[] = "-12,1000";
  ret = sscanf(a1, "%1d", &e1);
  if (ret != 1) {
    printf("Error wrong sscanf int return %d.\n", ret);
    err++;
  }
  if (e1 != 3) {
    printf("Error wrong sscanf int reading %d.\n", e1);
    err++;
  }
  ret = sscanf(a2, "%3d,%4d", &e1, &e2);
  if (ret != 2) {
    printf("Error wrong sscanf int return %d.\n", ret);
    err++;
  }
  if (e1 != -12) {
    printf("Error wrong sscanf int reading %d.\n", e1);
    err++;
  }
  if (e2 != 1000) {
    printf("Error wrong sscanf int reading %d.\n", e2);
    err++;
  }
  if (err)
    return err;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xebc(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xeaf(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     118e <main+0x6e>
mov    -0x8(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0x10(%rbp)
je     11b0 <main+0x90>
mov    -0x10(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    -0x21(%rbp),%rdi
lea    0xe9d(%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     11ef <main+0xcf>
mov    -0x8(%rbp),%esi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xfffffff4,-0x10(%rbp)
je     1211 <main+0xf1>
mov    -0x10(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
je     1236 <main+0x116>
mov    -0x14(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     124b <main+0x12b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <main+0x132>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x302e33,0x8(%rsp)
movabs $0x303030312c32312d,%rax
30 30 30
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0xec1(%rip),%rsi
xor    %ebx,%ebx
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1173 <main+0x53>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    0x4(%rsp),%esi
cmp    $0x3,%esi
je     118b <main+0x6b>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%ebx
lea    0xec2(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11be <main+0x9e>
lea    0xe59(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%esi
cmp    $0xfffffff4,%esi
je     11d6 <main+0xb6>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%esi
cmp    $0x3e8,%esi
je     11f1 <main+0xd1>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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