#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*/ puts(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char buf[100];
  int a, b;
  int status = 0;
  sscanf("12ab", "%dab%n", &a, &b);
  sprintf(buf, "%d, %d", a, b);
  puts(buf);
  status |= strcmp(buf, "12, 4");
  sscanf("12ab100", "%dab%n100", &a, &b);
  sprintf(buf, "%d, %d", a, b);
  puts(buf);
  status |= strcmp(buf, "12, 4");
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x8c(%rbp)
lea    0xe96(%rip),%rdi
lea    0xe94(%rip),%rsi
lea    -0x84(%rbp),%rdx
lea    -0x88(%rbp),%rcx
call   1050 <sscanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    -0x88(%rbp),%ecx
lea    0xe71(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x80(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1040 <strcmp@plt>
or     -0x8c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    0xe4d(%rip),%rdi
lea    0xe4e(%rip),%rsi
lea    -0x84(%rbp),%rdx
lea    -0x88(%rbp),%rcx
call   1050 <sscanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    -0x88(%rbp),%ecx
lea    0xe0f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x80(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1040 <strcmp@plt>
or     -0x8c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xeab(%rip),%rdi
lea    0xea9(%rip),%rsi
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe8c(%rip),%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    %eax,%ebp
lea    0xe66(%rip),%rdi
lea    0xe67(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
or     %ebp,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"12ab\00"
@.str.1 = [7 x i8] c"%dab%n\00"
@.str.2 = [7 x i8] c"%d, %d\00"
@.str.3 = [6 x i8] c"12, 4\00"
@.str.4 = [8 x i8] c"12ab100\00"
@.str.5 = [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 [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = 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* %7, i32* %8)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = call i32 @puts(i8* %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %9
%20 = or i32 %19, %18
store i32 %20, i32* %9
%21 = call i32 @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32* %7, i32* %8)
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = call i32 @puts(i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %9
%31 = or i32 %30, %29
store i32 %31, i32* %9
%32 = load i32, i32* %9
ret i32 %32
}

LLVM IR (-O2):
@.str = [5 x i8] c"12ab\00"
@.str.1 = [7 x i8] c"%dab%n\00"
@.str.2 = [7 x i8] c"%d, %d\00"
@.str.3 = [6 x i8] c"12, 4\00"
@.str.4 = [8 x i8] c"12ab100\00"
@.str.5 = [10 x i8] c"%dab%n100\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = 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* %4, i32* %5)
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = call i32 @puts(i8* %6)
%14 = call i32 @strcmp(i8* %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17)
%19 = call i32 @puts(i8* %6)
%20 = call i32 @strcmp(i8* %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%21 = or i32 %20, %14
ret i32 %21
}