#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*/ abort();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int main(int argc, char *argv[]) {
  int a, b;
  a = b = -1;
  sscanf("12ab", "%dab%n", &a, &b);
  printf("%d, %d\n", a, b);
  if (a != 12 || b != 4)
    abort();
  a = b = -1;
  sscanf("12ab100", "%dab%n100", &a, &b);
  printf("%d, %d\n", a, b);
  if (a != 12 || b != 4)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x14(%rbp)
lea    0xea5(%rip),%rdi
lea    0xea3(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xc,-0x14(%rbp)
jne    1195 <main+0x65>
cmpl   $0x4,-0x18(%rbp)
je     119c <main+0x6c>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x14(%rbp)
lea    0xe63(%rip),%rdi
lea    0xe64(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xc,-0x14(%rbp)
jne    11eb <main+0xbb>
cmpl   $0x4,-0x18(%rbp)
je     11f2 <main+0xc2>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0xffffffff,(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xeb9(%rip),%rdi
lea    0xeb7(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xc,0x4(%rsp)
jne    11c9 <main+0x99>
cmpl   $0x4,(%rsp)
jne    11c9 <main+0x99>
movl   $0xffffffff,(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xe83(%rip),%rdi
lea    0xe84(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xc,0x4(%rsp)
jne    11c9 <main+0x99>
cmpl   $0x4,(%rsp)
jne    11c9 <main+0x99>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"12ab\00"
@.str.1 = [7 x i8] c"%dab%n\00"
@.str.2 = [8 x i8] c"%d, %d\0A\00"
@.str.3 = [8 x i8] c"12ab100\00"
@.str.4 = [10 x i8] c"%dab%n100\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
store i32 -1, i32* %6
%8 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 12
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %19
17: ; preds = %14, %2
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %14
store i32 -1, i32* %7
store i32 -1, i32* %6
%20 = call i32 @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 12
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 4
br i1 %28, label %29, label %31
29: ; preds = %26, %19
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"12ab\00"
@.str.1 = [7 x i8] c"%dab%n\00"
@.str.2 = [8 x i8] c"%d, %d\0A\00"
@.str.3 = [8 x i8] c"12ab100\00"
@.str.4 = [10 x i8] c"%dab%n100\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
store i32 -1, i32* %3
%7 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 12
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %2
store i32 -1, i32* %4
store i32 -1, i32* %3
%19 = call i32 @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 12
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 4
%27 = select i1 %24, i1 true, i1 %26
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %18
ret i32 0
}