#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*/ assert(int);
int /*<<< orphan*/ free(void *);
int sscanf(char *, char *, ...);
int sscanf_t02(void) {
  int rc;
  char a, b, c;
  char *pa;
  rc = sscanf("abc", "%c", &a);
  assert(rc == 1);
  assert(a == 'a');
  rc = sscanf("abcdef", "%c%c%c", &a, &b, &c);
  assert(rc == 3);
  assert(a == 'a');
  assert(b == 'b');
  assert(c == 'c');
  b = 'X';
  rc = sscanf("def", "%c%*c%c", &a, &c);
  assert(rc == 2);
  assert(a == 'd');
  assert(b == 'X');
  assert(c == 'f');
  a = 'X';
  c = 'X';
  rc = sscanf("dZf", "%cZ%c", &a, &c);
  assert(rc == 2);
  assert(a == 'd');
  assert(c == 'f');
  a = 'X';
  c = 'X';
  rc = sscanf("d     f", "%c %c", &a, &c);
  assert(rc == 2);
  assert(a == 'd');
  assert(c == 'f');
  rc = sscanf("123456", "%mc", &pa);
  assert(rc == 1);
  assert(*pa == '1');
  free((void *)pa);
  return 0;
}


x86 assembly (clang, -O0):
<sscanf_t02>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xee9(%rip),%rsi
lea    -0x5(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe84(%rip),%rdi
lea    0xe84(%rip),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x6(%rbp),%rcx
lea    -0x7(%rbp),%r8
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x62,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x63,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movb   $0x58,-0x6(%rbp)
lea    0xe12(%rip),%rdi
lea    0xe16(%rip),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x7(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x58,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x66,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movb   $0x58,-0x5(%rbp)
movb   $0x58,-0x7(%rbp)
lea    0xdb0(%rip),%rdi
lea    0xdad(%rip),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x7(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x66,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movb   $0x58,-0x5(%rbp)
movb   $0x58,-0x7(%rbp)
lea    0xd59(%rip),%rdi
lea    0xd5a(%rip),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x7(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x66,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xd0e(%rip),%rdi
lea    0xd0e(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sscanf_t02>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
lea    0xeea(%rip),%rsi
lea    0xd(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x61,0xd(%rsp)
sete   %dil
call   1040 <assert@plt>
lea    0xe8b(%rip),%rdi
lea    0xe8b(%rip),%rsi
lea    0xf(%rsp),%rcx
lea    0xe(%rsp),%r14
mov    %rbx,%rdx
mov    %r14,%r8
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x61,0xd(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x62,0xf(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x63,0xe(%rsp)
sete   %dil
call   1040 <assert@plt>
movb   $0x58,0xf(%rsp)
lea    0xe26(%rip),%rdi
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x64,0xd(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x58,0xf(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x66,0xe(%rsp)
sete   %dil
call   1040 <assert@plt>
movb   $0x58,0xd(%rsp)
movb   $0x58,0xe(%rsp)
lea    0xdd6(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x64,0xd(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x66,0xe(%rsp)
sete   %dil
call   1040 <assert@plt>
movb   $0x58,0xd(%rsp)
movb   $0x58,0xe(%rsp)
lea    0xd8d(%rip),%rdi
lea    0xd8e(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x64,0xd(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x66,0xe(%rsp)
sete   %dil
call   1040 <assert@plt>
lea    0xd52(%rip),%rdi
lea    0xd52(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x10(%rsp),%rax
xor    %edi,%edi
cmpb   $0x31,(%rax)
sete   %dil
call   1040 <assert@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c"abcdef\00"
@.str.3 = [7 x i8] c"%c%c%c\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [8 x i8] c"%c%*c%c\00"
@.str.6 = [4 x i8] c"dZf\00"
@.str.7 = [6 x i8] c"%cZ%c\00"
@.str.8 = [8 x i8] c"d f\00"
@.str.9 = [6 x i8] c"%c %c\00"
@.str.10 = [7 x i8] c"123456\00"
@.str.11 = [4 x i8] c"%mc\00"
define i32 @sscanf_t02() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8*
%6 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 1
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 97
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %3, i8* %4)
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 3
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 97
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 98
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 99
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
store i8 88, i8* %3
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %4)
store i32 %36, i32* %1
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 2
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 100
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i8, i8* %3
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 88
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i8, i8* %4
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 102
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
store i8 88, i8* %2
store i8 88, i8* %4
%56 = call i32 (i8*, i8*, ...) @sscanf(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.7, i64 0, i64 0), i8* %2, i8* %4)
store i32 %56, i32* %1
%57 = load i32, i32* %1
%58 = icmp eq i32 %57, 2
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i8, i8* %2
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 100
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i8, i8* %4
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 102
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
store i8 88, i8* %2
store i8 88, i8* %4
%71 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %2, i8* %4)
store i32 %71, i32* %1
%72 = load i32, i32* %1
%73 = icmp eq i32 %72, 2
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = load i8, i8* %2
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 100
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = load i8, i8* %4
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 102
%84 = zext i1 %83 to i32
%85 = call i32 @assert(i32 %84)
%86 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8** %5)
store i32 %86, i32* %1
%87 = load i32, i32* %1
%88 = icmp eq i32 %87, 1
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
%91 = load i8*, i8** %5
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 49
%95 = zext i1 %94 to i32
%96 = call i32 @assert(i32 %95)
%97 = load i8*, i8** %5
%98 = call i32 @free(i8* %97)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c"abcdef\00"
@.str.3 = [7 x i8] c"%c%c%c\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [8 x i8] c"%c%*c%c\00"
@.str.6 = [4 x i8] c"dZf\00"
@.str.7 = [6 x i8] c"%cZ%c\00"
@.str.8 = [8 x i8] c"d f\00"
@.str.9 = [6 x i8] c"%c %c\00"
@.str.10 = [7 x i8] c"123456\00"
@.str.11 = [4 x i8] c"%mc\00"
define i32 @sscanf_t02() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%7 = icmp eq i32 %6, 1
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 97
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2, i8* %3)
%15 = icmp eq i32 %14, 3
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8, i8* %1
%19 = icmp eq i8 %18, 97
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i8, i8* %2
%23 = icmp eq i8 %22, 98
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i8, i8* %3
%27 = icmp eq i8 %26, 99
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
store i8 88, i8* %2
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %3)
%31 = icmp eq i32 %30, 2
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i8, i8* %1
%35 = icmp eq i8 %34, 100
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i8, i8* %2
%39 = icmp eq i8 %38, 88
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i8, i8* %3
%43 = icmp eq i8 %42, 102
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
store i8 88, i8* %1
store i8 88, i8* %3
%46 = call i32 (i8*, i8*, ...) @sscanf(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.7, i64 0, i64 0), i8* %1, i8* %3)
%47 = icmp eq i32 %46, 2
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i8, i8* %1
%51 = icmp eq i8 %50, 100
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i8, i8* %3
%55 = icmp eq i8 %54, 102
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
store i8 88, i8* %1
store i8 88, i8* %3
%58 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %1, i8* %3)
%59 = icmp eq i32 %58, 2
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = load i8, i8* %1
%63 = icmp eq i8 %62, 100
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i8, i8* %3
%67 = icmp eq i8 %66, 102
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = call i32 (i8*, i8*, ...) @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8** %4)
%71 = icmp eq i32 %70, 1
%72 = zext i1 %71 to i32
%73 = call i32 @assert(i32 %72)
%74 = load i8*, i8** %4
%75 = load i8, i8* %74
%76 = icmp eq i8 %75, 49
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = load i8*, i8** %4
%80 = call i32 @free(i8* %79)
ret i32 0
}