#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 sscanf(char *, char *, int *, int *, int *, int *);
int main(int argc, char *argv[]) {
  int d1, n1, n2, i;
  int d2 = 1234567;
  i = sscanf("123", "%d%n%n%d", &d1, &n1, &n2, &d2);
  return i != 1 || d1 != 123 || n1 != 3 || n2 != 3 || d2 != 1234567;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x12d687,-0x24(%rbp)
lea    0xecc(%rip),%rdi
lea    0xec9(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1030 <sscanf@plt>
mov    %eax,-0x20(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x20(%rbp)
mov    %al,-0x25(%rbp)
jne    119c <main+0x8c>
mov    $0x1,%al
cmpl   $0x7b,-0x14(%rbp)
mov    %al,-0x25(%rbp)
jne    119c <main+0x8c>
mov    $0x1,%al
cmpl   $0x3,-0x18(%rbp)
mov    %al,-0x25(%rbp)
jne    119c <main+0x8c>
mov    $0x1,%al
cmpl   $0x3,-0x1c(%rbp)
mov    %al,-0x25(%rbp)
jne    119c <main+0x8c>
cmpl   $0x12d687,-0x24(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x12d687,0x8(%rsp)
lea    0xedd(%rip),%rdi
lea    0xeda(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1030 <sscanf@plt>
xor    $0x1,%eax
mov    0x14(%rsp),%ecx
xor    $0x7b,%ecx
or     %eax,%ecx
mov    0x10(%rsp),%eax
xor    $0x3,%eax
mov    0xc(%rsp),%edx
xor    $0x3,%edx
or     %eax,%edx
mov    $0x12d687,%esi
xor    0x8(%rsp),%esi
or     %ecx,%edx
xor    %eax,%eax
or     %edx,%esi
setne  %al
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
@.str.1 = [9 x i8] c"%d%n%n%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 1234567, i32* %6
%11 = call i32 @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%12 = icmp ne i32 %11, 1
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 123
%15 = select i1 %12, i1 true, i1 %14
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
%18 = select i1 %15, i1 true, i1 %17
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 3
%21 = select i1 %18, i1 true, i1 %20
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 1234567
%24 = select i1 %21, i1 true, i1 %23
%25 = zext i1 %24 to i32
ret i32 %25
}