#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 */
scalar_t__ checked_sscanf(int, char *, char *, int *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int n, m;
  printf("Parsing '1 2'...");
  if (checked_sscanf(2, "1 2", "%d %d", &n, &m))
    puts("success");
  else
    puts("failure");
  printf("Parsing '1 a'...");
  if (checked_sscanf(2, "1 a", "%d %d", &n, &m))
    puts("success");
  else
    puts("failure");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
lea    0xeba(%rip),%rsi
lea    0xeb7(%rip),%rdx
lea    -0x8(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1050 <checked_sscanf@plt>
cmp    $0x0,%rax
je     1186 <main+0x56>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
jmp    1192 <main+0x62>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
lea    0xe92(%rip),%rsi
lea    0xe64(%rip),%rdx
lea    -0x8(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1050 <checked_sscanf@plt>
cmp    $0x0,%rax
je     11d9 <main+0xa9>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
jmp    11e5 <main+0xb5>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xec1(%rip),%rsi
lea    0xebe(%rip),%r14
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r15
mov    $0x2,%edi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1050 <checked_sscanf@plt>
test   %rax,%rax
lea    0xea5(%rip),%r13
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
cmove  %r13,%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xe98(%rip),%rsi
mov    $0x2,%edi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1050 <checked_sscanf@plt>
test   %rax,%rax
cmove  %r13,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Parsing '1 2'...\00"
@.str.1 = [4 x i8] c"1 2\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [8 x i8] c"success\00"
@.str.4 = [8 x i8] c"failure\00"
@.str.5 = [17 x i8] c"Parsing '1 a'...\00"
@.str.6 = [4 x i8] c"1 a\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @checked_sscanf(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%13 = call i64 @checked_sscanf(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %11
%18 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [17 x i8] c"Parsing '1 2'...\00"
@.str.1 = [4 x i8] c"1 2\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [8 x i8] c"success\00"
@.str.4 = [8 x i8] c"failure\00"
@.str.5 = [17 x i8] c"Parsing '1 a'...\00"
@.str.6 = [4 x i8] c"1 a\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @checked_sscanf(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%9 = call i32 @puts(i8* dereferenceable(1) %8)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%11 = call i64 @checked_sscanf(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 @puts(i8* dereferenceable(1) %13)
ret i32 0
}